/* ===========================
   UTDELNINGSSMART — Dashboard CSS
   =========================== */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  --e: #059669;
  --e-light: #d1fae5;
  --e-dark: #047857;
  --e-glow: rgba(5,150,105,0.15);
  --w: #ffffff;
  --b1: #f8fafc;
  --b2: #f1f5f9;
  --b3: #e2e8f0;
  --t1: #0f172a;
  --t2: #334155;
  --t3: #64748b;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 2px 12px rgba(0,0,0,0.06);
  --sidebar: 260px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Inter', -apple-system, sans-serif;
  background: var(--b1);
  color: var(--t1);
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar);
  background: var(--w);
  border-right: 1px solid var(--b2);
  padding: 24px;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 50;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--t1);
  text-decoration: none;
  margin-bottom: 32px;
}

.sidebar-logo .icon {
  width: 32px;
  height: 32px;
  background: var(--e);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1rem;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  color: var(--t2);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
}

.sidebar-nav a:hover {
  background: var(--b2);
  color: var(--t1);
}

.sidebar-nav a.active {
  background: var(--e-light);
  color: var(--e-dark);
  font-weight: 600;
}

.sidebar-nav a .nav-icon {
  font-size: 1.1rem;
  width: 24px;
  text-align: center;
}

.sidebar-user {
  padding-top: 16px;
  border-top: 1px solid var(--b2);
  display: flex;
  align-items: center;
  gap: 12px;
}

.sidebar-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--e-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--e);
  font-size: 0.9rem;
}

.sidebar-user-info {
  flex: 1;
}

.sidebar-user-name {
  font-size: 0.85rem;
  font-weight: 600;
}

.sidebar-user-plan {
  font-size: 0.75rem;
  color: var(--e);
  font-weight: 600;
}

/* ===== MAIN ===== */
.main {
  margin-left: var(--sidebar);
  flex: 1;
  padding: 32px 40px;
  max-width: 1200px;
}

.main-header {
  margin-bottom: 32px;
}

.main-header h1 {
  font-size: 1.8rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.main-header p {
  color: var(--t3);
  font-size: 0.95rem;
  margin-top: 4px;
}

/* ===== STATS ROW ===== */
.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--w);
  border: 1px solid var(--b2);
  border-radius: var(--radius);
  padding: 20px;
  transition: border-color 0.2s;
}

.stat-card:hover {
  border-color: var(--e);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--t3);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--t1);
}

.stat-change {
  font-size: 0.8rem;
  font-weight: 600;
  margin-top: 2px;
}

.stat-change.up { color: var(--e); }
.stat-change.neutral { color: var(--t3); }

/* ===== CALENDAR ===== */
.calendar-section {
  background: var(--w);
  border: 1px solid var(--b2);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 32px;
}

.section-title {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.section-sub {
  font-size: 0.85rem;
  color: var(--t3);
  margin-bottom: 20px;
}

.calendar-month {
  margin-bottom: 24px;
}

.calendar-month:last-child { margin-bottom: 0; }

.month-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--e);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 2px solid var(--e-light);
}

.month-total {
  float: right;
  color: var(--t1);
  font-weight: 700;
}

.calendar-event {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  gap: 16px;
  align-items: center;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  background: var(--b1);
  margin-bottom: 6px;
  transition: all 0.2s;
  cursor: default;
}

.calendar-event:hover {
  background: var(--e-light);
  transform: translateX(4px);
}

.event-date {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--t3);
}

.event-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.event-ticker {
  font-weight: 700;
  font-size: 0.9rem;
}

.event-name {
  font-size: 0.85rem;
  color: var(--t3);
}

.event-amount {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--e);
  white-space: nowrap;
}

.event-status {
  font-size: 0.7rem;
  padding: 3px 10px;
  border-radius: 100px;
  font-weight: 600;
  text-transform: uppercase;
}

.event-status.pending { background: #fef3c7; color: #d97706; }
.event-status.paid { background: var(--e-light); color: var(--e-dark); }
.event-status.soon { background: #dbeafe; color: #2563eb; }

.calendar-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--t3);
}

