/* =============================================
   FLEXI P3K — PREMIUM THEME
   Hitam Obsidian + Aksen Emas/Gold
   ============================================= */

/* ── FONTS ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

/* ── ROOT VARIABLES (LIGHT MODE) ── */
:root {
  --font: 'Inter', sans-serif;

  /* Gold accent */
  --gold: #c9a227;
  --gold-light: #f0c74b;
  --gold-dim: rgba(201, 162, 39, 0.12);
  --gold-border: rgba(201, 162, 39, 0.2);

  /* Surface */
  --bg-app: #f4f4f5;
  --bg-sidebar: #18181b;
  --bg-sidebar-brand: #111113;
  --bg-topbar: #ffffff;
  --bg-card: #ffffff;
  --bg-hover: rgba(0, 0, 0, 0.04);
  --bg-active: rgba(201, 162, 39, 0.1);

  /* Text */
  --text-primary: #18181b;
  --text-secondary: #71717a;
  --text-muted: #a1a1aa;
  --text-sidebar: rgba(255, 255, 255, 0.6);
  --text-sidebar-active: #ffffff;
  --text-sidebar-muted: rgba(255, 255, 255, 0.25);

  /* Borders */
  --border: #e4e4e7;
  --border-sidebar: rgba(255, 255, 255, 0.07);
  --border-card: #e4e4e7;

  /* Semantic */
  --color-blue: #3b82f6;
  --color-blue-dim: rgba(59, 130, 246, 0.1);
  --color-green: #22c55e;
  --color-green-dim: rgba(34, 197, 94, 0.1);
  --color-red: #ef4444;
  --color-red-dim: rgba(239, 68, 68, 0.1);
  --color-amber: #f59e0b;
  --color-amber-dim: rgba(245, 158, 11, 0.1);

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

/* ── DARK MODE ── */
html.dark {
  --bg-app: #0a0a0a;
  --bg-sidebar: #0d0d0d;
  --bg-sidebar-brand: #080808;
  --bg-topbar: #0d0d0d;
  --bg-card: #111113;
  --bg-hover: rgba(255, 255, 255, 0.04);
  --bg-active: rgba(201, 162, 39, 0.1);

  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #52525b;

  --border: #1f1f22;
  --border-card: #1f1f22;

  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
}

/* ── RESET & BASE ── */
* { box-sizing: border-box; }

body {
  font-family: var(--font);
  background: var(--bg-app);
  color: var(--text-primary);
  margin: 0;
  -webkit-font-smoothing: antialiased;
}

/* =============================================
   LAYOUT
   ============================================= */
.flexi-layout {
  display: flex;
  min-height: 100vh;
}

.flexi-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
}

/* =============================================
   SIDEBAR
   ============================================= */
.flexi-sidebar {
  width: 220px;
  min-width: 220px;
  height: 100vh;
  position: sticky;
  top: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-sidebar);
  display: flex;
  flex-direction: column;
  transition: width 0.25s cubic-bezier(0.4, 0, 0.2, 1),
              min-width 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  z-index: 100;
  flex-shrink: 0;
}

.flexi-sidebar.collapsed {
  width: 0;
  min-width: 0;
}

/* Brand */
.sb-brand {
  padding: 18px 14px;
  border-bottom: 1px solid var(--border-sidebar);
  background: var(--bg-sidebar-brand);
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 60px;
  white-space: nowrap;
}

.sb-brand-icon {
  width: 30px;
  height: 30px;
  min-width: 30px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: #0a0a0a;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(201, 162, 39, 0.3);
}

.sb-brand-text {
  font-size: 15px;
  font-weight: 600;
  color: #f4f4f5;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.sb-brand-text span {
  color: var(--gold);
}

/* Menu */
.sb-menu {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px 8px;
  scrollbar-width: thin;
  scrollbar-color: #2a2a2a transparent;
}

.sb-menu::-webkit-scrollbar { width: 3px; }
.sb-menu::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 3px; }

.sb-section {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-sidebar-muted);
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: 14px 10px 6px;
  white-space: nowrap;
}

.sb-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  margin-bottom: 1px;
  color: var(--text-sidebar);
  font-size: 13px;
  font-weight: 400;
  text-decoration: none;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: background 0.15s, color 0.15s;
}

.sb-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.85);
  text-decoration: none;
}

.sb-item.active {
  background: var(--gold-dim);
  color: var(--gold-light);
  border-color: var(--gold-border);
  font-weight: 500;
}

.sb-item i {
  font-size: 15px;
  width: 18px;
  min-width: 18px;
  text-align: center;
}

.sb-badge {
  margin-left: auto;
  background: var(--gold-dim);
  color: var(--gold);
  font-size: 9px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  border: 1px solid var(--gold-border);
  white-space: nowrap;
}

