/* ============================================================
   KasRumah - Stylesheet Utama
   Font: Plus Jakarta Sans
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;600&display=swap');

/* ── Variables ── */
:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --primary-light: #e0e7ff;
  --success: #10b981;
  --success-light: #d1fae5;
  --danger: #ef4444;
  --danger-light: #fee2e2;
  --warning: #f59e0b;
  --warning-light: #fef3c7;
  --info: #3b82f6;
  --info-light: #dbeafe;

  --bg: #f1f5f9;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --bg-sidebar-hover: rgba(255,255,255,0.08);
  --bg-sidebar-active: rgba(99,102,241,0.25);

  --text: #1e293b;
  --text-muted: #64748b;
  --text-sidebar: #cbd5e1;
  --text-sidebar-active: #ffffff;

  --border: #e2e8f0;
  --border-radius: 16px;
  --border-radius-sm: 10px;
  --border-radius-lg: 20px;

  --sidebar-width: 260px;
  --topbar-height: 68px;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
  --shadow-lg: 0 10px 40px rgba(0,0,0,0.12);

  --transition: 0.2s ease;
}

[data-theme="dark"] {
  --bg: #0f172a;
  --bg-card: #1e293b;
  --bg-sidebar: #020617;
  --text: #f1f5f9;
  --text-muted: #94a3b8;
  --border: #334155;
  --shadow: 0 4px 20px rgba(0,0,0,0.3);
}

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

body {
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; }

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-width);
  min-height: 100vh;
  background: var(--bg-sidebar);
  display: flex;
  flex-direction: column;
  position: fixed;
  left: 0; top: 0;
  z-index: 200;
  transition: transform var(--transition), width var(--transition);
  overflow-y: auto;
  overflow-x: hidden;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-icon {
  width: 38px; height: 38px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 16px;
  flex-shrink: 0;
}
.brand-text { display: flex; flex-direction: column; }
.brand-name { font-size: 16px; font-weight: 800; color: #fff; }
.brand-sub { font-size: 11px; color: var(--text-sidebar); opacity: 0.7; }

.sidebar-toggle {
  background: none; border: none;
  color: var(--text-sidebar); font-size: 18px;
  padding: 6px; border-radius: 8px;
  transition: background var(--transition);
  display: none;
}
.sidebar-toggle:hover { background: var(--bg-sidebar-hover); }

.sidebar-nav { flex: 1; padding: 12px 0; }
.nav-section { padding: 8px 0; }
.nav-label {
  font-size: 10px; font-weight: 700;
  color: rgba(203,213,225,0.4);
  letter-spacing: 1.5px;
  padding: 8px 20px 4px;
  display: block;
}

.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 20px;
  color: var(--text-sidebar);
  border-radius: 0;
  transition: all var(--transition);
  font-size: 14px; font-weight: 500;
  position: relative;
  margin: 1px 8px;
  border-radius: 10px;
}
.nav-item i { width: 18px; text-align: center; font-size: 15px; flex-shrink: 0; }
.nav-item:hover { background: var(--bg-sidebar-hover); color: #fff; }
.nav-item.active {
  background: var(--bg-sidebar-active);
  color: #fff;
  font-weight: 600;
}
.nav-item.active::before {
  content: '';
  position: absolute; left: -8px;
  width: 3px; height: 60%;
  background: var(--primary);
  border-radius: 0 3px 3px 0;
}
.nav-logout { color: #f87171 !important; }
.nav-logout:hover { background: rgba(239,68,68,0.15) !important; }

.sidebar-user {
  display: flex; align-items: center; gap: 10px;
  padding: 16px;
  border-top: 1px solid rgba(255,255,255,0.05);
  margin-top: auto;
}
.user-avatar {
  width: 36px; height: 36px;
  background: var(--primary);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 13px; font-weight: 700;
  flex-shrink: 0;
}
.user-info { display: flex; flex-direction: column; overflow: hidden; }
.user-name { font-size: 13px; font-weight: 600; color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 11px; color: rgba(203,213,225,0.5); }

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

/* ── Topbar ── */
.topbar {
  height: var(--topbar-height);
  background: var(--bg-card);
  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);
}
.topbar-toggle { display: none; background: none; border: none; color: var(--text-muted); font-size: 20px; }
.topbar-title { font-size: 18px; font-weight: 700; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 12px; }
.topbar-date { font-size: 13px; color: var(--text-muted); display: flex; align-items: center; gap: 6px; }

.btn-theme {
  background: var(--bg); border: 1px solid var(--border);
  color: var(--text-muted); width: 36px; height: 36px;
  border-radius: 10px; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.btn-theme:hover { background: var(--primary); color: #fff; border-color: var(--primary); }

.btn-add {
  display: flex; align-items: center; gap: 8px;
  background: var(--primary); color: #fff;
  padding: 8px 16px; border-radius: 10px;
  font-size: 14px; font-weight: 600;
  transition: all var(--transition);
}
.btn-add:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.4); }

/* ── Content Area ── */
.content-area { padding: 24px; flex: 1; }

/* ── Cards ── */
.card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.card-body { padding: 20px; }

/* ── Stat Cards ── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 16px; margin-bottom: 24px; }

.stat-card {
  background: var(--bg-card);
  border-radius: var(--border-radius);
  border: 1px solid var(--border);
  padding: 20px;
  display: flex; align-items: center; gap: 16px;
  position: relative; overflow: hidden;
  transition: transform var(--transition), box-shadow var(--transition);
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.stat-card::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0;
  height: 3px;
}
.stat-card.green::before { background: var(--success); }
.stat-card.red::before { background: var(--danger); }
.stat-card.blue::before { background: var(--info); }
.stat-card.purple::before { background: var(--primary); }

.stat-icon {
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px; flex-shrink: 0;
}
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }
.stat-icon.blue { background: var(--info-light); color: var(--info); }
.stat-icon.purple { background: var(--primary-light); color: var(--primary); }

.stat-info { flex: 1; min-width: 0; }
.stat-label { font-size: 12px; color: var(--text-muted); font-weight: 500; margin-bottom: 4px; }
.stat-value { font-size: 20px; font-weight: 800; font-family: 'JetBrains Mono', monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stat-sub { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── Grid Layouts ── */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 20px; }
.grid-col-7-5 { display: grid; grid-template-columns: 7fr 5fr; gap: 20px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--text-muted);
  padding: 10px 16px; text-align: left;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