.calendar-empty .emoji {
  font-size: 3rem;
  margin-bottom: 16px;
}

.calendar-empty p {
  font-size: 0.95rem;
}

/* ===== AI PANEL ===== */
.ai-panel {
  background: linear-gradient(135deg, var(--t1) 0%, #1e293b 100%);
  border-radius: var(--radius);
  padding: 28px;
  color: white;
  margin-bottom: 32px;
}

.ai-panel-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.ai-pulse {
  width: 8px;
  height: 8px;
  background: var(--e);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.ai-panel h3 {
  font-size: 1rem;
  font-weight: 700;
}

.ai-recommendation {
  background: rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  padding: 20px;
  margin-bottom: 12px;
}

.ai-recommendation:last-child { margin-bottom: 0; }

.ai-rec-title {
  font-size: 0.95rem;
  font-weight: 700;
  margin-bottom: 6px;
}

.ai-rec-text {
  font-size: 0.88rem;
  color: rgba(255,255,255,0.7);
  line-height: 1.7;
  margin-bottom: 12px;
}

.ai-rec-tag {
  display: inline-block;
  padding: 4px 12px;
  background: rgba(5,150,105,0.2);
  color: #34d399;
  border-radius: 100px;
  font-size: 0.75rem;
  font-weight: 600;
}

.ai-rec-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 20px;
  background: var(--e);
  color: white;
  border-radius: 100px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all 0.2s;
  margin-top: 12px;
}

.ai-rec-btn:hover {
  background: var(--e-dark);
  transform: translateY(-1px);
}

/* ===== PORTFOLIO TABLE ===== */
.table-section {
  background: var(--w);
  border: 1px solid var(--b2);
  border-radius: var(--radius);
  padding: 28px;
  margin-bottom: 32px;
}

.portfolio-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.portfolio-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--t3);
  font-weight: 600;
  border-bottom: 2px solid var(--b2);
}

.portfolio-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--b2);
}

.portfolio-table tr:last-child td { border-bottom: none; }

.portfolio-table tr:hover td {
  background: var(--b1);
}

.ticker-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.ticker-badge {
  font-weight: 700;
  font-size: 0.85rem;
}

.ticker-name {
  font-size: 0.8rem;
  color: var(--t3);
}

/* ===== SETUP FLOW ===== */
.setup-flow {
  background: var(--w);
  border: 1px solid var(--b2);
  border-radius: var(--radius);
  padding: 48px;
  text-align: center;
  margin-bottom: 32px;
}

.setup-flow .emoji-big {
  font-size: 3rem;
  margin-bottom: 16px;
}

.setup-flow h2 {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.setup-flow p {
  color: var(--t3);
  max-width: 480px;
  margin: 0 auto 28px;
}

.csv-upload {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.csv-zone {
  border: 2px dashed var(--b3);
  border-radius: var(--radius-sm);
  padding: 40px;
  width: 100%;
  max-width: 500px;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--b1);
}

.csv-zone:hover {
  border-color: var(--e);
  background: var(--e-light);
}

.csv-zone .icon {
  font-size: 2rem;
  margin-bottom: 12px;
}

.csv-zone .text {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--t2);
}

.csv-zone .sub {
  font-size: 0.8rem;
  color: var(--t3);
  margin-top: 4px;
}

.csv-zone input[type="file"] {
  display: none;
}

/* ===== LOADING ===== */
.loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 0;
  color: var(--t3);
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--b2);
  border-top-color: var(--e);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 16px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .sidebar {
    display: none;
  }
  .main {
    margin-left: 0;
    padding: 20px;
  }
  .stats {
    grid-template-columns: repeat(2, 1fr);
  }
  .calendar-event {
    grid-template-columns: 60px 1fr;
  }
  .portfolio-table {
    font-size: 0.8rem;
  }
  .setup-flow {
    padding: 24px;
  }
}
