/* =========================================================
   PRAMUKA AL HIKMAH — Fresh UI
   Tema merah maroon Bulan Bahasa · Sidebar desktop · Bottom nav mobile
   ========================================================= */
:root {
  --primary: #800020;
  --primary-dark: #590018;
  --primary-light: #a32949;
  --gold: #b54860;
  --cream: #fff7f9;
  --beige: #f2d8df;
  --success: #2E7D32;
  --danger: #C62828;
  --warning: #EF6C00;
  --text: #590018;
  --text-light: #865767;
  --white: #ffffff;
  --radius: 14px;
  --radius-full: 999px;
  --shadow: 0 4px 16px rgba(62, 39, 35, 0.12);
  --sidebar-w: 260px;
  --header-h: 64px;
  --nav-h: 68px;
  --font: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

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

html, body {
  font-family: var(--font);
  color: var(--text);
  background: var(--cream);
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
}

#app { min-height: 100vh; }

/* Screens */
.screen { display: none; min-height: 100vh; }
.screen.active { display: block; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 10px 16px; border: none; border-radius: 12px;
  font-family: inherit; font-size: 0.9rem; font-weight: 600;
  cursor: pointer; transition: transform .12s, box-shadow .12s, background .12s;
}
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--beige); color: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; border-radius: 10px; }
.btn-block { width: 100%; }
.btn-icon {
  background: transparent; border: none; color: inherit;
  width: 40px; height: 40px; border-radius: 50%; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: rgba(255,255,255,0.15); }

/* ---------- Cards & layout bits ---------- */
.card {
  background: var(--white);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
  margin-bottom: 14px;
}
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; margin-bottom: 12px; flex-wrap: wrap;
}
.card-header h3 { font-size: 1rem; color: var(--primary-dark); }
.page-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 10px; flex-wrap: wrap; margin-bottom: 16px;
}
.page-header h2 {
  font-size: 1.25rem; color: var(--primary-dark);
  display: flex; align-items: center; gap: 10px;
}
.page-header .actions { display: flex; flex-wrap: wrap; gap: 8px; }

