/* ============================================================
   APLIKASI KEUANGAN AI - DASHBOARD STYLES
   Dark Mode by default, Light Mode toggle
   ============================================================ */

/* ── DESIGN TOKENS ────────────────────────────────────────── */
:root {
  --bg-primary:    #0a0e1a;
  --bg-secondary:  #0f1628;
  --bg-card:       #131d35;
  --bg-card-hover: #1a2644;
  --border:        rgba(99, 140, 255, 0.15);
  --border-glow:   rgba(99, 140, 255, 0.35);

  --accent-blue:   #638cff;
  --accent-purple: #a855f7;
  --accent-green:  #10b981;
  --accent-amber:  #f59e0b;
  --accent-red:    #ef4444;
  --accent-cyan:   #06b6d4;

  --text-primary:  #e8eaf6;
  --text-secondary:#8b95b0;
  --text-muted:    #4a5568;

  --gradient-main: linear-gradient(135deg, #638cff 0%, #a855f7 100%);
  --gradient-danger: linear-gradient(135deg, #ef4444 0%, #f59e0b 100%);
  --gradient-green: linear-gradient(135deg, #10b981 0%, #06b6d4 100%);

  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;

  --shadow-card: 0 4px 24px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 30px rgba(99, 140, 255, 0.15);

  --font: 'Inter', -apple-system, sans-serif;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── LIGHT MODE ───────────────────────────────────────────── */
[data-theme="light"] {
  --bg-primary:    #f0f4ff;
  --bg-secondary:  #e8edf8;
  --bg-card:       #ffffff;
  --bg-card-hover: #f5f7ff;
  --border:        rgba(99, 140, 255, 0.2);
  --border-glow:   rgba(99, 140, 255, 0.4);
  --text-primary:  #1a1f36;
  --text-secondary:#4a5568;
  --text-muted:    #9ba3b2;
  --shadow-card:   0 4px 24px rgba(99, 140, 255, 0.1);
  --shadow-glow:   0 0 30px rgba(99, 140, 255, 0.1);
}

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

html { scroll-behavior: smooth; }

body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
  overflow-x: hidden;
}

/* Mesh gradient background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 20% 10%, rgba(99, 140, 255, 0.07) 0%, transparent 60%),
    radial-gradient(ellipse 60% 50% at 80% 80%, rgba(168, 85, 247, 0.06) 0%, transparent 60%);
  pointer-events: none;
  z-index: 0;
}

/* ── NAVBAR ───────────────────────────────────────────────── */
.navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  background: rgba(10, 14, 26, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
}

[data-theme="light"] .navbar {
  background: rgba(240, 244, 255, 0.88);
}

.navbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand-icon {
  font-size: 24px;
  filter: drop-shadow(0 0 8px rgba(99,140,255,0.6));
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.3px;
}

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

/* ── BUTTONS ──────────────────────────────────────────────── */
.btn-ghost {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font);
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}

.btn-ghost:hover {
  background: var(--bg-card);
  border-color: var(--accent-blue);
  color: var(--accent-blue);
  box-shadow: 0 0 12px rgba(99, 140, 255, 0.2);
}

/* ── CONTAINER ────────────────────────────────────────────── */
.container {
  max-width: 1300px;
  margin: 0 auto;
  padding: 28px 20px 60px;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 28px;
}

/* ── SECTION HEADER ───────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

/* ── BADGES ───────────────────────────────────────────────── */
.badge-danger {
  padding: 4px 12px;
  background: rgba(239, 68, 68, 0.15);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: 999px;
  font-size: 12px;
  color: var(--accent-red);
  font-weight: 600;
}

.badge-neutral {
  padding: 4px 12px;
  background: rgba(139, 149, 176, 0.1);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 11px;
  color: var(--text-muted);
}

/* ── CARDS ────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: all var(--transition);
}

.card:hover {
  border-color: var(--border-glow);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
}

.card-glow {
  box-shadow: var(--shadow-card);
}

/* Primary card with gradient border */
.card-primary {
  position: relative;
  background: linear-gradient(135deg, rgba(99,140,255,0.1) 0%, rgba(168,85,247,0.08) 100%);
  border-color: rgba(99, 140, 255, 0.3);
}

.card-primary::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: var(--radius-lg);
  padding: 1px;
  background: var(--gradient-main);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.card-danger {
  background: linear-gradient(135deg, rgba(239,68,68,0.08) 0%, rgba(245,158,11,0.06) 100%);
  border-color: rgba(239, 68, 68, 0.25);
}

.card-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
}

.card-value {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -1px;
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}

.card-danger .card-value {
  background: var(--gradient-danger);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.card-sub {
  font-size: 12px;
  color: var(--text-muted);
}

/* ── HERO GRID ────────────────────────────────────────────── */
.hero-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

/* ── PROGRESS BAR ─────────────────────────────────────────── */
.progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: rgba(255,255,255,0.06);
  border-radius: 999px;
  margin: 12px 0 6px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: var(--gradient-main);
  transition: width 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.progress-bar.danger { background: var(--gradient-danger); }

/* ── EXPENSIVE ALERT ──────────────────────────────────────── */
.alert-section {}

.expensive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.expensive-card {
  background: linear-gradient(135deg, rgba(239,68,68,0.12) 0%, rgba(245,158,11,0.08) 100%);
  border: 1px solid rgba(239, 68, 68, 0.3);
  border-radius: var(--radius-md);
  padding: 16px;
  animation: slideIn 0.3s ease;
  transition: all var(--transition);
}

.expensive-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(239, 68, 68, 0.2);
}

.expensive-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.expensive-card-amount {
  font-size: 20px;
  font-weight: 800;
  background: var(--gradient-danger);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 6px;
}

.expensive-card-reason {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.5;
}

.expensive-card-date {
  font-size: 10px;
  color: var(--accent-amber);
  margin-top: 8px;
  font-weight: 500;
}

/* ── EMPTY STATE ──────────────────────────────────────────── */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 40px;
  margin-bottom: 10px;
  filter: grayscale(0.3);
}

