/* ================================================================
   ICA Accounting System — Main Stylesheet
   Font: Plus Jakarta Sans | Theme: Deep Navy + Emerald
================================================================ */

:root {
  --primary:        #1a3a5c;
  --primary-light:  #2563a8;
  --accent:         #10b981;
  --accent-dark:    #059669;
  --danger:         #ef4444;
  --warning:        #f59e0b;
  --info:           #3b82f6;
  --sidebar-w:      260px;
  --topbar-h:       64px;
  --bg:             #f0f4f8;
  --surface:        #ffffff;
  --border:         #e2e8f0;
  --text:           #1e293b;
  --text-muted:     #64748b;
  --text-light:     #94a3b8;
  --shadow-sm:      0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.05);
  --shadow:         0 4px 12px rgba(0,0,0,.08);
  --shadow-lg:      0 10px 32px rgba(0,0,0,.12);
  --radius:         12px;
  --radius-sm:      8px;
  --sidebar-bg:     #0f2340;
  --sidebar-text:   #94a3b8;
  --sidebar-active: #10b981;
  --transition:     .2s ease;
}

* { box-sizing: border-box; }

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  margin: 0;
  font-size: 14px;
  line-height: 1.6;
}

/* ── SIDEBAR ─────────────────────────────────────────────────── */
.sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  z-index: 1000;
  transition: transform var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 20px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.brand-icon {
  width: 40px; height: 40px;
  background: var(--accent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-size: 18px;
  flex-shrink: 0;
}

.brand-name { color: #fff; font-weight: 800; font-size: 16px; line-height: 1; }
.brand-sub  { color: var(--sidebar-text); font-size: 11px; letter-spacing: .5px; }

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  margin: 12px;
  background: rgba(255,255,255,.04);
  border-radius: var(--radius-sm);
}

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

.user-name  { color: #fff; font-weight: 600; font-size: 13px; line-height: 1.2; }
.user-role  { color: var(--sidebar-text); font-size: 11px; }

.sidebar-nav { list-style: none; margin: 0; padding: 8px 0; flex: 1; }

.nav-section {
  padding: 12px 20px 4px;
  color: rgba(148,163,184,.5);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
  text-transform: uppercase;
}

.nav-item { padding: 2px 12px; }

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13.5px;
  font-weight: 500;
  transition: all var(--transition);
}

.nav-link i { font-size: 16px; flex-shrink: 0; }
.nav-link:hover { background: rgba(255,255,255,.06); color: #fff; }
.nav-link.active { background: rgba(16,185,129,.15); color: var(--accent); }
.nav-link.active i { color: var(--accent); }

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,.06);
}

.btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: 13px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.btn-logout:hover { color: var(--danger); background: rgba(239,68,68,.1); }

/* ── MAIN WRAPPER ───────────────────────────────────────────── */
.main-wrapper {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin var(--transition);
}

/* ── TOPBAR ─────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 100;
  box-shadow: var(--shadow-sm);
}

.sidebar-toggle {
  background: none; border: none;
  font-size: 20px; color: var(--text-muted);
  cursor: pointer; padding: 4px;
  display: none;
}

.topbar-title { flex: 1; }
.topbar-title h1 {
  font-size: 18px; font-weight: 700;
  color: var(--text); margin: 0; line-height: 1.2;
}

.topbar-actions { display: flex; align-items: center; gap: 12px; }

.fy-badge {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 12px;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
}

.user-btn {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 20px; padding: 4px 14px 4px 4px;
  font-size: 13px; font-weight: 600; color: var(--text);
  cursor: pointer;
}
.user-btn::after { display: none; }
.user-avatar-sm {
  width: 28px; height: 28px;
  background: var(--primary);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 700;
}

/* ── PAGE CONTENT ───────────────────────────────────────────── */
.page-content { padding: 24px; flex: 1; }

/* ── CARDS ──────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: transparent;
  display: flex; align-items: center; justify-content: space-between;
}

.card-title { font-size: 15px; font-weight: 700; margin: 0; }
.card-body  { padding: 20px; }

/* ── KPI CARDS ──────────────────────────────────────────────── */
.kpi-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  position: relative;
  overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.kpi-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }

.kpi-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--kpi-color, var(--accent));
}

.kpi-icon {
  width: 44px; height: 44px;
  background: color-mix(in srgb, var(--kpi-color, var(--accent)) 12%, transparent);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  color: var(--kpi-color, var(--accent));
  margin-bottom: 12px;
}

.kpi-value {
  font-size: 26px; font-weight: 800; color: var(--text);
  line-height: 1; margin-bottom: 4px;
  font-variant-numeric: tabular-nums;
}

.kpi-label { font-size: 12px; color: var(--text-muted); font-weight: 500; }

.kpi-trend {
  position: absolute; top: 16px; right: 16px;
  font-size: 11px; font-weight: 700;
  padding: 2px 8px; border-radius: 20px;
}
.kpi-trend.up   { background: rgba(16,185,129,.12); color: var(--accent); }
.kpi-trend.down { background: rgba(239,68,68,.12); color: var(--danger); }