td {
  padding: 13px 16px; font-size: 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--bg); }

/* ── Badges ── */
.badge {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 4px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 600;
}
.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-info { background: var(--info-light); color: var(--info); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-purple { background: var(--primary-light); color: var(--primary); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 9px 18px; border-radius: 10px;
  font-size: 14px; font-weight: 600; border: none;
  cursor: pointer; transition: all var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(99,102,241,0.4); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { filter: brightness(0.9); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { filter: brightness(0.9); }
.btn-warning { background: var(--warning); color: #fff; }
.btn-outline {
  background: transparent; border: 1.5px solid var(--border);
  color: var(--text-muted);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon { padding: 8px; aspect-ratio: 1; }

/* ── Forms ── */
.form-group { margin-bottom: 18px; }
.form-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-control {
  width: 100%; padding: 10px 14px;
  background: var(--bg); border: 1.5px solid var(--border);
  border-radius: 10px; font-size: 14px; color: var(--text);
  transition: border-color var(--transition), box-shadow var(--transition);
  outline: none;
}
.form-control:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(99,102,241,0.1); }
.form-control::placeholder { color: var(--text-muted); }
select.form-control { appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 14px center; padding-right: 36px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

/* ── Alerts ── */
.alert {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 18px; border-radius: 12px;
  font-size: 14px; font-weight: 500;
  margin-bottom: 20px; position: relative;
}
.alert-success { background: var(--success-light); color: #065f46; border-left: 4px solid var(--success); }
.alert-danger { background: var(--danger-light); color: #991b1b; border-left: 4px solid var(--danger); }
.alert-warning { background: var(--warning-light); color: #92400e; border-left: 4px solid var(--warning); }
.alert-info { background: var(--info-light); color: #1e40af; border-left: 4px solid var(--info); }
.alert-close { background: none; border: none; color: inherit; opacity: 0.5; font-size: 14px; margin-left: auto; padding: 0; }
.alert-close:hover { opacity: 1; }

/* ── Progress Bar ── */
.progress { background: var(--bg); border-radius: 20px; height: 8px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 20px; transition: width 0.6s ease; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 500; display: none;
  align-items: center; justify-content: center;
  padding: 20px;
}
.modal-overlay.show { display: flex; }
.modal {
  background: var(--bg-card);
  border-radius: var(--border-radius-lg);
  width: 100%; max-width: 520px;
  box-shadow: var(--shadow-lg);
  animation: modalIn 0.2s ease;
  max-height: 90vh; overflow-y: auto;
}
@keyframes modalIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.97); }
  to { opacity: 1; transform: none; }
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px; border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 17px; font-weight: 700; }
.modal-close { background: none; border: none; color: var(--text-muted); font-size: 20px; width: 32px; height: 32px; border-radius: 8px; display: flex; align-items: center; justify-content: center; }
.modal-close:hover { background: var(--bg); color: var(--text); }
.modal-body { padding: 24px; }
.modal-footer { display: flex; justify-content: flex-end; gap: 10px; padding: 16px 24px; border-top: 1px solid var(--border); }

/* ── Rekening Cards ── */
.rekening-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.rekening-card {
  border-radius: var(--border-radius);
  padding: 20px;
  color: #fff;
  position: relative; overflow: hidden;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}
.rekening-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); }
.rekening-card::after {
  content: ''; position: absolute;
  width: 120px; height: 120px;
  background: rgba(255,255,255,0.1);
  border-radius: 50%;
  top: -40px; right: -40px;
}
.rekening-card-icon { font-size: 28px; margin-bottom: 16px; opacity: 0.9; }
.rekening-card-name { font-size: 13px; font-weight: 500; opacity: 0.85; margin-bottom: 6px; }
.rekening-card-saldo { font-size: 22px; font-weight: 800; font-family: 'JetBrains Mono', monospace; }
.rekening-card-jenis { font-size: 11px; opacity: 0.7; margin-top: 8px; text-transform: uppercase; letter-spacing: 1px; }

/* ── Category Item ── */
.category-item {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 0; border-bottom: 1px solid var(--border);
}
.category-item:last-child { border-bottom: none; }
.cat-icon { width: 36px; height: 36px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 15px; flex-shrink: 0; }
.cat-name { flex: 1; font-size: 14px; font-weight: 500; }
.cat-amount { font-size: 14px; font-weight: 700; font-family: 'JetBrains Mono', monospace; }

/* ── Budget Progress ── */
.budget-item { padding: 14px 0; border-bottom: 1px solid var(--border); }
.budget-item:last-child { border-bottom: none; }
.budget-item-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.budget-pct { font-size: 12px; font-weight: 600; }
.budget-pct.over { color: var(--danger); }

/* ── Empty State ── */
.empty-state {
  text-align: center; padding: 60px 20px;
  color: var(--text-muted);
}
.empty-state i { font-size: 48px; margin-bottom: 16px; opacity: 0.3; }
.empty-state p { font-size: 15px; }

/* ── Pagination ── */
.pagination { display: flex; align-items: center; gap: 6px; justify-content: center; padding-top: 20px; }
.page-btn {
  width: 36px; height: 36px; border-radius: 8px; border: 1.5px solid var(--border);
  background: var(--bg-card); color: var(--text-muted);
  font-size: 14px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all var(--transition);
}
.page-btn:hover, .page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ── Tab ── */
.tabs { display: flex; gap: 4px; background: var(--bg); padding: 4px; border-radius: 12px; width: fit-content; margin-bottom: 20px; }
.tab-btn {
  padding: 8px 20px; border-radius: 9px; border: none;
  background: transparent; color: var(--text-muted);
  font-size: 14px; font-weight: 600; cursor: pointer;
  transition: all var(--transition);
}
.tab-btn.active { background: var(--bg-card); color: var(--text); box-shadow: var(--shadow-sm); }

/* ── Filter Bar ── */
.filter-bar {
  display: flex; align-items: center; gap: 12px;
  flex-wrap: wrap; margin-bottom: 20px;
}
.filter-bar .form-control { width: auto; min-width: 140px; }
.search-box { position: relative; }
.search-box i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-muted); font-size: 14px; }
.search-box input { padding-left: 36px; }

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

/* ── Login Page ── */
.login-page {
  min-height: 100vh; display: flex;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}
.login-left {
  flex: 1; display: flex; align-items: center; justify-content: center;
  flex-direction: column; color: #fff; padding: 60px;
}
.login-right {
  width: 480px; background: var(--bg-card);
  display: flex; align-items: center; justify-content: center;
  padding: 60px 50px;
}
.login-brand-icon {
  width: 72px; height: 72px; background: rgba(255,255,255,0.2);
  border-radius: 20px; display: flex; align-items: center; justify-content: center;
  font-size: 34px; margin-bottom: 24px;
}
.login-tagline { font-size: 14px; opacity: 0.8; }
.login-box { width: 100%; max-width: 380px; }
.login-box h2 { font-size: 26px; font-weight: 800; margin-bottom: 6px; }
.login-box p { color: var(--text-muted); margin-bottom: 30px; }

/* ── Responsive ── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.5); z-index: 199;
}

@media (max-width: 1024px) {
  .grid-col-7-5 { grid-template-columns: 1fr; }
  .grid-2 { grid-template-columns: 1fr; }
}

@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.show { display: block; }
  .sidebar-toggle { display: flex; }
  .main-content { margin-left: 0; }
  .topbar-toggle { display: block; }
  .topbar-date { display: none; }
  .content-area { padding: 16px; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .login-left { display: none; }
  .login-right { width: 100%; padding: 40px 24px; }
  .form-grid { grid-template-columns: 1fr; }
  .btn-add span { display: none; }
  .grid-3 { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
}

/* ── Utilities ── */
.text-success { color: var(--success) !important; }
.text-danger { color: var(--danger) !important; }
.text-muted { color: var(--text-muted) !important; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.fw-bold { font-weight: 700; }
.mono { font-family: 'JetBrains Mono', monospace; }
.mb-0 { margin-bottom: 0 !important; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.mt-16 { margin-top: 16px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.flex-1 { flex: 1; }
.w-100 { width: 100%; }
