/* ==========================================================
   FinVault — design tokens
   ========================================================== */
:root {
  --fv-font-en: 'Inter', system-ui, -apple-system, sans-serif;
  --fv-font-ml: 'Noto Sans Malayalam', 'Inter', system-ui, sans-serif;

  --fv-radius-sm: 8px;
  --fv-radius-md: 14px;
  --fv-radius-lg: 20px;
  --fv-shadow-sm: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
  --fv-shadow-md: 0 8px 24px rgba(15, 23, 42, 0.08);

  --fv-sidebar-width: 260px;
  --fv-topbar-height: 64px;

  /* Light mode palette */
  --fv-primary: #3949ab;
  --fv-primary-soft: #eef0fb;
  --fv-success: #1e8e5a;
  --fv-success-soft: #e8f6ef;
  --fv-warning: #b7791f;
  --fv-warning-soft: #fdf3e2;
  --fv-danger: #c53030;
  --fv-danger-soft: #fbeaea;

  --fv-bg: #f4f6fb;
  --fv-surface: #ffffff;
  --fv-border: #e5e8f0;
  --fv-text: #1a1f36;
  --fv-text-muted: #6b7280;
}

:root[data-theme="dark"] {
  --fv-primary: #7c8ef0;
  --fv-primary-soft: #262c48;
  --fv-success: #4ade91;
  --fv-success-soft: #16311f;
  --fv-warning: #f0b959;
  --fv-warning-soft: #3a2c12;
  --fv-danger: #f47171;
  --fv-danger-soft: #3a1c1c;

  --fv-bg: #0f1320;
  --fv-surface: #171c2e;
  --fv-border: #2a3049;
  --fv-text: #e7e9f3;
  --fv-text-muted: #9aa1b9;
}

* { box-sizing: border-box; }

html[lang="ml"] body { font-family: var(--fv-font-ml); }
body {
  font-family: var(--fv-font-en);
  background: var(--fv-bg);
  color: var(--fv-text);
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a { color: inherit; text-decoration: none; }

/* ==========================================================
   App shell
   ========================================================== */
.fv-app { display: flex; flex: 1; min-height: 0; }

.fv-sidebar {
  width: var(--fv-sidebar-width);
  flex-shrink: 0;
  background: var(--fv-surface);
  border-right: 1px solid var(--fv-border);
  position: sticky;
  top: 0;
  height: 100vh;
}
.fv-sidebar-inner, .fv-offcanvas .offcanvas-body {
  display: flex;
  flex-direction: column;
  height: 100%;
  padding: 20px 14px;
}
.fv-offcanvas { width: var(--fv-sidebar-width); background: var(--fv-surface); color: var(--fv-text); }

.fv-brand {
  display: flex; align-items: center; gap: 10px;
  font-weight: 700; font-size: 1.15rem;
  color: var(--fv-primary);
  padding: 6px 10px 22px;
}
.fv-brand i { font-size: 1.4rem; }

.fv-nav-group { display: flex; flex-direction: column; gap: 2px; }
.fv-nav-group--bottom { margin-top: auto; padding-top: 12px; border-top: 1px solid var(--fv-border); }

.fv-nav-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--fv-radius-sm);
  color: var(--fv-text-muted);
  font-size: 0.925rem;
  font-weight: 500;
}
.fv-nav-link i { width: 18px; text-align: center; }
.fv-nav-link:hover { background: var(--fv-primary-soft); color: var(--fv-primary); }
.fv-nav-link.active { background: var(--fv-primary-soft); color: var(--fv-primary); font-weight: 600; }

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

.fv-topbar {
  height: var(--fv-topbar-height);
  display: flex; align-items: center; gap: 10px;
  padding: 0 20px;
  background: var(--fv-surface);
  border-bottom: 1px solid var(--fv-border);
  position: sticky; top: 0; z-index: 10;
}
.fv-topbar-spacer { flex: 1; }

.fv-icon-btn {
  border: none; background: transparent; color: var(--fv-text-muted);
  width: 38px; height: 38px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 1.05rem;
}
.fv-icon-btn:hover { background: var(--fv-primary-soft); color: var(--fv-primary); }

.fv-lang-switch select, .fv-auth-lang select {
  border: 1px solid var(--fv-border); border-radius: var(--fv-radius-sm);
  background: var(--fv-surface); color: var(--fv-text);
  padding: 6px 10px; font-size: 0.875rem;
}