.form-group { margin-bottom: 14px; }
.form-group label {
  display: block; font-size: 0.85rem; font-weight: 500;
  margin-bottom: 6px; color: var(--text);
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--beige);
  border-radius: 10px; font-family: inherit; font-size: 0.9rem;
  background: #fff; color: var(--text);
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
  outline: none; border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(93,64,55,0.12);
}

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: 0.7rem; font-weight: 600;
}
.badge-regu { background: #E3F2FD; color: #1565C0; }
.badge-barung { background: #FFF3E0; color: #E65100; }
.badge-siaga { background: #E8F5E9; color: #2E7D32; }
.badge-penggalang { background: #FFEBEE; color: #C62828; }
.badge-hadir { background: #E8F5E9; color: #2E7D32; }
.badge-alpha { background: #FFEBEE; color: #C62828; }

.empty-state {
  text-align: center; padding: 32px 16px; color: var(--text-light);
}
.empty-state i { font-size: 2rem; margin-bottom: 10px; opacity: 0.5; }

.search-box {
  display: flex; align-items: center; gap: 10px;
  background: #fff; border-radius: 12px; padding: 10px 14px;
  margin-bottom: 12px; box-shadow: var(--shadow);
}
.search-box input {
  flex: 1; border: none; outline: none; font-family: inherit; font-size: 0.9rem;
  background: transparent;
}
.search-box i { color: var(--primary-light); }

.tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.tab-btn {
  padding: 8px 14px; border: none; border-radius: 999px;
  background: var(--beige); color: var(--primary-dark);
  font-family: inherit; font-size: 0.82rem; font-weight: 600; cursor: pointer;
}
.tab-btn.active { background: var(--primary); color: #fff; }

/* Stats */
.stats-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-bottom: 16px;
}
@media (min-width: 700px) {
  .stats-grid { grid-template-columns: repeat(4, 1fr); }
}
.stat-card, button.stat-card {
  background: #fff; border-radius: var(--radius); padding: 16px;
  border: none; border-left: 4px solid var(--primary);
  box-shadow: var(--shadow); text-align: left; cursor: pointer;
  font-family: inherit; width: 100%;
  transition: transform .12s, box-shadow .12s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: 0 6px 18px rgba(0,0,0,0.12); }
.stat-card.gold { border-left-color: var(--gold); }
.stat-card.success { border-left-color: var(--success); }
.stat-card.warning { border-left-color: var(--warning); }
.stat-card .number, .stat-card .number {
  font-size: 1.6rem; font-weight: 700; color: var(--primary-dark); line-height: 1.2;
}
.stat-card .label { font-size: 0.78rem; color: var(--text-light); margin-top: 4px; }

/* Tables */
.table-wrapper { width: 100%; overflow-x: auto; }
table {
  width: 100%; border-collapse: collapse; table-layout: fixed;
}
th, td {
  padding: 10px 8px; text-align: left; vertical-align: top;
  font-size: 0.85rem; word-break: break-word;
  border-bottom: 1px solid #f5e2e8;
}
th {
  background: var(--cream); color: var(--primary-dark);
  font-weight: 600; font-size: 0.78rem;
}
.col-peserta-info .ps-nama { font-weight: 600; font-size: 0.88rem; }
.col-peserta-info .ps-meta { font-size: 0.72rem; color: var(--text-light); margin-top: 2px; }

/* Mapping list */
.mapping-list { display: flex; flex-direction: column; gap: 10px; }
.mapping-item, button.mapping-item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--cream); border-radius: 12px;
  border: none; border-left: 4px solid var(--gold);
  font-family: inherit; text-align: left; cursor: pointer; width: 100%;
  color: var(--text);
}
.mapping-item:hover, button.mapping-item:hover { background: #f9e9ee; }
.mapping-item-active { outline: 2px solid var(--primary); background: #fff !important; }
.mapping-item .avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-weight: 700;
  flex-shrink: 0;
}
.mapping-item .info { flex: 1; min-width: 0; }
.mapping-item .info strong { display: block; font-size: 0.95rem; }
.mapping-item .info span { font-size: 0.78rem; color: var(--text-light); }

/* Modal */
.modal-overlay {
  display: none; position: fixed; inset: 0; z-index: 2000;
  background: rgba(0,0,0,0.45); align-items: center; justify-content: center;
  padding: 16px;
}
.modal-overlay.active { display: flex; }
.modal {
  background: #fff; border-radius: var(--radius); width: 100%; max-width: 480px;
  max-height: 90vh; overflow-y: auto; box-shadow: 0 12px 40px rgba(0,0,0,0.25);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; background: var(--primary); color: #fff;
  border-radius: var(--radius) var(--radius) 0 0;
}
.modal-body { padding: 16px; }

/* Toast */
.toast {
  position: fixed; top: 20px; left: 50%; z-index: 3000;
  transform: translateX(-50%) translateY(-120px);
  background: var(--primary-dark); color: #fff;
  padding: 12px 22px; border-radius: var(--radius-full);
  font-size: 0.9rem; box-shadow: var(--shadow);
  transition: transform .25s; max-width: 90vw;
}
.toast.show { transform: translateX(-50%) translateY(0); }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }

/* Role */
.role-badge {
  display: inline-block; font-size: 0.65rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.03em;
  background: rgba(255,255,255,0.2); padding: 2px 8px; border-radius: 999px;
}
.role-hidden { display: none !important; }

/* Absensi */
.absensi-list { display: flex; flex-direction: column; gap: 8px; }
.absensi-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 12px; background: var(--cream); border-radius: 12px;
}
.absensi-item .nama { font-weight: 600; font-size: 0.9rem; }
.absensi-item .kelas { font-size: 0.75rem; color: var(--text-light); }
.status-btns { display: flex; gap: 6px; }
.status-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 2px solid var(--beige);
  background: #fff; font-weight: 700; cursor: pointer; font-family: inherit;
}
.status-btn.active-hadir { background: var(--success); color: #fff; border-color: var(--success); }
.status-btn.active-izin { background: var(--warning); color: #fff; border-color: var(--warning); }
.status-btn.active-alpha { background: var(--danger); color: #fff; border-color: var(--danger); }

.rundown-ongoing { background: #E8F5E9 !important; }
.rd-waktu { font-size: 0.8rem; color: var(--text-light); }
.rd-kegiatan { font-size: 0.9rem; }

/* ========== LANDING ========== */
.landing-wrap {
  max-width: 720px; margin: 0 auto; padding: 28px 16px 100px;
}
.landing-hero { text-align: center; margin-bottom: 24px; }
.landing-logo { width: 88px; height: 88px; object-fit: contain; margin-bottom: 12px; }
.landing-hero h1 { font-size: 1.5rem; color: var(--primary-dark); }
.landing-hero p { color: var(--text-light); font-size: 0.9rem; margin-top: 4px; }
.landing-stats {
  display: flex !important; flex-direction: row !important; flex-wrap: nowrap !important;
  gap: 10px; margin-bottom: 18px;
}
.landing-stat-card {
  flex: 1 1 0; min-width: 0; text-align: center;
  background: #fff; border-radius: 12px; padding: 14px 8px;
  border-top: 4px solid var(--primary); box-shadow: var(--shadow);
}
.landing-stat-card.siaga { border-top-color: var(--success); }
.landing-stat-card.penggalang { border-top-color: var(--danger); }
.landing-stat-card.pembina { border-top-color: var(--gold); }
.landing-stat-card .num {
  font-size: clamp(1.2rem, 4vw, 1.9rem); font-weight: 700; color: var(--primary-dark);
}
.landing-stat-card .lbl {
  font-size: clamp(0.62rem, 2vw, 0.8rem); color: var(--text-light); margin-top: 4px;
}
.landing-izin-cta { margin: 16px 0; }

/* ========== LOGIN ========== */
.login-container {
  max-width: 420px; margin: 0 auto; padding: 48px 24px;
  min-height: 100vh; display: flex; flex-direction: column; justify-content: center;
}
.login-header { text-align: center; margin-bottom: 28px; }
.login-logo { width: 80px; height: 80px; object-fit: contain; margin-bottom: 12px; }
.login-header h1 { font-size: 1.4rem; color: var(--primary-dark); }
.login-header p { color: var(--text-light); font-size: 0.9rem; }
.login-form {
  background: #fff; padding: 24px; border-radius: var(--radius); box-shadow: var(--shadow);
}
.login-hint { text-align: center; font-size: 0.8rem; color: var(--text-light); margin-top: 16px; }

/* ========== MAIN APP SHELL ========== */
#main-app.screen.active { display: block; }

.app-shell { min-height: 100vh; }

.app-header {
  background: #590018;
  color: #fff; padding: 12px 16px;
  display: flex; align-items: center; justify-content: space-between;
  position: sticky; top: 0; z-index: 50; box-shadow: 0 2px 10px rgba(0,0,0,0.15);
}
.header-left { display: flex; align-items: center; gap: 12px; }
.header-logo { width: 40px; height: 40px; object-fit: contain; }
.header-left h2 { font-size: 1rem; font-weight: 600; }
#btn-logout { color: #fff; }

.content-area {
  padding: 16px;
  padding-bottom: calc(var(--nav-h) + 24px);
  max-width: 100%;
  width: 100%;
  margin: 0 auto;
}

/* ========== SIDEBAR (desktop only) ========== */
.sidebar { display: none; }

/* ========== BOTTOM NAV (mobile) — full rounded ========== */
.bottom-nav {
  position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  height: var(--nav-h); background: rgba(255, 252, 248, .97);
  border: 1px solid #f2d8df; border-radius: 24px;
  display: flex; align-items: center; justify-content: space-around; gap: 4px; padding: 7px;
  z-index: 200; box-shadow: 0 10px 32px rgba(78,55,40,.18); backdrop-filter: blur(16px);
}
.bottom-nav .nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; height: 100%; border: none; background: transparent; color: #865767;
  font-family: inherit; font-size: .64rem; font-weight: 600; cursor: pointer; border-radius: 18px;
  text-decoration: none; min-width: 0; padding: 6px 4px; -webkit-tap-highlight-color: transparent;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease;
}
.bottom-nav .nav-item i { font-size: 1.15rem; }
.bottom-nav .nav-item:hover { color: #590018; background: #fbeef2; }
.bottom-nav .nav-item.active { color: #fff; background: #590018; box-shadow: 0 3px 10px rgba(62,39,35,.24); }
.bottom-nav .nav-item:focus-visible { outline: 2px solid #800020; outline-offset: 2px; }
.bottom-nav.public-nav { max-width: 420px; margin: 0 auto; left: 50%; right: auto; transform: translateX(-50%); width: calc(100% - 24px); }

/* More menu */
.more-menu-overlay {
  display: none; position: fixed; inset: 0; z-index: 300;
  background: rgba(0,0,0,0.45); align-items: flex-end; justify-content: center;
}
.more-menu-overlay.active { display: flex; }
.more-menu-overlay[hidden] { display: none !important; }
.more-menu-sheet {
  width: 100%; max-width: 480px; background: #fff;
  border-radius: 24px 24px 0 0; padding: 12px 16px 28px;
  display: flex; flex-direction: column;
  box-shadow: 0 -8px 32px rgba(0,0,0,0.2);
}
.more-menu-handle {
  width: 40px; height: 4px; background: #ddd; border-radius: 4px; margin: 4px auto 10px;
}
.more-menu-title { font-weight: 700; font-size: 1rem; margin-bottom: 10px; color: var(--primary-dark); }
.more-menu-list { display: flex; flex-direction: column; gap: 4px; }
.more-menu-item {
  display: flex; align-items: center; gap: 14px; width: 100%;
  padding: 14px 12px; border: none; background: transparent; border-radius: 12px;
  font-family: inherit; font-size: 0.95rem; font-weight: 500; color: var(--text);
  cursor: pointer; text-align: left;
}
.more-menu-item i {
  width: 36px; height: 36px; border-radius: 10px; background: var(--beige);
  color: var(--primary); display: flex; align-items: center; justify-content: center;
}
.more-menu-item:hover { background: var(--cream); }
.more-menu-close {
  margin-top: 12px; width: 100%; padding: 12px; border: none; border-radius: 12px;
  background: var(--beige); color: var(--primary-dark); font-family: inherit;
  font-weight: 600; cursor: pointer;
}

/* ========== DESKTOP ≥ 768px ========== */
@media (min-width: 768px) {
  .bottom-nav:not(.public-nav),
  #more-menu-overlay {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }

  html.desktop-app, html.desktop-app body {
    height: 100%; overflow: hidden;
  }
  html.desktop-app #app,
  html.desktop-app #main-app.screen.active {
    height: 100%; overflow: hidden;
  }
  html.desktop-app #main-app .app-shell {
    display: block; height: 100%; overflow: hidden; position: relative;
  }

  .sidebar {
    display: flex !important;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    height: 100vh; height: 100dvh;
    background: #590018;
    color: #fff;
    z-index: 100;
    box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    overflow: hidden;
  }
  .sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.12);
    flex-shrink: 0;
  }
  .sidebar-logo { width: 44px; height: 44px; object-fit: contain; }
  .sidebar-title { font-weight: 600; font-size: 0.95rem; line-height: 1.25; }
  .sidebar-brand .role-badge { margin-top: 4px; background: rgba(255,255,255,0.2); }

  .sidebar-nav {
    flex: 1; min-height: 0; overflow-y: auto;
    padding: 12px 10px; display: flex; flex-direction: column; gap: 4px;
  }
  .sidebar-item {
    display: flex; align-items: center; gap: 12px; width: 100%;
    padding: 12px 14px; border: none; border-radius: 12px;
    background: transparent; color: rgba(255,255,255,0.78);
    font-family: inherit; font-size: 0.9rem; font-weight: 500;
    text-align: left; cursor: pointer; transition: background .15s, color .15s;
  }
  .sidebar-item i { width: 22px; text-align: center; font-size: 1.05rem; }
  .sidebar-item:hover { background: rgba(255,255,255,0.1); color: #fff; }
  .sidebar-item.active {
    background: rgba(255,255,255,0.2); color: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  }
  .sidebar-item.logout { color: rgba(255,180,180,0.95); }
  .sidebar-item.logout:hover { background: rgba(198,40,40,0.35); color: #fff; }
  .sidebar-footer {
    flex-shrink: 0; padding: 10px;
    border-top: 1px solid rgba(255,255,255,0.12);
  }

  html.desktop-app .app-main {
    margin-left: var(--sidebar-w);
    width: calc(100% - var(--sidebar-w));
    height: 100vh; height: 100dvh;
    display: flex; flex-direction: column; overflow: hidden;
  }
  html.desktop-app .app-header {
    flex-shrink: 0; position: relative;
  }
  html.desktop-app .app-header .header-logo { display: none; }
  html.desktop-app .content-area {
    flex: 1; min-height: 0; overflow-y: auto;
    padding: 24px 28px 32px;
    max-width: 100%;
    width: 100%;
  }
  html.desktop-app .app-main {
    max-width: 100%;
  }
  /* Tables & grids expand on desktop */
  html.desktop-app .card { max-width: 100%; }
  html.desktop-app .data-table-wrap,
  html.desktop-app .table-responsive {
    width: 100%;
    overflow-x: auto;
  }
  html.desktop-app .stats-grid,
  html.desktop-app .grid-cards {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }
}

/* Welcome overlay */
.welcome-overlay {
  position: fixed; inset: 0; z-index: 99999;
  background: rgba(62,39,35,0.55);
  display: flex; align-items: center; justify-content: center; padding: 20px;
}
.welcome-card {
  background: #fff; border-radius: 20px; padding: 28px 24px;
  max-width: 360px; width: 100%; text-align: center;
  box-shadow: 0 16px 48px rgba(0,0,0,0.25);
}
.welcome-card h2 { color: var(--primary-dark); font-size: 1.2rem; margin-bottom: 8px; }
.welcome-card p { color: var(--text-light); font-size: 0.9rem; margin-bottom: 8px; }
.welcome-card .quote {
  font-style: italic; color: var(--primary); font-size: 0.85rem;
  margin: 14px 0 20px; padding: 12px; background: var(--cream); border-radius: 12px;
}


/* Dropdown Kelompok */
.form-select-regu:focus {
  outline: none;
  border-color: var(--primary-light) !important;
  box-shadow: 0 0 0 3px rgba(141, 110, 99, 0.2);
}

/* Unified maroon page headers. */
.landing-hero { background: #590018; color: #fff; padding: 24px 18px; border-radius: 22px; }
.landing-hero h1, .landing-hero p { color: #fff; }

/* Bulan Bahasa: konten memenuhi lebar monitor pada semua halaman */
html,body,#app,.app-main{max-width:100%;min-width:0}
.landing-wrap{width:100%;max-width:none;margin-inline:0;box-sizing:border-box;padding-inline:clamp(16px,2.5vw,36px)}
.content-area{width:100%;max-width:none;min-width:0;box-sizing:border-box;padding-inline:clamp(16px,2.5vw,36px)}
.content-area > *, .landing-wrap > *{max-width:100%;min-width:0}
@media(min-width:768px){html.desktop-app .content-area{padding-inline:clamp(20px,2.5vw,44px)}}

/* Pengaturan menu responsif */
.bb-nav-editor-row{display:grid;grid-template-columns:minmax(130px,2fr) minmax(100px,1.2fr) minmax(130px,1.4fr) minmax(140px,1.5fr) repeat(3,auto);gap:8px;align-items:center;margin:9px 0;padding:9px;border:1px solid #ead7dc;border-radius:12px;background:#fff}
.bb-nav-editor-row input,.bb-nav-editor-row select{width:100%;min-width:0;padding:9px;border:1px solid #d7b8c1;border-radius:9px;background:white;color:#590018}
.bb-nav-editor-actions{display:flex;flex-wrap:wrap;gap:10px;margin-top:14px}
@media(max-width:800px){.bb-nav-editor-row{grid-template-columns:repeat(3,minmax(0,1fr))}.bb-nav-editor-row input,.bb-nav-editor-row select{grid-column:span 3}}
