/* ============================================================
   Antrian PTSP Kanwil Kemenag DIY - Gaya halaman aplikasi
   ============================================================ */
:root {
  --green: #0b7a43;
  --green-dark: #075530;
  --green-deep: #053d22;
  --green-light: #e7f4ec;
  --gold: #f2b705;
  --gold-dark: #c99600;
  --bg: #f2f5f3;
  --card: #fff;
  --text: #1f2a24;
  --muted: #6b7a72;
  --border: #e1e8e4;
  --danger: #d64545;
  --warning: #f0a020;
  --info: #2b7de9;
  --success: #1f9d55;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(16, 40, 28, .08), 0 4px 14px rgba(16, 40, 28, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
  background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5;
}
a { color: var(--green); text-decoration: none; }
a:hover { text-decoration: underline; }
code { background: #eef2ef; padding: 1px 6px; border-radius: 5px; font-size: .92em; }
h2, h3 { margin-top: 0; }
.muted { color: var(--muted); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-0 { margin-top: 0 } .mb-0 { margin-bottom: 0 }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.flex-between { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.nowrap { white-space: nowrap; }

/* ---------- Layout ---------- */
.layout { display: flex; min-height: 100vh; }
.sidebar {
  width: 250px; flex-shrink: 0; color: #fff;
  background: linear-gradient(180deg, var(--green-dark), var(--green-deep));
  position: sticky; top: 0; height: 100vh; overflow-y: auto;
  display: flex; flex-direction: column; z-index: 60;
}
.sb-brand { display: flex; gap: 12px; align-items: center; padding: 20px 18px; border-bottom: 1px solid rgba(255,255,255,.1); }
.sb-brand img, .sb-logo { width: 46px; height: 46px; border-radius: 10px; object-fit: contain; background: #fff; padding: 4px; flex-shrink: 0; }
.sb-logo { display: grid; place-items: center; color: var(--green); font-weight: 800; font-size: 12px; }
.sb-title { font-weight: 700; font-size: 16px; line-height: 1.2; }
.sb-sub { font-size: 12px; opacity: .75; }
.sb-nav { padding: 6px 10px 12px; flex: 1; }
.sb-group { font-size: 11px; text-transform: uppercase; letter-spacing: 1px; opacity: .55; padding: 16px 10px 6px; }
.sb-nav a {
  display: flex; gap: 10px; align-items: center; color: rgba(255,255,255,.9);
  padding: 9px 12px; border-radius: 9px; margin-bottom: 2px; font-size: 14.5px;
}
.sb-nav a:hover { background: rgba(255,255,255,.09); text-decoration: none; }
.sb-nav a.active { background: var(--gold); color: #3a2c00; font-weight: 600; }
.sb-nav .ic { width: 22px; text-align: center; }
.sb-foot { padding: 12px 18px; font-size: 12px; opacity: .55; border-top: 1px solid rgba(255,255,255,.1); }
.sb-backdrop { display: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar {
  background: #fff; border-bottom: 1px solid var(--border); padding: 10px 24px;
  display: flex; align-items: center; gap: 16px; position: sticky; top: 0; z-index: 40;
}
.topbar h1 { font-size: 19px; margin: 0; flex: 1; }
.topbar-clock { font-variant-numeric: tabular-nums; color: var(--muted); font-size: 14px; }
.menu-toggle { display: none; border: 0; background: var(--green-light); color: var(--green); font-size: 20px; border-radius: 8px; width: 40px; height: 40px; cursor: pointer; }
.user-box { display: flex; align-items: center; gap: 10px; }
.user-meta { display: flex; flex-direction: column; line-height: 1.2; font-size: 14px; }
.user-meta small { color: var(--muted); }
.avatar { width: 38px; height: 38px; border-radius: 50%; background: var(--green); color: #fff; display: grid; place-items: center; font-weight: 700; }
.content { padding: 24px; flex: 1; }

/* ---------- Komponen ---------- */
.card { background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow); padding: 20px; margin-bottom: 20px; border: 1px solid var(--border); }
.card-title { font-size: 16px; font-weight: 700; margin: 0 0 14px; display: flex; align-items: center; gap: 8px; justify-content: space-between; flex-wrap: wrap; }
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-side { grid-template-columns: minmax(0, 1fr) 380px; }
.grid > .card { margin-bottom: 0; }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 16px; margin-bottom: 20px; }
.stat { background: #fff; border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); border-left: 5px solid var(--green); }
.stat .lbl { font-size: 13px; color: var(--muted); font-weight: 600; }
.stat .val { font-size: 30px; font-weight: 800; line-height: 1.2; }
.stat.gold { border-color: var(--gold); } .stat.blue { border-color: var(--info); }
.stat.red { border-color: var(--danger); } .stat.gray { border-color: #9aa8a0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 9px; border: 1px solid transparent;
  font: inherit; font-weight: 600; cursor: pointer; background: #e9eeeb; color: var(--text);
  transition: filter .15s, transform .05s; text-decoration: none !important; white-space: nowrap; line-height: 1.3;
}
.btn:hover { filter: brightness(.94); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; filter: none; }
.btn-primary { background: var(--green); color: #fff; }
.btn-gold { background: var(--gold); color: #3a2c00; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-info { background: var(--info); color: #fff; }
.btn-success { background: var(--success); color: #fff; }
.btn-outline { background: #fff; border-color: #cfd9d3; }
.btn-outline-danger { background: #fff; border-color: #f0b4b4; color: var(--danger); }
.btn-sm { padding: 5px 10px; font-size: 13px; border-radius: 7px; }
.btn-lg { padding: 13px 22px; font-size: 17px; }
.btn-xl { padding: 18px 26px; font-size: 21px; border-radius: 12px; }
.btn-block { width: 100%; }

.form-group { margin-bottom: 14px; }
label { display: block; font-weight: 600; font-size: 13.5px; margin-bottom: 5px; }
.input, select.input, textarea.input {
  width: 100%; padding: 9px 12px; border: 1px solid #cfd9d3; border-radius: 9px;
  font: inherit; background: #fff; color: var(--text);
}
textarea.input { resize: vertical; min-height: 80px; }
.input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(11,122,67,.15); }
input[type=color].input { padding: 3px; height: 42px; cursor: pointer; }
.help { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.form-row { display: grid; gap: 14px; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.check { display: inline-flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--green); }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 6px; }

.table-wrap { overflow-x: auto; }
table.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th { background: #f6f9f7; text-align: left; font-size: 12px; text-transform: uppercase; letter-spacing: .4px; color: var(--muted); padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tbody tr:hover td { background: #fafcfb; }
.table .actions { display: flex; gap: 6px; flex-wrap: wrap; }
.table tfoot td { font-weight: 700; background: #f6f9f7; }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: 12px; font-weight: 600; background: #eef1ef; color: #555; white-space: nowrap; }
.badge-menunggu { background: #fff4d6; color: #8a6200; }
.badge-dipanggil { background: #dcebff; color: #1b5fc1; }
.badge-selesai { background: #dcf5e6; color: #11743c; }
.badge-dilewati { background: #fde2e2; color: #b02a2a; }
.badge-on { background: #dcf5e6; color: #11743c; }
.badge-off { background: #eceff1; color: #6b7a72; }
.badge-admin { background: #fde2e2; color: #b02a2a; }
.badge-resepsionis { background: #dcebff; color: #1b5fc1; }
.badge-petugas { background: #fff4d6; color: #8a6200; }

.kode { display: inline-grid; place-items: center; min-width: 38px; height: 38px; padding: 0 8px; border-radius: 9px; color: #fff; font-weight: 800; background: var(--c, var(--green)); }
.dot { display: inline-block; width: 16px; height: 16px; border-radius: 5px; vertical-align: middle; background: var(--c); }

.alert { padding: 12px 16px; border-radius: 10px; margin-bottom: 16px; border: 1px solid; }
.alert-success { background: #e6f6ec; border-color: #bfe5cd; color: #11603a; }
.alert-error { background: #fdeaea; border-color: #f5c2c2; color: #9b1c1c; }
.alert-info { background: #e8f1fd; border-color: #c3dafa; color: #1b4f99; }
.alert-warning { background: #fff6e0; border-color: #f5dc9c; color: #7a5600; }

kbd { background: #f3f3f3; border: 1px solid #ccc; border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; font-size: 11px; color: #333; font-family: inherit; }

.empty { text-align: center; color: var(--muted); padding: 24px 10px; }

/* ---------- Toast ---------- */
#toast-wrap { position: fixed; top: 18px; right: 18px; z-index: 9999; display: flex; flex-direction: column; gap: 10px; }
.toast { min-width: 260px; max-width: 400px; padding: 13px 18px; border-radius: 10px; color: #fff; box-shadow: 0 8px 24px rgba(0,0,0,.18); animation: toastIn .25s ease-out; font-weight: 500; }
.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-info { background: var(--info); }
.toast.out { animation: toastOut .3s forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateX(30px); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateX(30px); } }

/* ---------- Switch ---------- */
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-weight: 600; margin: 0; }
.switch input { display: none; }
.switch .slider { width: 46px; height: 26px; background: #c8d2cc; border-radius: 99px; position: relative; transition: .2s; flex-shrink: 0; }
.switch .slider::after { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + .slider { background: var(--green); }
.switch input:checked + .slider::after { left: 23px; }

/* ---------- Login / Install ---------- */
.auth-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px;
  background: radial-gradient(circle at 20% 10%, #12955a 0%, transparent 40%), radial-gradient(circle at 90% 90%, rgba(242,183,5,.35) 0%, transparent 35%), linear-gradient(135deg, var(--green-dark), var(--green-deep)); }
.auth-card { width: min(420px, 94vw); background: #fff; border-radius: 18px; padding: 32px; box-shadow: 0 20px 60px rgba(0,0,0,.3); }
.auth-brand { text-align: center; margin-bottom: 22px; }
.auth-brand h1 { font-size: 22px; margin: 10px 0 2px; }
.auth-brand p { margin: 0; color: var(--muted); font-size: 14px; }
.auth-logo { width: 72px; height: 72px; margin: 0 auto; border-radius: 50%; background: linear-gradient(135deg, var(--green), var(--green-dark)); color: var(--gold); display: grid; place-items: center; font-weight: 800; border: 3px solid var(--gold); }
.auth-logo-img { width: 80px; height: 80px; object-fit: contain; }
.auth-foot { text-align: center; margin-top: 18px; font-size: 14px; }
.check-list { list-style: none; padding: 0; margin: 0 0 18px; }
.check-list li { padding: 6px 0 6px 28px; position: relative; }
.check-list li::before { position: absolute; left: 0; font-weight: 700; }
.check-list li.ok::before { content: "✔"; color: var(--success); }
.check-list li.no::before { content: "✖"; color: var(--danger); }

/* ---------- Resepsionis ---------- */
.ticket-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 18px; }
.ticket-btn {
  position: relative; display: flex; flex-direction: column; align-items: flex-start; gap: 8px;
  padding: 22px; border: 0; border-radius: 18px; background: var(--c); color: #fff; cursor: pointer;
  text-align: left; font: inherit; min-height: 190px; overflow: hidden;
  box-shadow: 0 10px 22px -10px var(--c), inset 0 -4px 0 rgba(0,0,0,.15);
  transition: transform .12s, box-shadow .12s;
}
.ticket-btn::before { content: ""; position: absolute; right: -50px; top: -50px; width: 170px; height: 170px; border-radius: 50%; background: rgba(255,255,255,.12); }
.ticket-btn::after { content: ""; position: absolute; right: 30px; bottom: -70px; width: 140px; height: 140px; border-radius: 50%; background: rgba(255,255,255,.07); }
.ticket-btn:hover { transform: translateY(-3px); box-shadow: 0 16px 28px -12px var(--c), inset 0 -4px 0 rgba(0,0,0,.15); }
.ticket-btn:active { transform: scale(.98); }
.ticket-btn.loading { opacity: .65; pointer-events: none; }
.ticket-btn.flash { animation: btnFlash .6s; }
@keyframes btnFlash { 0% { filter: brightness(1.6); } 100% { filter: none; } }
.tb-top { display: flex; align-items: center; gap: 14px; position: relative; z-index: 1; }
.tb-kode { font-size: 40px; font-weight: 900; line-height: 1; background: rgba(255,255,255,.22); border-radius: 14px; padding: 8px 16px; }
.tb-nama { font-size: 21px; font-weight: 800; line-height: 1.2; }
.tb-layanan { font-size: 14px; opacity: .95; flex: 1; position: relative; z-index: 1; }
.tb-stat { display: flex; gap: 14px; font-size: 13px; background: rgba(0,0,0,.2); padding: 6px 12px; border-radius: 8px; position: relative; z-index: 1; }
.tb-stat b { font-size: 15px; }
.tb-key { position: absolute; right: 14px; bottom: 14px; font-size: 12px; background: rgba(255,255,255,.25); padding: 2px 8px; border-radius: 6px; z-index: 1; }
.tb-hint { position: absolute; right: 14px; top: 14px; font-size: 12px; opacity: .9; z-index: 1; }

.last-ticket { text-align: center; border-top: 6px solid var(--c, var(--green)); }
.lt-label { font-size: 13px; letter-spacing: 2px; color: var(--muted); font-weight: 700; }
.lt-nomor { font-size: 72px; font-weight: 900; color: var(--c, var(--green)); line-height: 1.05; font-variant-numeric: tabular-nums; }
.lt-loket { font-size: 18px; font-weight: 700; }
.lt-meta { color: var(--muted); font-size: 14px; margin-bottom: 12px; }
.print-frame { position: fixed; right: 0; bottom: 0; width: 0; height: 0; border: 0; }

/* ---------- Petugas ---------- */
.petugas-head { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.petugas-head .kode { min-width: 64px; height: 64px; font-size: 30px; border-radius: 14px; }
.petugas-head h2 { margin: 0; font-size: 24px; }
.petugas-head p { margin: 0; color: var(--muted); }
.petugas-head .ph-right { margin-left: auto; display: flex; gap: 10px; align-items: center; }
.serving { text-align: center; background: linear-gradient(135deg, var(--green), var(--green-deep)); color: #fff; border: 0; position: relative; overflow: hidden; }
.serving::before { content: ""; position: absolute; right: -80px; top: -80px; width: 260px; height: 260px; border-radius: 50%; background: rgba(255,255,255,.06); }
.serving-label { letter-spacing: 4px; font-size: 14px; opacity: .85; font-weight: 700; }
.serving-nomor { font-size: 120px; font-weight: 900; line-height: 1; margin: 10px 0 6px; color: var(--gold); text-shadow: 0 5px 0 rgba(0,0,0,.18); font-variant-numeric: tabular-nums; }
.serving-info { opacity: .9; margin-bottom: 20px; min-height: 24px; }
.serving .btn-xl { position: relative; }
.action-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 12px; }
.action-row .btn { padding: 13px 10px; font-size: 15.5px; }
.serving .btn-light { background: rgba(255,255,255,.14); color: #fff; border: 1px solid rgba(255,255,255,.25); }
.serving .btn-gold { box-shadow: 0 6px 0 var(--gold-dark); }
.serving .btn-gold:active { box-shadow: 0 2px 0 var(--gold-dark); transform: translateY(4px); }
.sisa-box { text-align: center; background: linear-gradient(135deg, #fff8e1, #ffefb8); border: 1px solid #f5dc9c; }
.sisa-box .val { font-size: 76px; font-weight: 900; color: #8a6200; line-height: 1.05; }
.sisa-box .lbl { font-weight: 700; letter-spacing: 2px; color: #8a6200; }
.mini-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 14px; }
.mini-stats div { background: #fff; border-radius: 10px; padding: 8px; }
.mini-stats b { display: block; font-size: 22px; color: var(--text); }
.mini-stats small { color: var(--muted); font-weight: 600; }
.queue-list { display: flex; flex-wrap: wrap; gap: 8px; max-height: 380px; overflow: auto; }
.q-item { display: flex; align-items: center; gap: 10px; border: 1px solid var(--border); border-radius: 10px; padding: 6px 6px 6px 12px; background: #fafcfb; }
.q-item b { font-size: 17px; font-variant-numeric: tabular-nums; }
.q-item small { color: var(--muted); }
.q-item.first { border-color: var(--gold); background: #fffbea; }
.shortcut-help { font-size: 13px; color: var(--muted); margin-top: 10px; }
.serving .shortcut-help { color: rgba(255,255,255,.75); }
.serving .shortcut-help kbd { background: rgba(255,255,255,.15); color: #fff; border-color: rgba(255,255,255,.3); }

.loket-pick { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 16px; }
.loket-pick a { display: flex; gap: 14px; align-items: center; padding: 18px; border-radius: 14px; background: #fff; border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text); }
.loket-pick a:hover { border-color: var(--c); text-decoration: none; transform: translateY(-2px); }

/* ---------- Video & laporan ---------- */
.video-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }
.video-item { background: #fff; border: 1px solid var(--border); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); }
.video-item video { width: 100%; aspect-ratio: 16/9; background: #000; display: block; }
.video-item .vi-body { padding: 14px; }
.video-item.off { opacity: .6; }
.progress { height: 10px; background: #e6ece8; border-radius: 99px; overflow: hidden; margin-top: 10px; display: none; }
.progress > div { height: 100%; width: 0; background: var(--green); transition: width .2s; }
.bar-chart { display: flex; flex-direction: column; gap: 6px; }
.bar-row { display: grid; grid-template-columns: 120px 1fr 50px; gap: 10px; align-items: center; font-size: 13px; }
.bar-track { background: #eef2ef; border-radius: 6px; height: 18px; overflow: hidden; }
.bar-fill { height: 100%; background: linear-gradient(90deg, var(--green), #19a463); border-radius: 6px; }
.logo-preview { width: 90px; height: 90px; object-fit: contain; border: 1px dashed #cfd9d3; border-radius: 10px; padding: 6px; background: #fff; }

/* ---------- Responsif ---------- */
@media (max-width: 1100px) {
  .grid-side { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .sidebar { position: fixed; left: -260px; transition: left .2s; }
  .sidebar.open { left: 0; }
  .sb-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 55; }
  .menu-toggle { display: inline-grid; place-items: center; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .content { padding: 16px; }
  .topbar-clock, .user-meta { display: none; }
  .serving-nomor { font-size: 88px; }
}

/* ---------- Cetak (laporan) ---------- */
@media print {
  .sidebar, .topbar, .no-print, #toast-wrap { display: none !important; }
  .content { padding: 0; }
  .card { box-shadow: none; border: 0; padding: 0; }
  body { background: #fff; font-size: 12px; }
  .print-only { display: block !important; }
}
.print-only { display: none; }