/* Submenu */
.sb-collapse {
  overflow: hidden;
  max-height: 0;
  transition: max-height 0.25s ease;
}

.sb-collapse.open {
  max-height: 300px;
}

.sb-sub {
  padding: 2px 10px 4px 36px;
  border-left: 1px solid rgba(255,255,255,0.07);
  margin-left: 18px;
  margin-top: 2px;
}

.sb-sub-item {
  display: block;
  padding: 6px 8px;
  font-size: 12px;
  color: rgba(255,255,255,0.4);
  text-decoration: none;
  border-radius: 6px;
  white-space: nowrap;
  transition: color 0.15s;
}

.sb-sub-item:hover {
  color: rgba(255,255,255,0.75);
  text-decoration: none;
}

.sb-sub-item.active {
  color: var(--gold-light);
}

/* Chevron */
.sb-chevron {
  margin-left: auto;
  font-size: 11px;
  transition: transform 0.2s;
  color: rgba(255,255,255,0.25);
}

.sb-chevron.open { transform: rotate(90deg); }

/* Footer */
.sb-footer {
  padding: 12px;
  border-top: 1px solid var(--border-sidebar);
}

.sb-user-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.sb-user-card:hover {
  background: rgba(255,255,255,0.06);
}

.sb-user-avatar {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 7px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #0a0a0a;
}

.sb-user-name {
  font-size: 12px;
  font-weight: 500;
  color: #d4d4d8;
  line-height: 1.2;
}

.sb-user-role {
  font-size: 10px;
  color: rgba(255,255,255,0.3);
}

/* =============================================
   TOPBAR / NAVBAR
   ============================================= */
.flexi-topbar {
  height: 56px;
  min-height: 56px;
  background: var(--bg-topbar);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  position: sticky;
  top: 0;
  z-index: 90;
}

.tb-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tb-toggle {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 15px;
  transition: background 0.15s;
  flex-shrink: 0;
}

.tb-toggle:hover { background: var(--border); }

.tb-breadcrumb {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}

.tb-breadcrumb .current {
  color: var(--text-secondary);
  font-weight: 500;
}

.tb-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.tb-icon-btn {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 14px;
  transition: background 0.15s;
}

.tb-icon-btn:hover { background: var(--border); }

.tb-user-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 10px 4px 5px;
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.tb-user-pill:hover { background: var(--border); }

.tb-user-avatar {
  width: 24px;
  height: 24px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--gold), var(--gold-light));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  color: #0a0a0a;
}

.tb-user-info .tb-uname {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary);
  line-height: 1.2;
}

.tb-user-info .tb-urole {
  font-size: 10px;
  color: var(--text-muted);
}

/* Divider */
.tb-divider {
  width: 1px;
  height: 20px;
  background: var(--border);
}

/* =============================================
   CONTENT AREA
   ============================================= */
.flexi-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
}

/* Page header */
.page-header {
  margin-bottom: 24px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.page-title {
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}

.page-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-top: 3px;
}

/* =============================================
   STAT CARDS
   ============================================= */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 20px;
}

@media (max-width: 1100px) { .stat-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .stat-grid { grid-template-columns: 1fr; } }

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  padding: 18px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-card::after {
  content: '';
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 2px;
}