.fv-profile-menu { position: relative; }
.fv-profile-btn { width: auto; padding: 0 10px; border-radius: 999px; gap: 8px; }
.fv-profile-name { font-size: 0.875rem; font-weight: 600; }
.fv-profile-dropdown {
  display: none; position: absolute; right: 0; top: 46px;
  background: var(--fv-surface); border: 1px solid var(--fv-border);
  border-radius: var(--fv-radius-sm); box-shadow: var(--fv-shadow-md);
  min-width: 180px; overflow: hidden; z-index: 20;
}
.fv-profile-dropdown.show { display: block; }
.fv-profile-dropdown a { display: flex; gap: 10px; padding: 10px 14px; font-size: 0.9rem; }
.fv-profile-dropdown a:hover { background: var(--fv-primary-soft); color: var(--fv-primary); }

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

/* ==========================================================
   Page header / cards / panels
   ========================================================== */
.fv-page-header { margin-bottom: 20px; }
.fv-page-header h1 { font-size: 1.5rem; font-weight: 700; margin: 0 0 4px; }
.fv-page-subtitle { color: var(--fv-text-muted); margin: 0; font-size: 0.925rem; }

.fv-card-grid {
  display: grid; gap: 16px;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  margin-bottom: 24px;
}
.fv-summary-card {
  background: var(--fv-surface);
  border: 1px solid var(--fv-border);
  border-radius: var(--fv-radius-lg);
  box-shadow: var(--fv-shadow-sm);
  padding: 18px;
  display: flex; align-items: center; gap: 14px;
}
.fv-summary-icon {
  width: 46px; height: 46px; border-radius: var(--fv-radius-md);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.15rem; flex-shrink: 0;
}
.fv-tone-primary .fv-summary-icon { background: var(--fv-primary-soft); color: var(--fv-primary); }
.fv-tone-success .fv-summary-icon { background: var(--fv-success-soft); color: var(--fv-success); }
.fv-tone-warning .fv-summary-icon { background: var(--fv-warning-soft); color: var(--fv-warning); }
.fv-tone-danger  .fv-summary-icon { background: var(--fv-danger-soft);  color: var(--fv-danger); }

.fv-summary-label { font-size: 0.825rem; color: var(--fv-text-muted); margin-bottom: 2px; }
.fv-summary-value { font-size: 1.25rem; font-weight: 700; }

.fv-row-2col { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.fv-panel {
  background: var(--fv-surface); border: 1px solid var(--fv-border);
  border-radius: var(--fv-radius-lg); box-shadow: var(--fv-shadow-sm);
  padding: 20px;
}
.fv-panel h2 { font-size: 1.05rem; font-weight: 700; margin: 0 0 14px; }

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

/* ==========================================================
   Auth screen
   ========================================================== */
.fv-auth-screen {
  flex: 1; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--fv-bg);
}
.fv-auth-card {
  width: 100%; max-width: 400px;
  background: var(--fv-surface); border: 1px solid var(--fv-border);
  border-radius: var(--fv-radius-lg); box-shadow: var(--fv-shadow-md);
  padding: 32px 28px;
}
.fv-auth-brand {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  font-weight: 700; font-size: 1.3rem; color: var(--fv-primary); margin-bottom: 6px;
}
.fv-auth-tagline { text-align: center; color: var(--fv-text-muted); font-size: 0.875rem; margin-bottom: 24px; }
.fv-auth-lang { display: flex; justify-content: center; margin-top: 18px; }

.form-control, .form-select {
  background: var(--fv-bg); border: 1px solid var(--fv-border); color: var(--fv-text);
  border-radius: var(--fv-radius-sm);
}
.form-control:focus { border-color: var(--fv-primary); box-shadow: 0 0 0 0.2rem var(--fv-primary-soft); background: var(--fv-surface); color: var(--fv-text); }
.btn-primary { background: var(--fv-primary); border-color: var(--fv-primary); border-radius: var(--fv-radius-sm); }

/* ==========================================================
   Status badges (reusable — fv_status_badge() in helpers.php)
   ========================================================== */
.fv-badge {
  display: inline-flex; align-items: center;
  padding: 3px 11px; border-radius: 999px;
  font-size: 0.75rem; font-weight: 600; white-space: nowrap;
}
.fv-badge-success   { background: var(--fv-success-soft); color: var(--fv-success); }
.fv-badge-danger    { background: var(--fv-danger-soft);  color: var(--fv-danger); }
.fv-badge-warning   { background: var(--fv-warning-soft); color: var(--fv-warning); }
.fv-badge-primary   { background: var(--fv-primary-soft); color: var(--fv-primary); }
.fv-badge-secondary { background: var(--fv-border); color: var(--fv-text-muted); }

