/* ─────────────────────────────────────────────────────────────────────────
   Expense Analyzer — main.css  (Minimal theme + Sidebar layout)
   ───────────────────────────────────────────────────────────────────────── */

/* ── Reset ───────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ── Design Tokens ───────────────────────────────────────────────────────── */
:root {
  --primary:        #6b4fbb;
  --primary-dark:   #5a3fa8;
  --primary-light:  #ede9fe;
  --primary-subtle: #f5f3ff;

  --success:  #16a34a;
  --danger:   #dc2626;
  --warning:  #d97706;

  --text:     #111827;
  --text-2:   #374151;
  --muted:    #6b7280;
  --border:   #e5e7eb;
  --bg:       #f9fafb;
  --surface:  #ffffff;

  --sidebar-w: 232px;
  --radius:    8px;
  --radius-sm: 6px;
  --shadow:    0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
}

html, body {
  font-family: 'Lato', sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  min-height: 100vh;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

/* ═══════════════════════════════════════════════════════════════════════════
   SIDEBAR LAYOUT
   ═══════════════════════════════════════════════════════════════════════════ */

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

/* Brand */
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 20px 18px;
  border-bottom: 1px solid var(--border);
}

.brand-icon {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.brand-icon i { width: 18px; height: 18px; color: #fff; }

.brand-icon i { width: 18px; height: 18px; color: #fff; }

.brand-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: var(--muted);
}

/* Nav */
.sidebar-nav {
  flex: 1;
  padding: 12px 12px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 8px 8px 4px;
  margin-top: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  transition: background 0.12s, color 0.12s;
  cursor: pointer;
  text-decoration: none;
}

.nav-item i { width: 13px; height: 13px; flex-shrink: 0; }

.nav-item:hover {
  background: var(--bg);
  color: var(--text);
  text-decoration: none;
}

.nav-item.active {
  background: var(--primary-subtle);
  color: var(--primary);
}

.nav-item.active i { color: var(--primary); }

/* User footer */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
}
.sidebar-version {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  padding: 4px 0 8px;
  letter-spacing: 0.5px;
  opacity: 0.7;
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.12s;
  position: relative;
}

.sidebar-user:hover { background: var(--bg); }

.user-avatar {
  width: 32px; height: 32px;
  background: var(--primary-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700;
  font-size: 13px;
  color: var(--primary);
  flex-shrink: 0;
}

.user-info { flex: 1; min-width: 0; }

.user-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role {
  font-size: 11px;
  color: var(--muted);
}

.sidebar-user i { width: 14px; height: 14px; color: var(--muted); flex-shrink: 0; }

/* User dropdown (sidebar) */
.user-dropdown {
  display: none;
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0; right: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  overflow: hidden;
  z-index: 100;
}

.user-dropdown.open { display: block; }

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: 'Lato', sans-serif;
  font-size: 13px;
  color: var(--text);
  text-align: left;
  transition: background 0.1s;
}

.dropdown-item:hover { background: var(--bg); }
.dropdown-item i { width: 14px; height: 14px; color: var(--muted); }

/* ── Main Content ────────────────────────────────────────────────────────── */
.app-main {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-topbar {
  padding: 24px 32px 0;
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 24px;
}

.page-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.page-subtitle {
  font-size: 13px;
  color: var(--muted);
  margin-top: 2px;
}

.page-actions { display: flex; gap: 8px; align-items: center; }

.page-body { padding: 0 32px 32px; }

/* ═══════════════════════════════════════════════════════════════════════════
   COMPONENTS
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-family: 'Lato', sans-serif;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  border: none;
  transition: background 0.13s, box-shadow 0.13s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
}

.btn i { width: 14px; height: 14px; }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover {
  background: var(--primary-dark);
  color: #fff;
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(107,79,187,0.3);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg); text-decoration: none; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; text-decoration: none; color: #fff; }

.btn-ghost { background: transparent; color: var(--muted); }
.btn-ghost:hover { background: var(--bg); color: var(--text); text-decoration: none; }

.btn-full { width: 100%; justify-content: center; padding: 11px 16px; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; pointer-events: none; }

/* ── Cards ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 20px 24px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
}

/* ── Stat Cards ──────────────────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 14px;
  margin-bottom: 20px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
}

.stat-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-label i { width: 13px; height: 13px; }

.stat-value {
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  line-height: 1;
}

.stat-value.primary { color: var(--primary); }
.stat-value.success { color: var(--success); }
.stat-value.warning { color: var(--warning); }
.stat-value.danger  { color: var(--danger); }

/* ── Welcome Banner ──────────────────────────────────────────────────────── */
.welcome-banner {
  background: var(--primary-subtle);
  border: 1px solid var(--primary-light);
  border-radius: var(--radius);
  padding: 28px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.welcome-icon {
  width: 48px; height: 48px;
  background: var(--primary-light);
  border-radius: var(--radius);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

.welcome-icon i { width: 22px; height: 22px; color: var(--primary); }
.welcome-banner h2 { font-size: 15px; font-weight: 700; margin-bottom: 3px; }
.welcome-banner p { font-size: 13px; color: var(--muted); }

/* ── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
  margin-bottom: 6px;
}

.form-input {
  display: block;
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: 'Lato', sans-serif;
  font-size: 13px;
  color: var(--text);
  background: var(--surface);
  outline: none;
  transition: border-color 0.13s, box-shadow 0.13s;
  -webkit-appearance: none;
}

.form-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(107,79,187,0.1);
}

.form-input::placeholder { color: #9ca3af; }
.form-input:disabled { background: var(--bg); color: var(--muted); }

/* Input with leading icon */
.input-group {
  position: relative;
}

.input-group .input-icon {
  position: absolute;
  left: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 15px; height: 15px;
  color: var(--muted);
  pointer-events: none;
  display: flex; align-items: center; justify-content: center;
}

.input-group .input-icon svg {
  width: 15px; height: 15px;
}

.input-group .form-input {
  padding-left: 34px;
}

select.form-input { padding-left: 12px; cursor: pointer; }

/* ── Alerts / Banners ────────────────────────────────────────────────────── */
.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 14px;
  border: 1px solid #fecaca;
  background: #fef2f2;
  color: #b91c1c;
}

.alert-success {
  background: #f0fdf4;
  border-color: #bbf7d0;
  color: #15803d;
}

.hidden { display: none !important; }

/* ── Table ───────────────────────────────────────────────────────────────── */
.table-wrapper {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.data-table thead { background: var(--bg); }

.data-table th {
  padding: 11px 16px;
  text-align: left;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.data-table td {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #fafafa; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 700;
}

.badge-needs      { background: #dbeafe; color: #1d4ed8; }
.badge-wants      { background: #fef9c3; color: #92400e; }
.badge-investment { background: #dcfce7; color: #166534; }
.badge-unknown    { background: #f3f4f6; color: #6b7280; }
.badge-debit      { background: #fee2e2; color: #b91c1c; }
.badge-credit     { background: #dcfce7; color: #166534; }

/* ── Filters Bar ─────────────────────────────────────────────────────────── */
.filters-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
}

.filters-bar .form-input {
  padding: 7px 10px;
  height: 32px;
  font-size: 13px;
}

/* ── Pagination ──────────────────────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--border);
}

.pagination-controls { display: flex; gap: 4px; }

.page-btn {
  width: 30px; height: 30px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px;
  font-family: 'Lato', sans-serif;
  color: var(--text-2);
  transition: background 0.1s;
}

.page-btn:hover { background: var(--primary-subtle); color: var(--primary); border-color: var(--primary-light); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── Toast ───────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 20px; right: 20px;
  background: var(--text);
  color: #fff;
  padding: 11px 18px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  box-shadow: var(--shadow-md);
  z-index: 9999;
  animation: fadeUp 0.18s ease;
}

.toast.success { background: #15803d; }
.toast.error   { background: var(--danger); }

@keyframes fadeUp {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.spinner {
  width: 15px; height: 15px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  display: inline-block;
}

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

/* ── Coming-soon ─────────────────────────────────────────────────────────── */
.coming-soon {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 56px 32px;
  text-align: center;
}

.coming-soon svg,
.coming-soon i {
  width: 40px; height: 40px;
  color: var(--primary);
  margin: 0 auto 14px;
  display: block;
}

.coming-soon h2 { font-size: 16px; font-weight: 700; color: var(--text); margin-bottom: 6px; }
.coming-soon p  { font-size: 13px; color: var(--muted); }

/* ═══════════════════════════════════════════════════════════════════════════
   AUTH PAGES  (login / signup — no sidebar)
   ═══════════════════════════════════════════════════════════════════════════ */

.auth-page {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.auth-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-md);
  padding: 36px 32px 32px;
  width: 100%;
  max-width: 380px;
}

/* Logo mark */
.auth-mark {
  width: 52px; height: 52px;
  background: var(--primary);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 20px;
}

.auth-mark svg { width: 24px; height: 24px; stroke: #fff; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.auth-heading {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  text-align: center;
  margin-bottom: 4px;
}

.auth-sub {
  font-size: 13px;
  color: var(--muted);
  text-align: center;
  margin-bottom: 28px;
}

.auth-divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

.auth-switch {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  margin-top: 20px;
}

.auth-switch a { color: var(--primary); font-weight: 700; }
.auth-switch a:hover { text-decoration: underline; }
