/* ==========================================================================
   RELAWANKU - TOKEN & KERANGKA HALAMAN
   Palet diambil dari logo Yayasan Demo Nusantara:
   navy (tulisan), biru langit (figur), hijau zaitun/lime (lengkungan).
   Terang = bawaan karena logo hidup di atas putih; gelap = pilihan.
   Kontras teks diverifikasi >= 4.5:1 di kedua tema.
   ========================================================================== */

:root,
[data-theme="light"] {
  --bg-primary: #f5f6f3;
  --bg-secondary: #eef1ea;
  --bg-card: #ffffff;
  --bg-card-hover: #f8f9f6;
  --bg-sidebar: #ffffff;
  --bg-modal: #ffffff;
  --bg-glass: #ffffff;

  --border-color: #dfe3da;
  --border-subtle: #eceee8;
  --border-input: #7f8a9b;
  --border-focus: #1a6aa0;
  --border-glow: #1a6aa0;

  --text-primary: #21304b;
  --text-secondary: #45536b;
  --text-muted: #5b6678;
  --text-inverse: #ffffff;

  --primary: #1a6aa0;
  --primary-hover: #155884;
  --primary-light: #e3f0f8;
  --primary-glow: transparent;

  /* Aksen tunggal dari lengkungan logo. Lime = isi (teks navy), olive = garis. */
  --accent: #c3d14f;
  --accent-line: #8a9a1c;
  --on-accent: #21304b;

  --success: #4a650d;
  --success-light: #eef4dc;
  --success-glow: transparent;
  --warning: #9a5606;
  --warning-light: #fbefdc;
  --danger: #b42318;
  --danger-light: #fde8e6;
  --danger-glow: transparent;

  /* Dipetakan ke keluarga warna logo supaya palet tetap 3 warna + 1 aksen. */
  --purple: #45536b;
  --purple-light: #eceff4;
  --cyan: #1a6aa0;
  --cyan-light: #e3f0f8;

  --shadow-sm: none;
  --shadow-md: 0 1px 2px rgba(33, 48, 75, 0.06);
  --shadow-lg: 0 12px 32px rgba(33, 48, 75, 0.18);
  --glass-blur: none;

  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --radius-full: 9999px;

  --font-main: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font-heading: 'Plus Jakarta Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --transition: 150ms ease;

  --sidebar-width: 248px;
  --topbar-height: 64px;

  color-scheme: light;
}

[data-theme="dark"] {
  --bg-primary: #131b29;
  --bg-secondary: #223047;
  --bg-card: #1a2435;
  --bg-card-hover: #1f2b3f;
  --bg-sidebar: #161f2f;
  --bg-modal: #1a2435;
  --bg-glass: #1a2435;

  --border-color: #2c3a52;
  --border-subtle: #243148;
  --border-input: #6a7b9c;
  --border-focus: #72b9e6;
  --border-glow: #72b9e6;

  --text-primary: #eef2f7;
  --text-secondary: #c2cad6;
  --text-muted: #9aa6b8;
  --text-inverse: #0f1a2b;

  --primary: #72b9e6;
  --primary-hover: #93cbee;
  --primary-light: #1f3550;

  --accent: #c3d14f;
  --accent-line: #b9c94a;
  --on-accent: #1a2435;

  --success: #a9c653;
  --success-light: #26331c;
  --warning: #eba94a;
  --warning-light: #3a2c17;
  --danger: #f29286;
  --danger-light: #3d2224;

  --purple: #c2cad6;
  --purple-light: #26334a;
  --cyan: #72b9e6;
  --cyan-light: #1f3550;

  --shadow-md: none;
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.5);

  color-scheme: dark;
}

/* ---------- Dasar ---------- */

*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-main);
  font-size: 0.9375rem;
  line-height: 1.5;
  background: var(--bg-primary);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 {
  font-family: var(--font-heading);
  font-weight: 700;
  line-height: 1.25;
  color: var(--text-primary);
}

a {
  color: var(--primary);
}

img {
  max-width: 100%;
}

button {
  font: inherit;
  color: inherit;
}