/* ==========================================================
   Toasts (reusable — components/toast.js)
   ========================================================== */
.toast.fv-toast-success { background: var(--fv-success); color: #fff; }
.toast.fv-toast-danger  { background: var(--fv-danger);  color: #fff; }
.toast.fv-toast-info    { background: var(--fv-primary); color: #fff; }
.toast.fv-toast-success .btn-close,
.toast.fv-toast-danger .btn-close,
.toast.fv-toast-info .btn-close { filter: brightness(0) invert(1); }

/* ==========================================================
   Reusable data table (components/data-table.js)
   ========================================================== */
.fv-table-toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.fv-table-toolbar .form-control { max-width: 280px; }
.fv-table thead th { font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.02em; color: var(--fv-text-muted); border-bottom: 1px solid var(--fv-border); white-space: nowrap; }
.fv-table thead th.fv-sort-asc::after  { content: " \2191"; }
.fv-table thead th.fv-sort-desc::after { content: " \2193"; }
.fv-table td { vertical-align: middle; }
.fv-table-pagination { margin-top: 12px; }
.fv-row-actions { display: flex; gap: 6px; justify-content: flex-end; }
.fv-row-actions .btn { padding: 4px 9px; }

/* Touch targets: Apple/Google guidelines recommend ~44x44px minimum for
   anything tapped with a finger. The compact 4px/9px padding above reads
   fine with a mouse but is too small to comfortably tap — this widens
   just the row-action icon buttons on narrow/touch viewports, where
   information density matters far less than not mis-tapping between two
   adjacent icons (e.g. Edit vs Delete). */
@media (max-width: 767.98px), (hover: none) and (pointer: coarse) {
  .fv-row-actions { gap: 10px; }
  .fv-row-actions .btn { min-width: 44px; min-height: 44px; padding: 8px 12px; display: inline-flex; align-items: center; justify-content: center; }
}

/* ==========================================================
   Modal forms
   ========================================================== */
.modal-content { background: var(--fv-surface); color: var(--fv-text); border: 1px solid var(--fv-border); border-radius: var(--fv-radius-lg); }
.modal-header, .modal-footer { border-color: var(--fv-border); }
.form-label { font-size: 0.85rem; font-weight: 600; color: var(--fv-text-muted); }
.form-check-label { font-size: 0.9rem; }

/* ==========================================================
   Insurance module
   ========================================================== */
.fv-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.fv-detail-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.fv-detail-header h1 { font-size: 1.35rem; font-weight: 700; margin: 0 0 4px; }
.fv-detail-meta { color: var(--fv-text-muted); font-size: 0.9rem; }
.fv-kv-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-bottom: 22px; }
.fv-kv-item .fv-kv-label { font-size: 0.78rem; color: var(--fv-text-muted); margin-bottom: 3px; }
.fv-kv-item .fv-kv-value { font-size: 1rem; font-weight: 600; }
.fv-nav-tabs { border-bottom: 1px solid var(--fv-border); margin-bottom: 20px; }
.fv-nav-tabs .nav-link { color: var(--fv-text-muted); border: none; border-bottom: 2px solid transparent; font-weight: 600; font-size: 0.9rem; }
.fv-nav-tabs .nav-link.active { color: var(--fv-primary); border-bottom-color: var(--fv-primary); background: transparent; }
.fv-nav-tabs .nav-link.disabled { color: var(--fv-text-muted); opacity: 0.5; }
.fv-action-list { display: flex; flex-direction: column; gap: 10px; }
.fv-action-item { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--fv-radius-sm); background: var(--fv-bg); font-size: 0.9rem; }
.fv-action-item i { width: 18px; }
.fv-action-item.fv-tone-danger i { color: var(--fv-danger); }
.fv-action-item.fv-tone-warning i { color: var(--fv-warning); }
.fv-action-item.fv-tone-info i { color: var(--fv-primary); }
.fv-event-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-radius: var(--fv-radius-sm); }
.fv-event-item:hover { background: var(--fv-bg); }
.fv-event-date { font-size: 0.78rem; color: var(--fv-text-muted); }

.fv-bell-btn { position: relative; text-decoration: none; }
.fv-bell-badge {
  position: absolute; top: 2px; right: 2px;
  background: var(--fv-danger); color: #fff;
  font-size: 0.62rem; font-weight: 700; line-height: 1;
  min-width: 16px; height: 16px; border-radius: 999px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px;
}

/* ==========================================================
   Notification Center
   ========================================================== */
