/* ==========================================================================
   RT Dua — Dashboard shell styles (sidebar, topbar, stats, charts)
   ========================================================================== */

body.dash { display: flex; min-height: 100vh; overflow-x: hidden; }

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.sidebar {
  width: var(--sidebar-w);
  flex: none;
  background: #ffffff;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 60;
  transition: transform .22s ease;
}
.side-brand {
  display: flex; align-items: center; gap: 11px;
  padding: 17px 18px;
  border-bottom: 1px solid var(--border-2);
  height: var(--topbar-h);
  flex: none;
}
.brand-mark {
  width: 38px; height: 38px; flex: none;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--primary), var(--primary-600));
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 11px rgba(13, 94, 53, .34);
}
.brand-txt { display: flex; flex-direction: column; line-height: 1.25; overflow: hidden; }
.brand-txt strong { font-size: 14.5px; letter-spacing: -.01em; }
.brand-txt span { font-size: 10.5px; color: var(--text-3); font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.side-nav { flex: 1; overflow-y: auto; padding: 14px 11px 8px; }
.nav-group { margin-bottom: 17px; }
.nav-label {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .075em; color: var(--text-3);
  padding: 0 9px; margin-bottom: 6px;
}
.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--r-sm);
  font-size: 13.4px; font-weight: 550;
  color: var(--text-2);
  margin-bottom: 2px;
  transition: .14s;
  position: relative;
}
.nav-item svg { color: var(--text-3); flex: none; transition: .14s; }
.nav-item:hover { background: var(--surface-2); color: var(--text); }
.nav-item:hover svg { color: var(--text-2); }
.nav-item.active {
  background: var(--primary-soft);
  color: var(--primary-700);
  font-weight: 700;
}
.nav-item.active svg { color: var(--primary-700); }
.nav-item.active::before {
  content: ''; position: absolute; left: -11px; top: 50%; transform: translateY(-50%);
  width: 3px; height: 19px; border-radius: 0 3px 3px 0; background: var(--primary);
}
.nav-text { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nav-badge {
  background: var(--error); color: #fff;
  font-size: 10.5px; font-weight: 700;
  min-width: 19px; height: 19px; padding: 0 6px;
  border-radius: var(--r-full);
  display: inline-flex; align-items: center; justify-content: center;
}
.nav-item.active .nav-badge { background: var(--primary-700); }

.side-foot { padding: 11px; border-top: 1px solid var(--border-2); flex: none; }

/* --------------------------------------------------------------------------
   Main column
   -------------------------------------------------------------------------- */
.main {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-w);
  display: flex;
  flex-direction: column;
}
.topbar {
  height: var(--topbar-h);
  flex: none;
  background: rgba(255, 255, 255, .9);
  backdrop-filter: blur(9px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 14px;
  padding: 0 24px;
  position: sticky; top: 0; z-index: 50;
}
.menu-toggle { display: none; }
.topbar-search { width: 340px; max-width: 40vw; }
.push-right { margin-left: auto; }

.user-chip {
  display: flex; align-items: center; gap: 9px;
  padding: 5px 12px 5px 5px;
  border-radius: var(--r-full);
  border: 1px solid var(--border);
  background: var(--surface);
  transition: .15s;
  cursor: pointer;
}
.user-chip:hover { border-color: #d3d7dd; background: var(--surface-2); }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; }
.user-meta strong { font-size: 12.5px; font-weight: 700; }
.user-meta span { font-size: 10.5px; color: var(--text-3); }

.content { padding: 26px 28px 60px; flex: 1; }

/* --------------------------------------------------------------------------
   Stat cards
   -------------------------------------------------------------------------- */
.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 17px 18px;
  box-shadow: var(--shadow-xs);
  position: relative;
  overflow: hidden;
  transition: .18s;
}
.stat:hover { transform: translateY(-2px); box-shadow: var(--shadow); border-color: #dcdfe4; }
.stat-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 13px; }
.stat-ico {
  width: 40px; height: 40px; border-radius: 11px;
  display: flex; align-items: center; justify-content: center;
}
.stat-ico svg { width: 20px; height: 20px; }
.stat-val { font-size: 25px; font-weight: 800; letter-spacing: -.03em; line-height: 1.1; }
.stat-lbl { font-size: 12.2px; color: var(--text-2); font-weight: 550; margin-top: 3px; }
.stat-delta { font-size: 11.5px; font-weight: 700; display: inline-flex; align-items: center; gap: 3px; }
.stat-delta svg { width: 13px; height: 13px; }
.up { color: #2e7d32; } .down { color: #c62828; } .flat { color: var(--text-3); }

/* Tone variants for icon boxes */
.t-primary { background: var(--primary-soft); color: var(--primary-700); }
.t-success { background: var(--success-soft); color: #2e7d32; }
.t-error { background: var(--error-soft); color: #c62828; }
.t-warning { background: var(--warning-soft); color: #b26a00; }
.t-info { background: var(--info-soft); color: #1565c0; }
.t-purple { background: var(--purple-soft); color: #6b3fb0; }
.t-teal { background: var(--teal-soft); color: #0f7a66; }

/* --------------------------------------------------------------------------
   Hero summary (dashboard)
   -------------------------------------------------------------------------- */
.hero-card {
  background: linear-gradient(128deg, var(--primary) 0%, #0a4d2b 52%, var(--gold-600) 100%);
  border-radius: var(--r-xl);
  padding: 24px 26px;
  color: #fff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(13, 94, 53, .28);
}
.hero-card::after {
  content: ''; position: absolute;
  width: 320px; height: 320px; border-radius: 50%;
  background: rgba(255, 255, 255, .1);
  top: -140px; right: -80px;
}
.hero-card::before {
  content: ''; position: absolute;
  width: 190px; height: 190px; border-radius: 50%;
  background: rgba(255, 255, 255, .08);
  bottom: -110px; right: 130px;
}
.hero-card > * { position: relative; z-index: 1; }
.hero-eyebrow {
  font-size: 11.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .08em; opacity: .85; margin-bottom: 5px;
}
.hero-card h2 { font-size: 22px; margin-bottom: 5px; }
.hero-card > p { font-size: 13px; opacity: .9; margin-bottom: 19px; max-width: 560px; }
.hero-pills { display: flex; flex-wrap: wrap; gap: 10px; }
.hero-pill {
  background: rgba(255, 255, 255, .18);
  backdrop-filter: blur(3px);
  border: 1px solid rgba(255, 255, 255, .22);
  border-radius: var(--r);
  padding: 10px 15px;
  display: flex; flex-direction: column; gap: 1px;
  min-width: 104px;
}
.hero-pill b { font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.hero-pill span { font-size: 10.8px; opacity: .88; font-weight: 550; }

/* --------------------------------------------------------------------------
   List rows
   -------------------------------------------------------------------------- */
.list-row {
  display: flex; align-items: center; gap: 13px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border-2);
}
.list-row:last-child { border-bottom: none; }
.list-row .lr-ico {
  width: 38px; height: 38px; border-radius: 11px; flex: none;
  display: flex; align-items: center; justify-content: center;
}
.list-row .lr-ico svg { width: 18px; height: 18px; }
.list-row .lr-main { flex: 1; min-width: 0; }
.list-row .lr-title { font-size: 13.4px; font-weight: 650; }
.list-row .lr-sub { font-size: 11.6px; color: var(--text-3); margin-top: 1px; }
.list-row .lr-right { text-align: right; flex: none; }

/* Activity feed */
.feed-item {
  display: flex; gap: 12px;
  padding: 13px 0;
  border-bottom: 1px solid var(--border-2);
}
.feed-item:last-child { border-bottom: none; }
.feed-ico {
  width: 36px; height: 36px; border-radius: 50%; flex: none;
  display: flex; align-items: center; justify-content: center;
}
.feed-ico svg { width: 17px; height: 17px; }
.feed-body { flex: 1; min-width: 0; }
.feed-title { font-size: 13.2px; font-weight: 600; line-height: 1.4; }
.feed-sub { font-size: 11.5px; color: var(--text-3); margin-top: 2px; }
.feed-time { font-size: 11px; color: var(--text-3); white-space: nowrap; flex: none; }

/* --------------------------------------------------------------------------
   Charts
   -------------------------------------------------------------------------- */
.chart-bars {
  display: flex; align-items: flex-end; gap: 6px;
  padding-top: 20px;
}
.chart-col {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  height: 100%; min-width: 0;
}
.chart-val { font-size: 10.5px; font-weight: 700; color: var(--text-2); white-space: nowrap; }
.chart-track {
  flex: 1; width: 100%; display: flex; align-items: flex-end;
  padding: 5px 0 6px;
}
.chart-fill {
  width: 100%; border-radius: 6px 6px 3px 3px;
  min-height: 3px;
  transition: height .55s cubic-bezier(.16, 1, .3, 1);
}
.chart-lbl {
  font-size: 10.5px; color: var(--text-3); font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%;
}

.progress-row { margin-bottom: 15px; }
.progress-row:last-child { margin-bottom: 0; }

.legend { display: flex; flex-direction: column; gap: 11px; }
.legend-item { display: flex; align-items: center; gap: 9px; font-size: 12.6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.legend-item .lg-val { margin-left: auto; font-weight: 700; font-variant-numeric: tabular-nums; }

.donut-wrap { position: relative; display: flex; align-items: center; justify-content: center; min-width: 0; }
/* The donut is generated at a fixed pixel size. Clamp it so a 168px chart
   still fits inside a 320px phone with page padding on both sides. */
.donut-wrap > svg { width: 100%; max-width: 168px; height: auto; }
.donut-center {
  position: absolute; text-align: center; line-height: 1.2;
}
.donut-center b { display: block; font-size: 19px; font-weight: 800; letter-spacing: -.02em; }
.donut-center span { font-size: 10.8px; color: var(--text-3); }

/* Horizontal mini bars (statistik) */
.hbar-row { margin-bottom: 13px; }
.hbar-top { display: flex; justify-content: space-between; font-size: 12.4px; margin-bottom: 5px; }
.hbar-top b { font-variant-numeric: tabular-nums; }

/* --------------------------------------------------------------------------
   Filter bar
   -------------------------------------------------------------------------- */
.filter-bar {
  display: flex; align-items: center; gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.filter-bar .search-wrap { flex: 1; min-width: 210px; max-width: 330px; }

/* --------------------------------------------------------------------------
   Timeline (mutasi)
   -------------------------------------------------------------------------- */
.timeline { position: relative; padding-left: 26px; }
.timeline::before {
  content: ''; position: absolute; left: 8px; top: 6px; bottom: 6px;
  width: 2px; background: var(--border);
}
.tl-item { position: relative; padding-bottom: 20px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ''; position: absolute; left: -24px; top: 4px;
  width: 12px; height: 12px; border-radius: 50%;
  background: #fff; border: 3px solid var(--primary);
}
.tl-item.in::before { border-color: var(--success); }
.tl-item.out::before { border-color: var(--error); }

/* --------------------------------------------------------------------------
   Public site nav / footer (shared with landing page)
   -------------------------------------------------------------------------- */
.pub-nav {
  position: sticky; top: 0; z-index: 80;
  background: rgba(255, 255, 255, .88);
  backdrop-filter: blur(11px);
  border-bottom: 1px solid var(--border);
}
.pub-nav-inner {
  max-width: 1180px; margin: 0 auto;
  padding: 0 26px; height: 68px;
  display: flex; align-items: center; gap: 12px;
}
.pub-links { display: flex; gap: 4px; margin-left: 12px; }
.pub-links a {
  padding: 8px 13px; border-radius: var(--r-sm);
  font-size: 13.5px; font-weight: 600; color: var(--text-2);
  transition: .15s;
}
.pub-links a:hover { background: var(--surface-2); color: var(--text); }
.pub-cta { margin-left: auto; display: flex; gap: 9px; align-items: center; }

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 1000px) {
  .sidebar { transform: translateX(-100%); box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .main { margin-left: 0; }
  .menu-toggle { display: inline-flex; }
  .side-scrim {
    position: fixed; inset: 0; background: rgba(16, 24, 40, .45);
    z-index: 55; opacity: 0; pointer-events: none; transition: opacity .2s;
  }
  .side-scrim.show { opacity: 1; pointer-events: auto; }
  .content { padding: 20px 18px 56px; }
  .topbar { padding: 0 16px; }
  .pub-links { display: none; }
}
@media (min-width: 1001px) { .side-scrim { display: none; } }

@media (max-width: 640px) {
  .topbar-search { display: none; }
  .user-meta { display: none; }
  .page-head h1 { font-size: 20px; }
  .topbar { gap: 8px; padding: 0 11px; }
  .hero-card { padding: 19px 17px; border-radius: var(--r-lg); }
  .hero-card h2 { font-size: 18.5px; }
  .hero-card > p { font-size: 12.5px; margin-bottom: 15px; }
  .hero-card::after { width: 200px; height: 200px; top: -100px; right: -60px; }
  .hero-card::before { display: none; }
  .hero-pills { gap: 8px; }
  .hero-pill { padding: 8px 12px; }
  .hero-pill b { font-size: 16px; }
  .feed-time { display: none; }
  .list-row { gap: 10px; }
  .timeline { padding-left: 20px; }
  .tl-item::before { left: -18px; }
  .chart-bars { gap: 3px; }
  .chart-val { font-size: 9.4px; }
  .chart-lbl { font-size: 9.4px; }
  .filter-bar { margin-bottom: 13px; }
}

/* Very narrow phones — trim the chrome further so content, not padding,
   owns the screen. */
@media (max-width: 400px) {
  .topbar { height: 58px; }
  .brand-mark { width: 33px; height: 33px; }
  .user-chip { padding: 4px 9px 4px 4px; }
  .icon-btn { width: 34px; height: 34px; }
  .hero-card { padding: 17px 14px; }
  .chart-bars { gap: 2px; }
}

/* Gold badge tone — used by the admin approval queue so it reads as
   "needs attention" rather than "error". */
.nav-badge.badge-gold { background: var(--gold); color: #241c07; }
.nav-item.active .nav-badge.badge-gold { background: var(--gold-600); color: #241c07; }

/* Gold tone — used by the admin approval queue. */
.t-gold { background: var(--gold-soft); color: var(--gold-700); }

/* Danger badge tone — used by the CCTV sidebar counter (offline cameras). */
.nav-badge.badge-danger { background: var(--error); color: #fff; }
.nav-item.active .nav-badge.badge-danger { background: #fff; color: var(--error); }
