/* ============================================================
   WKB-GIM — Main Stylesheet
   Theme: Navy #1e3a5f | White | Orange #f97316
   Font: Inter (UI) + JetBrains Mono (data)
   ============================================================ */

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

:root {
  --navy:       #1e3a5f;
  --navy-dark:  #152d4a;
  --navy-light: #2a4f7c;
  --orange:     #f97316;
  --orange-dark:#ea6a0a;
  --white:      #ffffff;
  --bg:         #f0f4f8;
  --bg-card:    #ffffff;
  --border:     #d1dbe8;
  --text:       #1a2738;
  --text-muted: #64748b;
  --success:    #22c55e;
  --danger:     #ef4444;
  --warning:    #f59e0b;
  --info:       #3b82f6;
  --sidebar-w:  240px;
  --topbar-h:   56px;
  --radius:     8px;
  --shadow:     0 1px 4px rgba(30,58,95,.10);
  --shadow-md:  0 4px 16px rgba(30,58,95,.14);
}

html, body { height: 100%; font-family: 'Inter', sans-serif; font-size: 14px; background: var(--bg); color: var(--text); }

/* ── SCROLLBAR ─────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #b0becc; border-radius: 3px; }

/* ── LOGIN ─────────────────────────────────────────────── */
.login-overlay {
  position: fixed; inset: 0; background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy) 60%, #1a4a7a 100%);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.login-card {
  background: var(--white); border-radius: 16px; padding: 48px 40px;
  width: 100%; max-width: 400px; text-align: center;
  box-shadow: 0 24px 64px rgba(0,0,0,.30);
}
.login-logo { font-size: 36px; font-weight: 700; letter-spacing: -1px; margin-bottom: 4px; }
.logo-wkb { color: var(--navy); }
.logo-gim { color: var(--orange); }
.login-subtitle { color: var(--text-muted); margin-bottom: 32px; font-size: 13px; letter-spacing: .5px; text-transform: uppercase; }
.login-message { padding: 12px 16px; border-radius: var(--radius); margin-bottom: 16px; font-weight: 500; font-size: 13px; }
.login-message.error { background: #fef2f2; color: #dc2626; border: 1px solid #fecaca; }
.login-message.info  { background: #eff6ff; color: #1d4ed8; border: 1px solid #bfdbfe; }
.btn-google {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; padding: 13px; border-radius: var(--radius);
  background: var(--navy); color: var(--white); border: none; cursor: pointer;
  font-size: 15px; font-weight: 600; font-family: inherit;
  transition: background .2s; letter-spacing: .2px;
}
.btn-google:hover { background: var(--navy-light); }
.login-note { margin-top: 20px; font-size: 12px; color: var(--text-muted); }

/* ── APP SHELL ─────────────────────────────────────────── */
.app-shell { display: flex; min-height: 100vh; }

/* ── SIDEBAR ───────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); background: var(--navy); color: var(--white);
  display: flex; flex-direction: column; position: fixed; top: 0; left: 0;
  height: 100vh; z-index: 200; transition: transform .25s ease;
}
.sidebar-header { padding: 24px 20px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-logo { font-size: 22px; font-weight: 700; letter-spacing: -.5px; }
.sidebar-sub { font-size: 11px; color: rgba(255,255,255,.45); margin-top: 2px; letter-spacing: .8px; text-transform: uppercase; }
.sidebar-nav { flex: 1; padding: 12px 0; overflow-y: auto; }
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 20px; color: rgba(255,255,255,.65);
  text-decoration: none; font-size: 13.5px; font-weight: 500;
  transition: all .15s; border-left: 3px solid transparent;
}
.nav-item svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.8; flex-shrink: 0; }
.nav-item:hover { color: var(--white); background: rgba(255,255,255,.07); }
.nav-item.active { color: var(--white); background: rgba(249,115,22,.15); border-left-color: var(--orange); }
.sidebar-footer {
  padding: 16px 20px; border-top: 1px solid rgba(255,255,255,.08);
  display: flex; align-items: center; gap: 10px;
}
.user-info { flex: 1; display: flex; align-items: center; gap: 10px; min-width: 0; }
.user-avatar { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; border: 2px solid rgba(255,255,255,.2); flex-shrink: 0; }
.user-details { min-width: 0; }
.user-name { display: block; color: var(--white); font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { display: block; color: rgba(255,255,255,.45); font-size: 11px; text-transform: uppercase; letter-spacing: .5px; }
.btn-logout {
  background: rgba(255,255,255,.08); border: none; color: rgba(255,255,255,.6);
  cursor: pointer; padding: 8px; border-radius: 6px; transition: all .15s; flex-shrink: 0;
}
.btn-logout:hover { background: rgba(239,68,68,.2); color: #fca5a5; }
.btn-logout svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.8; display: block; }

/* ── TOPBAR (mobile) ───────────────────────────────────── */
.topbar {
  display: none; position: fixed; top: 0; left: 0; right: 0; height: var(--topbar-h);
  background: var(--navy); color: var(--white); z-index: 150;
  align-items: center; padding: 0 16px; gap: 12px;
}
.btn-menu-toggle { background: none; border: none; color: var(--white); cursor: pointer; padding: 4px; }
.btn-menu-toggle svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 2; display: block; }
.topbar-title { font-size: 17px; font-weight: 700; flex: 1; }
.topbar-avatar { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 199; }

/* ── MAIN CONTENT ──────────────────────────────────────── */
.main-content { margin-left: var(--sidebar-w); flex: 1; min-height: 100vh; padding: 28px; }

/* ── PAGE HEADER ───────────────────────────────────────── */
.page-header { margin-bottom: 24px; }
.page-title { font-size: 22px; font-weight: 700; color: var(--navy); }
.page-subtitle { font-size: 13px; color: var(--text-muted); margin-top: 2px; }

/* ── CARDS ─────────────────────────────────────────────── */
.card {
  background: var(--bg-card); border-radius: var(--radius); border: 1px solid var(--border);
  box-shadow: var(--shadow); overflow: hidden;
}
.card-header { padding: 16px 20px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px; }
.card-title { font-size: 14px; font-weight: 600; color: var(--navy); }
.card-body { padding: 20px; }

/* ── STAT CARDS ────────────────────────────────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--white); border-radius: var(--radius); padding: 20px 22px;
  border: 1px solid var(--border); box-shadow: var(--shadow);
  display: flex; align-items: center; gap: 16px;
}
.stat-icon {
  width: 46px; height: 46px; border-radius: 10px; display: flex; align-items: center;
  justify-content: center; flex-shrink: 0;
}
.stat-icon svg { width: 22px; height: 22px; stroke: var(--white); fill: none; stroke-width: 2; }
.stat-icon.blue   { background: var(--navy); }
.stat-icon.orange { background: var(--orange); }
.stat-icon.green  { background: var(--success); }
.stat-icon.purple { background: #8b5cf6; }
.stat-value { font-size: 26px; font-weight: 700; color: var(--navy); font-family: 'JetBrains Mono', monospace; line-height: 1; }
.stat-label { font-size: 12px; color: var(--text-muted); margin-top: 3px; font-weight: 500; }

/* ── TOOLBAR ───────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.search-box {
  position: relative; flex: 1; min-width: 200px; max-width: 320px;
}
.search-box input {
  width: 100%; padding: 8px 12px 8px 36px; border: 1px solid var(--border);
  border-radius: var(--radius); font-family: inherit; font-size: 13px;
  background: var(--white); color: var(--text); transition: border-color .15s;
}
.search-box input:focus { outline: none; border-color: var(--navy); }
.search-box svg {
  position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
  width: 15px; height: 15px; stroke: var(--text-muted); fill: none; stroke-width: 2;
}
.filter-input {
  padding: 8px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-family: inherit; font-size: 13px; background: var(--white); color: var(--text);
  min-width: 130px; transition: border-color .15s;
}
.filter-input:focus { outline: none; border-color: var(--navy); }

/* ── BUTTONS ───────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-family: inherit; font-size: 13px; font-weight: 600;
  border: none; cursor: pointer; transition: all .15s; white-space: nowrap; text-decoration: none;
}
.btn svg { width: 15px; height: 15px; stroke: currentColor; fill: none; stroke-width: 2; }
.btn-primary { background: var(--orange); color: var(--white); }
.btn-primary:hover { background: var(--orange-dark); }
.btn-secondary { background: var(--navy); color: var(--white); }
.btn-secondary:hover { background: var(--navy-light); }
.btn-ghost { background: transparent; color: var(--navy); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); }
.btn-success { background: var(--success); color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }
.btn-danger:hover { background: #dc2626; }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn-icon { padding: 6px; }

/* ── TABLE ─────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
thead th {
  background: var(--navy); color: var(--white); padding: 10px 12px;
  text-align: left; font-weight: 600; font-size: 12px; letter-spacing: .4px;
  position: sticky; top: 0; z-index: 1; white-space: nowrap;
}
tbody tr { border-bottom: 1px solid var(--border); transition: background .1s; }
tbody tr:nth-child(even) { background: #f8fafc; }
tbody tr:hover { background: #eef3f9; }
tbody td { padding: 9px 12px; vertical-align: middle; white-space: nowrap; }
.td-mono { font-family: 'JetBrains Mono', monospace; font-size: 12px; }
.badge {
  display: inline-flex; align-items: center; padding: 2px 8px;
  border-radius: 999px; font-size: 11px; font-weight: 600; letter-spacing: .3px;
}
.badge-success { background: #dcfce7; color: #15803d; }
.badge-danger  { background: #fee2e2; color: #dc2626; }
.badge-warning { background: #fef9c3; color: #854d0e; }
.badge-info    { background: #dbeafe; color: #1d4ed8; }
.badge-gray    { background: #f1f5f9; color: #64748b; }

/* checkbox in table */
.ceklist-check { width: 16px; height: 16px; accent-color: var(--orange); cursor: pointer; }

/* action buttons in table */
.actions-cell { display: flex; gap: 4px; align-items: center; }
.btn-edit  { background: #dbeafe; color: #1d4ed8; border: none; }
.btn-edit:hover  { background: #bfdbfe; }
.btn-del   { background: #fee2e2; color: #dc2626; border: none; }
.btn-del:hover   { background: #fecaca; }

/* ── FORM ──────────────────────────────────────────────── */
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.form-group { display: flex; flex-direction: column; gap: 5px; }
.form-group.span2 { grid-column: span 2; }
.form-group.span3 { grid-column: span 3; }
label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .4px; }
.form-control {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: var(--radius);
  font-family: inherit; font-size: 13px; color: var(--text); background: var(--white);
  transition: border-color .15s; width: 100%;
}
.form-control:focus { outline: none; border-color: var(--navy); box-shadow: 0 0 0 3px rgba(30,58,95,.08); }
.form-control[readonly] { background: var(--bg); color: var(--text-muted); cursor: not-allowed; }
textarea.form-control { resize: vertical; min-height: 80px; }

/* autocomplete dropdown */
.autocomplete-wrap { position: relative; }
.autocomplete-list {
  position: absolute; top: 100%; left: 0; right: 0; background: var(--white);
  border: 1px solid var(--border); border-top: none; border-radius: 0 0 var(--radius) var(--radius);
  max-height: 180px; overflow-y: auto; z-index: 50; box-shadow: var(--shadow-md);
}
.autocomplete-item { padding: 8px 12px; cursor: pointer; font-size: 13px; transition: background .1s; }
.autocomplete-item:hover { background: var(--bg); }

/* ── MODAL ─────────────────────────────────────────────── */
.modal { position: fixed; inset: 0; z-index: 500; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.5); }
.modal-box {
  position: relative; background: var(--white); border-radius: 12px;
  width: 100%; max-width: 680px; max-height: 90vh; display: flex; flex-direction: column;
  box-shadow: 0 24px 64px rgba(0,0,0,.25);
}
.modal-box.modal-sm { max-width: 420px; }
.modal-header { padding: 18px 24px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-header h3 { font-size: 15px; font-weight: 700; color: var(--navy); }
.modal-close { background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text-muted); line-height: 1; padding: 0 4px; }
.modal-close:hover { color: var(--danger); }
.modal-body { padding: 20px 24px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 24px; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 10px; }

/* ── TOAST ─────────────────────────────────────────────── */
.toast-container { position: fixed; bottom: 24px; right: 24px; z-index: 900; display: flex; flex-direction: column; gap: 8px; }
.toast {
  padding: 13px 18px; border-radius: var(--radius); color: var(--white);
  font-size: 13px; font-weight: 500; box-shadow: var(--shadow-md);
  animation: slideUp .25s ease; max-width: 320px;
}
.toast.success { background: var(--success); }
.toast.error   { background: var(--danger); }
.toast.warning { background: var(--warning); color: var(--text); }
.toast.info    { background: var(--info); }
@keyframes slideUp { from { transform: translateY(16px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

/* ── CHARTS ────────────────────────────────────────────── */
.chart-wrap { position: relative; height: 260px; }
.bar-chart { display: flex; align-items: flex-end; gap: 8px; height: 100%; padding-bottom: 30px; padding-top: 20px; }
.bar-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; height: 100%; justify-content: flex-end; }
.bar-fill { width: 100%; border-radius: 4px 4px 0 0; min-height: 4px; transition: height .5s ease; position: relative; }
.bar-fill.blue   { background: var(--navy); }
.bar-fill.orange { background: var(--orange); }
.bar-label { font-size: 10px; color: var(--text-muted); text-align: center; }
.bar-value { font-size: 10px; font-weight: 600; color: var(--text-muted); }

/* ── LOADING ───────────────────────────────────────────── */
.page-loading { position: fixed; inset: 0; background: rgba(255,255,255,.7); display: flex; align-items: center; justify-content: center; z-index: 300; }
.spinner { width: 36px; height: 36px; border: 3px solid var(--border); border-top-color: var(--orange); border-radius: 50%; animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── UTILS ─────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.gap-10 { display: flex; gap: 10px; align-items: center; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.empty-state { text-align: center; padding: 48px 24px; color: var(--text-muted); }
.empty-state svg { width: 40px; height: 40px; stroke: var(--border); fill: none; stroke-width: 1.5; margin: 0 auto 12px; display: block; }
.divider { border: none; border-top: 1px solid var(--border); margin: 16px 0; }

/* ── PAGINATION ────────────────────────────────────────── */
.pagination { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.page-info { font-size: 12px; color: var(--text-muted); margin-right: auto; }

/* ── TOGGLE VISIBILITY ─────────────────────────────────── */
.toggle-col { font-size: 12px; color: var(--text-muted); cursor: pointer; user-select: none; }
.toggle-col:hover { color: var(--navy); }

/* ── REKAP LEGEND ──────────────────────────────────────── */
.legend { display: flex; gap: 16px; flex-wrap: wrap; }
.legend-item { display: flex; align-items: center; gap: 6px; font-size: 12px; }
.legend-dot { width: 10px; height: 10px; border-radius: 2px; }

/* ── RESPONSIVE ────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); box-shadow: var(--shadow-md); }
  .sidebar-overlay.show { display: block; }
  .topbar { display: flex; }
  .main-content { margin-left: 0; padding: 80px 16px 24px; }
  .form-grid { grid-template-columns: 1fr; }
  .form-group.span2, .form-group.span3 { grid-column: span 1; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .modal-box { max-width: 100%; }
}
@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .search-box { max-width: 100%; }
}

/* ── TFOOT ─────────────────────────────────────────────── */
tfoot tr { border-top: 2px solid var(--navy); }
tfoot td { padding: 9px 12px; font-size: 13px; }

/* ── RESPONSIVE GRID ───────────────────────────────────── */
@media (max-width: 900px) {
  #dashCharts, #rekapGrid { grid-template-columns: 1fr !important; }
}

/* ── CARD MARGIN UTIL ──────────────────────────────────── */
.mb-20 { margin-bottom: 20px; }