.fv-notif-item { display: flex; gap: 12px; align-items: flex-start; padding: 14px; border-radius: var(--fv-radius-md); border: 1px solid var(--fv-border); margin-bottom: 10px; }
.fv-notif-item.fv-notif-unread { background: var(--fv-primary-soft); border-color: transparent; }
.fv-notif-icon { width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; background: var(--fv-bg); }
.fv-notif-body { flex: 1; min-width: 0; }
.fv-notif-meta { font-size: 0.78rem; color: var(--fv-text-muted); margin-top: 2px; }
.fv-notif-filters { display: flex; gap: 8px; margin-bottom: 16px; flex-wrap: wrap; }
.fv-notif-filters a { padding: 6px 14px; border-radius: 999px; font-size: 0.85rem; font-weight: 600; border: 1px solid var(--fv-border); color: var(--fv-text-muted); }
.fv-notif-filters a.active { background: var(--fv-primary); border-color: var(--fv-primary); color: #fff; }

/* ==========================================================
   Calendar
   ========================================================== */
.fv-calendar-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.fv-calendar-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.fv-calendar-dow { text-align: center; font-size: 0.75rem; font-weight: 700; color: var(--fv-text-muted); text-transform: uppercase; padding-bottom: 6px; }
.fv-calendar-cell {
  min-height: 96px; border: 1px solid var(--fv-border); border-radius: var(--fv-radius-sm);
  padding: 6px; background: var(--fv-surface); display: flex; flex-direction: column; gap: 4px;
}
.fv-calendar-cell.fv-outside-month { background: var(--fv-bg); opacity: 0.5; }
.fv-calendar-cell.fv-today { border-color: var(--fv-primary); border-width: 2px; }
.fv-calendar-daynum { font-size: 0.8rem; font-weight: 700; }
.fv-calendar-event {
  font-size: 0.7rem; padding: 2px 6px; border-radius: 6px; background: var(--fv-primary-soft); color: var(--fv-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer;
}
.fv-calendar-event.fv-tone-danger { background: var(--fv-danger-soft); color: var(--fv-danger); }
.fv-calendar-list-item { display: flex; justify-content: space-between; align-items: center; padding: 10px 12px; border-bottom: 1px solid var(--fv-border); }
@media (max-width: 767.98px) {
  .fv-calendar-grid { grid-template-columns: 1fr; }
  .fv-calendar-dow { display: none; }
  .fv-calendar-cell { min-height: auto; }
  .fv-calendar-cell.fv-outside-month { display: none; }
}

@media (max-width: 991.98px) {
  .fv-content { padding: 16px; }
}

/* ---- Print styles (Report Center) ---- */
.fv-no-print { }
@media print {
  .fv-sidebar, .fv-offcanvas, .fv-topbar, .fv-no-print, .fv-app > .fv-main > .fv-topbar { display: none !important; }
  .fv-app, .fv-main, .fv-content { display: block !important; margin: 0 !important; padding: 0 !important; width: 100% !important; }
  .fv-print-panel { box-shadow: none !important; border: none !important; padding: 0 !important; }
  body { background: #fff !important; color: #000 !important; }
  .fv-table { font-size: 12px; }
  a[href]::after { content: none !important; }
  .fv-report-networth-row th { border-top: 2px solid #000; font-size: 1.1em; }
  .fv-app-footer { display: none !important; }
}

/* ---- App-wide copyright footer (appears on every page, including login) ---- */
.fv-app-footer {
  flex-shrink: 0;
  text-align: center;
  padding: 14px 16px;
  font-size: 0.8rem;
  color: var(--fv-text-muted);
  border-top: 1px solid var(--fv-border);
}
.fv-app-footer a {
  color: var(--fv-text-muted);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.fv-app-footer a:hover { color: var(--fv-primary); }

/* ---- Viewer mode: normal ("user"-role) accounts can see everything but
   never mutate it. Server-side already rejects these requests outright
   (Api::requireAdmin()) — this is the matching visual treatment so a
   locked action looks locked rather than clickable-but-silently-failing. ---- */
.fv-viewer-mode .fv-admin-action {
  opacity: 0.45;
  pointer-events: none;
  cursor: not-allowed;
  position: relative;
}
.fv-viewer-mode .fv-admin-action::after {
  content: "\f023"; /* fa-lock */
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  position: absolute;
  top: -6px;
  right: -6px;
  font-size: 0.65rem;
  background: var(--fv-text-muted);
  color: var(--fv-surface);
  border-radius: 50%;
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fv-viewer-mode .fv-nav-item.fv-admin-action::after { top: 8px; right: 8px; }
