/**
 * style.css
 * Design tokens are drawn from the Sunshine Social Foundation mark: a warm
 * sunrise (amber → terracotta) rising between teal and navy figures. Rather
 * than a generic SaaS blue, the product's accent is that sunrise gradient —
 * used sparingly (KPI icons, active nav state, the signature dashboard
 * header) — set against a calm slate-and-cream neutral system so 11 KPI
 * cards and 8 charts stay legible rather than fighting for attention.
 */

:root {
  /* ---- Brand tokens (from FinalLogo.png) ---- */
  --sun-amber: #f5a623;
  --sun-orange: #f97316;
  --sun-teal: #0f766e;
  --sun-navy: #1e3a5f;

  /* ---- Neutral system ---- */
  --bg-canvas: #f4f6f9;
  --bg-surface: #ffffff;
  --bg-surface-soft: #f8fafc;
  --border-subtle: #e6e9ef;
  --text-primary: #1a2333;
  --text-secondary: #64748b;
  --text-muted: #94a3b8;

  --success: #10b981;
  --danger: #f43f5e;
  --warning: #f59e0b;
  --info: #0ea5e9;

  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-elevated: 0 8px 24px rgba(16, 24, 40, 0.10);
  --sidebar-w: 264px;
  --sidebar-w-collapsed: 84px;
  --topbar-h: 72px;

  --font-display: 'Sora', 'Segoe UI', sans-serif;
  --font-body: 'Inter', 'Segoe UI', sans-serif;
}