/* ── CHARTS ───────────────────────────────────────────────── */
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.chart-card { padding: 24px; }

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

.chart-header h3 {
  font-size: 14px;
  font-weight: 600;
}

.chart-period {
  font-size: 11px;
  color: var(--text-muted);
}

.chart-wrap {
  position: relative;
  height: 220px;
}

/* ── DATA TABLE ───────────────────────────────────────────── */
.table-section {}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

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

.data-table thead {
  background: rgba(99, 140, 255, 0.06);
}

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

.data-table td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(99, 140, 255, 0.06);
  color: var(--text-primary);
  transition: background var(--transition);
}

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

.data-table tbody tr:hover td {
  background: var(--bg-card-hover);
}

.data-table tbody tr { animation: fadeRow 0.3s ease forwards; opacity: 0; }

.tag-category {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(99, 140, 255, 0.12);
  color: var(--accent-blue);
  border: 1px solid rgba(99, 140, 255, 0.2);
}

.tag-expensive {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  background: rgba(239, 68, 68, 0.12);
  color: var(--accent-red);
  border: 1px solid rgba(239, 68, 68, 0.25);
}

.tag-normal {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: rgba(16, 185, 129, 0.1);
  color: var(--accent-green);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.amount-cell {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* ── LOADING ──────────────────────────────────────────────── */
.loading-row {
  text-align: center;
  padding: 32px !important;
  color: var(--text-muted);
}

.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent-blue);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 8px;
}

/* ── TOAST ────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  padding: 12px 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 999;
  max-width: 300px;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* ── SPARKLINE ────────────────────────────────────────────── */
.card-sparkline { margin-top: 16px; opacity: 0.7; }

/* ── ANIMATIONS ───────────────────────────────────────────── */
@keyframes spin {
  to { transform: rotate(360deg); }
}

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

@keyframes fadeRow {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── LOGIN PAGE ───────────────────────────────────────────── */
.login-container {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  z-index: 1;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
  box-shadow: var(--shadow-card), var(--shadow-glow);
}

.login-brand {
  text-align: center;
  margin-bottom: 32px;
}

.login-logo {
  font-size: 56px;
  margin-bottom: 12px;
  filter: drop-shadow(0 4px 16px rgba(99,140,255,0.4));
}

.login-title {
  background: var(--gradient-main);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 4px;
}

.login-subtitle {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-group label {
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.form-group input {
  width: 100%;
  padding: 14px 16px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  transition: var(--transition);
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(99,140,255,0.15);
}

.login-btn {
  width: 100%;
  padding: 14px;
  background: var(--gradient-main);
  border: none;
  border-radius: var(--radius-sm);
  color: white;
  font-family: var(--font);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.login-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 24px rgba(99,140,255,0.35);
}

.login-btn:disabled {
  opacity: 0.7;
  cursor: not-allowed;
}

.login-error {
  text-align: center;
  font-size: 13px;
  color: var(--accent-red);
  min-height: 20px;
  font-weight: 500;
}

.login-footer {
  margin-top: 24px;
  text-align: center;
  font-size: 11px;
  color: var(--text-muted);
}

/* ── VIEW TABS ───────────────────────────────────────────── */
.view-tabs {
  display: flex;
  gap: 8px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 6px;
  margin-bottom: 24px;
  overflow-x: auto;
}

.view-tab {
  flex: 1;
  min-width: max-content;
  padding: 10px 18px;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  white-space: nowrap;
}

.view-tab:hover { color: var(--text-primary); }

.view-tab.active {
  background: var(--gradient-main);
  color: white;
  box-shadow: 0 4px 12px rgba(99,140,255,0.3);
}

.btn-logout {
  padding: 8px 14px;
  background: rgba(239,68,68,0.12);
  border: 1px solid rgba(239,68,68,0.25);
  border-radius: var(--radius-sm);
  color: var(--accent-red);
  font-family: var(--font);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
}

.btn-logout:hover {
  background: rgba(239,68,68,0.2);
  border-color: rgba(239,68,68,0.4);
}

/* ── INCOME / EXPENSE CARD VARIANTS ──────────────────────── */
.card-income {
  border-color: rgba(16, 185, 129, 0.3);
}

.card-income::before {
  background: var(--gradient-green) !important;
}

.card-saldo-positive {
  border-color: rgba(16, 185, 129, 0.3);
}

.card-saldo-negative {
  border-color: rgba(239, 68, 68, 0.4);
}

/* ── RESPONSIVE ───────────────────────────────────────────── */
@media (max-width: 1024px) {
  .hero-grid { grid-template-columns: repeat(2, 1fr); }
  .charts-grid { grid-template-columns: 1fr; }
}

@media (max-width: 540px) {
  .hero-grid { grid-template-columns: 1fr; }
  .login-card { padding: 32px 24px; }
}

@media (max-width: 640px) {
  .navbar { padding: 12px 16px; }
  .container { padding: 16px 12px 48px; gap: 20px; }
  .hero-grid { grid-template-columns: 1fr; }
  .card-value { font-size: 22px; }
  .expensive-grid { grid-template-columns: 1fr; }
}