/* ── TABLES ─────────────────────────────────────────────────── */
.table { font-size: 13.5px; }
.table thead th {
  font-weight: 700; font-size: 11px; text-transform: uppercase;
  letter-spacing: .6px; color: var(--text-muted);
  border-bottom: 2px solid var(--border);
  background: var(--bg);
  padding: 10px 12px;
  white-space: nowrap;
}
.table td { padding: 10px 12px; vertical-align: middle; }
.table tbody tr { transition: background var(--transition); }
.table tbody tr:hover { background: rgba(16,185,129,.03); }

/* ── BADGES ─────────────────────────────────────────────────── */
.badge-income  { background: rgba(16,185,129,.12); color: #059669; }
.badge-expense { background: rgba(239,68,68,.12);  color: #dc2626; }
.badge-posted  { background: rgba(59,130,246,.12); color: #2563eb; }
.badge-draft   { background: rgba(245,158,11,.12); color: #d97706; }
.badge-void    { background: rgba(100,116,139,.12); color: #475569; }

/* ── FORMS ──────────────────────────────────────────────────── */
.form-label { font-weight: 600; font-size: 12.5px; color: var(--text); margin-bottom: 4px; }
.form-control, .form-select {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 13.5px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-control:focus, .form-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(16,185,129,.1);
}

/* ── BUTTONS ─────────────────────────────────────────────────── */
.btn { font-weight: 600; border-radius: var(--radius-sm); font-size: 13.5px; }
.btn-primary { background: var(--primary); border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-light); border-color: var(--primary-light); }
.btn-success { background: var(--accent); border-color: var(--accent); }
.btn-success:hover { background: var(--accent-dark); border-color: var(--accent-dark); }

/* ── AMOUNT COLORS ──────────────────────────────────────────── */
.amount-income  { color: #059669; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.amount-expense { color: #dc2626; font-weight: 700; font-family: 'JetBrains Mono', monospace; }
.amount-neutral { color: var(--text); font-weight: 600; font-family: 'JetBrains Mono', monospace; }

/* ── CHARTS ─────────────────────────────────────────────────── */
.chart-container { position: relative; }

/* ── PAGINATION ─────────────────────────────────────────────── */
.page-link { color: var(--primary); border-radius: 6px; margin: 0 2px; }
.page-item.active .page-link { background: var(--primary); border-color: var(--primary); }

/* ── FILTER BAR ─────────────────────────────────────────────── */
.filter-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 20px;
}

/* ── BREADCRUMB ─────────────────────────────────────────────── */
.breadcrumb { font-size: 12px; }
.breadcrumb-item a { color: var(--accent); text-decoration: none; }

/* ── STAT TABLE ─────────────────────────────────────────────── */
.stat-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); }
.stat-row:last-child { border: none; }
.stat-label { color: var(--text-muted); font-size: 12.5px; }
.stat-value { font-weight: 700; font-size: 13px; }

/* ── LOGIN PAGE ─────────────────────────────────────────────── */
.login-wrapper {
  min-height: 100vh;
  background: var(--sidebar-bg);
  display: flex; align-items: center; justify-content: center;
}

.login-card {
  background: var(--surface);
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  width: 56px; height: 56px;
  background: var(--accent);
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; color: #fff;
  margin: 0 auto 20px;
}

/* ── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 20px rgba(0,0,0,.3);
  }
  .main-wrapper { margin-left: 0; }
  .sidebar-toggle { display: flex; }
  .page-content { padding: 16px; }
  .kpi-value { font-size: 20px; }
}

/* ── SELECT2 OVERRIDES ──────────────────────────────────────── */
.select2-container--default .select2-selection--single {
  height: 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
}
.select2-container--default .select2-selection--single .select2-selection__rendered {
  line-height: 36px;
  padding-left: 10px;
}
.select2-container--default .select2-selection--single .select2-selection__arrow {
  height: 36px;
}

/* ── AUDIT LOG ──────────────────────────────────────────────── */
.audit-action {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}
.audit-create  { background: rgba(16,185,129,.12); color: #059669; }
.audit-update  { background: rgba(59,130,246,.12); color: #2563eb; }
.audit-delete  { background: rgba(239,68,68,.12);  color: #dc2626; }
.audit-login   { background: rgba(139,92,246,.12); color: #7c3aed; }
.audit-logout  { background: rgba(100,116,139,.12);color: #475569; }
.audit-void    { background: rgba(245,158,11,.12); color: #d97706; }

/* ── MISC ───────────────────────────────────────────────────── */
.section-title {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 48px; margin-bottom: 12px; opacity: .3; }
.empty-state h5 { font-size: 16px; font-weight: 700; margin-bottom: 4px; }

.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 999;
}
.sidebar-overlay.show { display: block; }