[data-theme="dark"] {
  --bg-canvas: #0f1621;
  --bg-surface: #161f2e;
  --bg-surface-soft: #1c2635;
  --border-subtle: #263143;
  --text-primary: #e8edf5;
  --text-secondary: #9aa7bc;
  --text-muted: #6b7788;
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.2), 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow-elevated: 0 12px 28px rgba(0, 0, 0, 0.4);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg-canvas);
  color: var(--text-primary);
  margin: 0;
  -webkit-font-smoothing: antialiased;
  transition: background 0.25s ease, color 0.25s ease;
}
h1, h2, h3, h4, h5, .font-display { font-family: var(--font-display); }
a { text-decoration: none; }
::selection { background: var(--sun-amber); color: #1a2333; }

/* ============ Layout shell ============ */
#appShell { display: flex; min-height: 100vh; }

.app-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: linear-gradient(180deg, var(--sun-navy) 0%, #14283f 100%);
  color: #dbe4f0;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  transition: width 0.25s ease;
  z-index: 40;
}
.app-sidebar.collapsed { width: var(--sidebar-w-collapsed); }
.app-sidebar.collapsed .nav-label,
.app-sidebar.collapsed .brand-text,
.app-sidebar.collapsed .nav-section-title { display: none; }
.app-sidebar.collapsed .btn-collapse i { transform: rotate(180deg); }

.sidebar-brand {
  display: flex; align-items: center; gap: 12px;
  padding: 20px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-logo { width: 38px; height: 38px; border-radius: 10px; object-fit: cover; flex-shrink: 0; background: #fff; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 0.92rem; line-height: 1.2; color: #fff; }
.brand-sub { font-size: 0.72rem; color: #93a5c2; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 14px 10px; }
.nav-section { margin-bottom: 6px; }
.nav-section-title {
  font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em;
  color: #6f83a3; padding: 14px 12px 6px;
}
.nav-link-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; margin: 2px 0; border-radius: var(--radius-sm);
  color: #c3d0e5; font-size: 0.88rem; font-weight: 500;
  transition: background 0.15s ease, color 0.15s ease;
}
.nav-link-item i { width: 18px; text-align: center; font-size: 0.95rem; }
.nav-link-item:hover { background: rgba(255,255,255,0.06); color: #fff; }
.nav-link-item.active {
  background: linear-gradient(90deg, var(--sun-orange), var(--sun-amber));
  color: #1a1408; font-weight: 600;
  box-shadow: 0 4px 12px rgba(249, 115, 22, 0.35);
}
.sidebar-footer { padding: 12px; border-top: 1px solid rgba(255,255,255,0.08); }
.btn-collapse {
  background: rgba(255,255,255,0.06); border: none; color: #c3d0e5;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 8px; border-radius: var(--radius-sm); font-size: 0.8rem;
}
.btn-collapse:hover { background: rgba(255,255,255,0.12); color: #fff; }

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
  height: var(--topbar-h);
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; position: sticky; top: 0; z-index: 30;
  backdrop-filter: saturate(1.2);
}
.topbar-left { display: flex; align-items: center; gap: 14px; }
.page-title { font-size: 1.15rem; font-weight: 700; margin: 0; }
.breadcrumb-trail { font-size: 0.78rem; color: var(--text-muted); display: flex; gap: 6px; align-items: center; }
.crumb-sep { font-size: 0.6rem; }
.crumb-current { color: var(--sun-orange); font-weight: 600; }

.topbar-right { display: flex; align-items: center; gap: 10px; }
.btn-icon {
  width: 38px; height: 38px; border-radius: 50%; border: 1px solid var(--border-subtle);
  background: var(--bg-surface-soft); color: var(--text-secondary);
  display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: var(--sun-amber); color: #1a1408; border-color: var(--sun-amber); }

.global-search { position: relative; display: flex; align-items: center; background: var(--bg-surface-soft); border: 1px solid var(--border-subtle); border-radius: 999px; padding: 0 14px; width: 320px; }
.global-search i { color: var(--text-muted); font-size: 0.85rem; }
.global-search input { border: none; background: transparent; outline: none; padding: 9px 10px; width: 100%; font-size: 0.85rem; color: var(--text-primary); }
.global-search-results {
  position: absolute; top: 46px; left: 0; width: 100%; background: var(--bg-surface);
  border: 1px solid var(--border-subtle); border-radius: var(--radius-md); box-shadow: var(--shadow-elevated);
  max-height: 320px; overflow-y: auto; display: none; z-index: 60;
}
.global-search-results.show { display: block; }
.search-result-item { display: flex; gap: 10px; padding: 10px 14px; align-items: center; border-bottom: 1px solid var(--border-subtle); cursor: pointer; }
.search-result-item:hover { background: var(--bg-surface-soft); }
.search-result-item i { color: var(--sun-orange); width: 16px; }
.sr-title { font-size: 0.84rem; font-weight: 600; }
.sr-sub { font-size: 0.72rem; color: var(--text-muted); }
.search-empty { padding: 14px; font-size: 0.82rem; color: var(--text-muted); text-align: center; }

.btn-user { display: flex; align-items: center; gap: 10px; background: none; border: none; padding: 4px 6px; border-radius: 999px; }
.btn-user:hover { background: var(--bg-surface-soft); }
.user-avatar {
  width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--sun-teal), var(--sun-navy)); color: #fff; font-weight: 700; font-size: 0.85rem;
}
.user-meta { text-align: left; line-height: 1.2; }
.user-name { display: block; font-size: 0.82rem; font-weight: 600; }
.user-role { display: block; font-size: 0.7rem; color: var(--text-muted); }

.app-content { padding: 24px; max-width: 1600px; width: 100%; margin: 0 auto; }

/* ============ Cards / KPIs ============ */
.section-card {
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-card);
  padding: 20px; margin-bottom: 22px;
}
.section-card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.section-card-title { font-family: var(--font-display); font-weight: 700; font-size: 1rem; margin: 0; }
.section-card-title .sub { font-family: var(--font-body); font-weight: 400; font-size: 0.78rem; color: var(--text-muted); display: block; margin-top: 2px; }

.kpi-card {
  background: var(--bg-surface); border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg); padding: 16px 18px; display: flex; gap: 14px; align-items: center;
  box-shadow: var(--shadow-card); height: 100%;
  animation: kpiRise 0.5s ease both;
}
@keyframes kpiRise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.kpi-icon {
  width: 44px; height: 44px; border-radius: var(--radius-md); display: flex; align-items: center; justify-content: center;
  font-size: 1.05rem; flex-shrink: 0;
}
.kpi-success .kpi-icon { background: #d1fae5; color: var(--success); }
.kpi-danger .kpi-icon { background: #fee2e2; color: var(--danger); }
.kpi-primary .kpi-icon { background: #dbeafe; color: #2563eb; }
.kpi-info .kpi-icon { background: #e0f2fe; color: var(--info); }
.kpi-warning .kpi-icon { background: #fef3c7; color: var(--warning); }
.kpi-secondary .kpi-icon { background: #ede9fe; color: #7c3aed; }
[data-theme="dark"] .kpi-success .kpi-icon { background: rgba(16,185,129,0.15); }
[data-theme="dark"] .kpi-danger .kpi-icon { background: rgba(244,63,94,0.15); }
[data-theme="dark"] .kpi-primary .kpi-icon { background: rgba(37,99,235,0.18); }
[data-theme="dark"] .kpi-info .kpi-icon { background: rgba(14,165,233,0.15); }
[data-theme="dark"] .kpi-warning .kpi-icon { background: rgba(245,158,11,0.15); }
[data-theme="dark"] .kpi-secondary .kpi-icon { background: rgba(124,58,237,0.18); }

.kpi-label { font-size: 0.74rem; color: var(--text-muted); font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em; }
.kpi-value { font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; margin-top: 2px; }

.chart-box { position: relative; height: 260px; }
.chart-box.short { height: 200px; }

.empty-state { text-align: center; padding: 30px 10px; color: var(--text-muted); }
.empty-state i { font-size: 1.8rem; margin-bottom: 10px; display: block; opacity: 0.5; }
.empty-state p { margin: 0; font-size: 0.85rem; }

.mini-table { font-size: 0.85rem; margin: 0; }
.mini-table th { color: var(--text-muted); font-weight: 600; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.03em; border-bottom: 1px solid var(--border-subtle); }
.mini-table td { border-bottom: 1px solid var(--border-subtle); color: var(--text-primary); }
.mini-table tr:last-child td { border-bottom: none; }

.badge-type { padding: 3px 10px; border-radius: 999px; font-size: 0.7rem; font-weight: 700; }
.badge-income { background: #d1fae5; color: #047857; }
.badge-expense { background: #fee2e2; color: #be123c; }
.badge-neutral { background: #e0e7ff; color: #4338ca; }
[data-theme="dark"] .badge-neutral { background: rgba(99,102,241,0.18); color: #a5b4fc; }

.list-recent { list-style: none; margin: 0; padding: 0; }
.list-recent li { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border-subtle); }
.list-recent li:last-child { border-bottom: none; }
.avatar-chip {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(135deg, var(--sun-amber), var(--sun-orange)); color: #fff; font-weight: 700; font-size: 0.85rem;
}
.chip-lead { background: linear-gradient(135deg, var(--sun-teal), #0891b2); font-size: 0.8rem; }
.lr-title { font-size: 0.85rem; font-weight: 600; }
.lr-sub { font-size: 0.72rem; color: var(--text-muted); }

/* ============ Login page ============ */
.login-page {
  min-height: 100vh; display: flex; align-items: stretch;
  background: var(--bg-canvas);
}
.login-visual {
  flex: 1.1; position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 30% 20%, #2a4a6f 0%, var(--sun-navy) 55%, #0f2338 100%);
  color: #fff; padding: 60px;
}
.login-visual::before {
  content: ''; position: absolute; inset: -20%;
  background: radial-gradient(circle at 70% 75%, rgba(245,166,35,0.28), transparent 45%);
}
.login-visual-content { position: relative; z-index: 1; max-width: 440px; }
.login-visual .brand-row { display: flex; align-items: center; gap: 14px; margin-bottom: 40px; }
.login-visual .brand-row img { width: 52px; height: 52px; border-radius: 14px; background: #fff; }
.login-visual h2 { font-family: var(--font-display); font-size: 1.9rem; font-weight: 700; line-height: 1.25; }
.login-visual p { color: #b9c8de; font-size: 0.95rem; line-height: 1.6; }
.login-feature-list { list-style: none; padding: 0; margin-top: 32px; }
.login-feature-list li { display: flex; gap: 12px; align-items: flex-start; margin-bottom: 16px; font-size: 0.88rem; color: #dbe4f0; }
.login-feature-list i { color: var(--sun-amber); margin-top: 3px; }

.login-form-side { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px; }
.login-form-card { width: 100%; max-width: 380px; }
.login-form-card h3 { font-family: var(--font-display); font-weight: 700; margin-bottom: 4px; }
.login-form-card .lead-sub { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 28px; }
.form-label { font-size: 0.82rem; font-weight: 600; color: var(--text-secondary); }
.form-control, .form-select {
  background: var(--bg-surface); border: 1px solid var(--border-subtle); color: var(--text-primary);
  border-radius: var(--radius-sm); padding: 10px 14px; font-size: 0.9rem;
}
.form-control:focus, .form-select:focus { border-color: var(--sun-orange); box-shadow: 0 0 0 3px rgba(249,115,22,0.15); }
.btn-brand {
  background: linear-gradient(90deg, var(--sun-orange), var(--sun-amber)); border: none; color: #1a1408;
  font-weight: 700; border-radius: var(--radius-sm); padding: 11px; font-size: 0.92rem;
  box-shadow: 0 6px 16px rgba(249,115,22,0.3);
}
.btn-brand:hover { filter: brightness(1.05); color: #1a1408; }
.demo-creds { background: var(--bg-surface-soft); border: 1px dashed var(--border-subtle); border-radius: var(--radius-sm); padding: 12px 14px; font-size: 0.76rem; color: var(--text-muted); margin-top: 22px; }
.demo-creds code { color: var(--sun-teal); }

/* ============ Toasts / spinner / modal ============ */
.toast-host { position: fixed; top: 20px; right: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.app-toast {
  display: flex; align-items: center; gap: 10px; background: var(--bg-surface); color: var(--text-primary);
  border: 1px solid var(--border-subtle); border-left: 4px solid var(--info);
  padding: 12px 16px; border-radius: var(--radius-sm); box-shadow: var(--shadow-elevated);
  font-size: 0.85rem; transform: translateX(20px); opacity: 0; transition: all 0.25s ease; min-width: 260px;
}
.app-toast.show { transform: translateX(0); opacity: 1; }
.app-toast-success { border-left-color: var(--success); }
.app-toast-danger { border-left-color: var(--danger); }
.app-toast-warning { border-left-color: var(--warning); }
.app-toast i { font-size: 1rem; }
.app-toast-success i { color: var(--success); }
.app-toast-danger i { color: var(--danger); }
.app-toast-warning i { color: var(--warning); }
.app-toast-info i { color: var(--info); }

.global-spinner {
  position: fixed; inset: 0; background: rgba(15, 22, 33, 0.35); backdrop-filter: blur(2px);
  display: flex; align-items: center; justify-content: center; z-index: 9998;
}
.spinner-box { background: var(--bg-surface); padding: 24px 32px; border-radius: var(--radius-md); text-align: center; box-shadow: var(--shadow-elevated); }
.spinner-label { margin-top: 10px; font-size: 0.82rem; color: var(--text-muted); }

/* ============ Placeholder / coming-soon module pages ============ */
.coming-soon { text-align: center; padding: 80px 20px; }
.coming-soon i { font-size: 2.6rem; color: var(--sun-orange); margin-bottom: 18px; }
.coming-soon h3 { font-family: var(--font-display); font-weight: 700; }
.coming-soon p { color: var(--text-muted); max-width: 480px; margin: 8px auto 0; }
.phase-badge { display: inline-block; margin-top: 16px; padding: 6px 16px; border-radius: 999px; background: var(--bg-surface-soft); border: 1px solid var(--border-subtle); font-size: 0.78rem; font-weight: 600; color: var(--sun-teal); }

/* ============ Responsive ============ */
@media (max-width: 991px) {
  .app-sidebar { position: fixed; left: -280px; height: 100vh; box-shadow: var(--shadow-elevated); }
  .app-sidebar.mobile-open { left: 0; }
  .global-search { width: 200px; }
  .app-content { padding: 16px; }
  .login-visual { display: none; }
}
@media (max-width: 576px) {
  .global-search { display: none; }
}