:focus-visible {
  outline: 3px solid var(--border-focus);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

.text-primary { color: var(--primary) !important; }
.text-success { color: var(--success) !important; }
.text-warning { color: var(--warning) !important; }
.text-danger { color: var(--danger) !important; }
.text-info, .text-cyan { color: var(--primary) !important; }
.muted { color: var(--text-muted); }
.ms-1 { margin-left: 4px; }
.me-1 { margin-right: 4px; }

/* ---------- Loader awal ---------- */

.app-loader {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: var(--bg-primary);
  color: var(--text-secondary);
}

/* ---------- Kerangka aplikasi ---------- */

.app-container {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-color);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.brand-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: var(--radius-md);
  background: #ffffff;
}

.brand-name {
  font-weight: 800;
  font-size: 1rem;
  line-height: 1.2;
}

.brand-info span {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.sidebar-menu {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 14px 10px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.nav-item i {
  width: 18px;
  text-align: center;
}

.nav-item:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.nav-item.active {
  background: var(--primary-light);
  color: var(--primary);
}

.nav-badge {
  margin-left: auto;
  min-width: 22px;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: var(--danger);
  color: #ffffff;
  font-size: 0.75rem;
  font-weight: 700;
  text-align: center;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-subtle);
}

.user-profile-box {
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--on-accent);
  font-weight: 800;
}

.user-meta {
  flex: 1;
  min-width: 0;
}

.user-name {
  font-weight: 700;
  font-size: 0.875rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-role-tag {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-logout-mini {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
}

.btn-logout-mini:hover {
  color: var(--danger);
  border-color: var(--danger);
}

.sidebar-scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgba(19, 27, 41, 0.45);
}

.main-wrapper {
  flex: 1;
  min-width: 0;
  margin-left: var(--sidebar-width);
  display: flex;
  flex-direction: column;
}

.top-navbar {
  position: sticky;
  top: 0;
  z-index: 30;
  min-height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 28px;
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
}

.navbar-left,
.navbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

/* Motif identitas: lengkungan zaitun dari logo di bawah judul halaman. */
.page-title {
  position: relative;
  font-size: 1.375rem;
  font-weight: 800;
  padding-bottom: 6px;
}

.page-title::after {
  content: '';
  position: absolute;
  left: 0;
  bottom: -2px;
  width: 56px;
  height: 8px;
  background: no-repeat center / 100% 100%
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 56 8'%3E%3Cpath d='M2 2 Q28 10 54 2' fill='none' stroke='%238a9a1c' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
}

[data-theme="dark"] .page-title::after {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 56 8'%3E%3Cpath d='M2 2 Q28 10 54 2' fill='none' stroke='%23b9c94a' stroke-width='3' stroke-linecap='round'/%3E%3C/svg%3E");
}

.clock-display {
  font-size: 0.875rem;
  color: var(--text-secondary);
  white-space: nowrap;
}

.btn-icon {
  flex: none;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  background: var(--bg-card);
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.btn-icon:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.menu-toggle {
  display: none;
}

.content-body {
  padding: 24px 28px 40px;
}

.tab-pane {
  display: none;
}

.tab-pane.active {
  display: block;
}

/* ---------- Layar sempit: menu jadi laci ---------- */

@media (max-width: 960px) {
  .sidebar {
    transform: translateX(-100%);
    visibility: hidden;
    transition: transform 200ms ease, visibility 0s linear 200ms;
  }

  body.menu-open .sidebar {
    transform: none;
    visibility: visible;
    transition: transform 200ms ease;
    box-shadow: var(--shadow-lg);
  }

  .main-wrapper {
    margin-left: 0;
  }

  .menu-toggle {
    display: grid;
  }

  .top-navbar {
    padding: 10px 16px;
  }

  .content-body {
    padding: 16px 16px 32px;
  }
}

@media (max-width: 560px) {
  .clock-display {
    display: none;
  }

  .page-title {
    font-size: 1.2rem;
  }
}

/* Mode demo */
.demo-banner { position: sticky; top: 0; z-index: 1000; background: #52680F; color: #FFFFFF; text-align: center; font-size: 13px; font-weight: 600; padding: 6px 16px; }
.demo-login { margin-top: 20px; display: grid; gap: 8px; }
.demo-login__title { margin: 0; font-size: 13px; color: var(--text-muted, #5B6573); }
.demo-login__btn { width: 100%; }