.stat-card.gold::after  { background: linear-gradient(90deg, var(--gold), var(--gold-light)); }
.stat-card.green::after { background: linear-gradient(90deg, #16a34a, #22c55e); }
.stat-card.red::after   { background: linear-gradient(90deg, #dc2626, #ef4444); }
.stat-card.blue::after  { background: linear-gradient(90deg, #1d4ed8, #3b82f6); }

.stat-icon {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  margin-bottom: 14px;
}

.stat-icon.gold  { background: var(--gold-dim);              color: var(--gold); }
.stat-icon.green { background: var(--color-green-dim);        color: var(--color-green); }
.stat-icon.red   { background: var(--color-red-dim);          color: var(--color-red); }
.stat-icon.blue  { background: var(--color-blue-dim);         color: var(--color-blue); }

.stat-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 6px;
}

.stat-value {
  font-size: 24px;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  line-height: 1;
}

.stat-sub {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 6px;
}

/* =============================================
   CARDS (CHART & LIST)
   ============================================= */
.flexi-card {
  background: var(--bg-card);
  border: 1px solid var(--border-card);
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
}

.flexi-card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.flexi-card-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
}

.flexi-card-badge {
  font-size: 11px;
  background: var(--gold-dim);
  color: var(--gold);
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid var(--gold-border);
  font-weight: 500;
}

.flexi-card-body {
  padding: 20px;
}

/* bottom grid */
.bottom-grid {
  display: grid;
  grid-template-columns: 1fr 300px;
  gap: 14px;
}

@media (max-width: 900px) { .bottom-grid { grid-template-columns: 1fr; } }

/* SKPD list */
.skpd-item {
  margin-bottom: 16px;
}

.skpd-item:last-child { margin-bottom: 0; }

.skpd-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.skpd-name {
  font-size: 12px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 170px;
}

.skpd-count {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.skpd-track {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.skpd-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  border-radius: 2px;
}

/* =============================================
   DROPDOWN MENU
   ============================================= */
.flexi-dropdown {
  position: relative;
}

.flexi-dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 6px;
  min-width: 180px;
  box-shadow: var(--shadow-md);
  z-index: 200;
  display: none;
}

.flexi-dropdown-menu.open { display: block; }

.dd-header {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  padding: 4px 8px 6px;
}

.dd-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 10px;
  border-radius: 7px;
  font-size: 13px;
  color: var(--text-secondary);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.12s;
}

.dd-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  text-decoration: none;
}

.dd-item.danger { color: var(--color-red); }
.dd-item.danger:hover { background: var(--color-red-dim); }
.dd-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* =============================================
   FOOTER
   ============================================= */
.flexi-footer {
  padding: 14px 24px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-topbar);
}

.footer-text {
  font-size: 12px;
  color: var(--text-muted);
}

.footer-text strong {
  color: var(--gold);
  font-weight: 600;
}

.footer-links {
  display: flex;
  gap: 16px;
}

.footer-links a {
  font-size: 12px;
  color: var(--text-muted);
  text-decoration: none;
}

.footer-links a:hover { color: var(--text-secondary); }

/* =============================================
   UTILITIES
   ============================================= */
.text-gold { color: var(--gold); }
.bg-gold-dim { background: var(--gold-dim); }
.border-gold { border-color: var(--gold-border) !important; }

/* Modal About */
.flexi-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.flexi-modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px;
  max-width: 380px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
}

/* Sidebar light mode */
html:not(.dark) .flexi-sidebar {
  background: #1a1a2e;  /* tetap gelap tapi lebih soft */
}

/* ATAU kalau mau benar-benar terang: */
html:not(.dark) .flexi-sidebar {
  background: #ffffff;
  border-right: 1px solid #e4e4e7;
}

html:not(.dark) .sb-brand-text { color: #18181b; }
html:not(.dark) .sb-brand-text span { color: #c9a227; }
html:not(.dark) .sb-section { color: #a1a1aa; }
html:not(.dark) .sb-item { color: #71717a; }
html:not(.dark) .sb-item:hover { background: #f4f4f5; color: #18181b; }
html:not(.dark) .sb-item.active { background: rgba(201,162,39,0.1); color: #92700f; }
html:not(.dark) .sb-user-card { background: #f4f4f5; border-color: #e4e4e7; }
html:not(.dark) .sb-user-name { color: #18181b; }
html:not(.dark) .sb-user-role { color: #a1a1aa; }
html:not(.dark) .sb-brand { background: #f9f9f9; border-bottom-color: #e4e4e7; }
html:not(.dark) .sb-footer { border-top-color: #e4e4e7; }
html:not(.dark) .sb-sub-item { color: #71717a; }
html:not(.dark) .sb-sub-item:hover { color: #18181b; }


/* Tambahkan di flexi-theme.css */
.flexi-card-body canvas {
  width: 100% !important;
  height: 280px !important;
}

html, body, #root {
  height: 100%;
  margin: 0;
  overflow: hidden; /* ← cegah double scroll */
}

.flexi-layout {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.flexi-sidebar {
  height: 100vh;
  overflow-y: auto;
  flex-shrink: 0;
}

.flexi-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* ← penting */
}

.flexi-content {
  flex: 1;
  padding: 24px;
  overflow-y: auto;  /* ← scroll ada di sini */
  overflow-x: hidden;
}



.sb-sub-item { position: relative; }

.flexi-sidebar .sb-sub .sb-sub-item.active {
  color: #b8860b !important;
  background: rgba(184, 134, 11, 0.08);
  font-weight: 600;
  border-radius: 8px;
}

html.dark .flexi-sidebar .sb-sub .sb-sub-item.active {
  color: var(--gold-light) !important;
  background: var(--gold-dim);
}

.sb-sub-item.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: #b8860b;
  border-radius: 2px;
}

html .sb-sub-item.active,
html:not(.dark) .sb-sub-item.active {
  color: #92700f;                      /* emas lebih gelap = lebih kontras di light mode */
  background: rgba(184, 134, 11, 0.14); /* tint lebih pekat */
  font-weight: 700;
  border-radius: 8px;
}