/* =========================================================
   STYLE UTAMA
   Sistem Antrian Pengadilan Agama Kalianda Kelas IB
   ========================================================= */

:root {
  --hijau-tua: #1a5632;
  --hijau-tua-dark: #103d22;
  --hijau-muda: #2d8049;
  --emas: #b8860b;
  --emas-terang: #d4a017;
  --biru: #1e3a8a;
  --merah: #9b1c1c;
  --abu-gelap: #2b2f36;
  --abu: #6b7280;
  --abu-muda: #f3f4f6;
  --putih: #ffffff;
  --border: #e2e5ea;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 2px 10px rgba(16, 24, 40, 0.08);
  --shadow-lg: 0 10px 30px rgba(16, 24, 40, 0.15);
  --font-main: 'Segoe UI', 'Poppins', Arial, sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-main);
  background: var(--abu-muda);
  color: var(--abu-gelap);
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
ul { margin: 0; padding: 0; }

/* ===================== LAYOUT UMUM ===================== */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.page-body {
  padding: 24px 28px 60px;
  flex: 1;
}

.container-narrow {
  max-width: 1100px;
  margin: 0 auto;
}

/* ===================== TOPBAR INSTANSI (Header umum) ===================== */
.topbar-instansi {
  background: linear-gradient(135deg, var(--hijau-tua) 0%, var(--hijau-tua-dark) 100%);
  color: var(--putih);
  padding: 14px 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-shadow: var(--shadow);
}

.topbar-instansi .brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.topbar-instansi .brand img {
  width: 46px;
  height: 46px;
  object-fit: contain;
  background: var(--putih);
  border-radius: 50%;
  padding: 4px;
}

.topbar-instansi .brand-text h1 {
  font-size: 16px;
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.topbar-instansi .brand-text p {
  margin: 2px 0 0;
  font-size: 12px;
  opacity: 0.85;
}

.topbar-instansi .clock {
  text-align: right;
  font-size: 13px;
  opacity: 0.9;
}

.topbar-instansi .clock #live-clock {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 1px;
}

/* ===================== SIDEBAR ADMIN ===================== */
.sidebar {
  width: 250px;
  background: var(--hijau-tua-dark);
  color: var(--putih);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar .sidebar-header {
  padding: 22px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar .sidebar-header img {
  width: 38px;
  height: 38px;
  background: var(--putih);
  border-radius: 50%;
  padding: 3px;
}

.sidebar .sidebar-header .title {
  font-size: 13px;
  font-weight: 700;
  line-height: 1.3;
}

.sidebar .sidebar-header .subtitle {
  font-size: 11px;
  opacity: 0.7;
}

.sidebar nav {
  padding: 14px 10px;
  flex: 1;
}

.sidebar nav .nav-section-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  opacity: 0.55;
  padding: 14px 12px 6px;
}

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: rgba(255,255,255,0.85);
  margin-bottom: 2px;
  transition: background 0.15s ease;
}

.sidebar nav a:hover {
  background: rgba(255,255,255,0.08);
  color: var(--putih);
}

.sidebar nav a.active {
  background: var(--emas);
  color: var(--hijau-tua-dark);
  font-weight: 600;
}

.sidebar nav a .icon {
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.sidebar .sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 12px;
}

.sidebar .user-chip {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.sidebar .user-chip .avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--emas);
  color: var(--hijau-tua-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 14px;
  flex-shrink: 0;
}

.sidebar .user-chip .meta .name {
  font-weight: 600;
  font-size: 13px;
}
.sidebar .user-chip .meta .role {
  font-size: 11px;
  opacity: 0.7;
  text-transform: capitalize;
}

.btn-logout-sidebar {
  display: block;
  text-align: center;
  background: rgba(155, 28, 28, 0.85);
  color: var(--putih);
  padding: 9px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 600;
}
.btn-logout-sidebar:hover { background: var(--merah); }

/* Topbar dalam halaman admin (judul halaman + breadcrumb) */
.page-topbar {
  background: var(--putih);
  padding: 18px 28px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 20;
}
.page-topbar h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
}
.page-topbar .breadcrumb {
  font-size: 12px;
  color: var(--abu);
  margin-top: 3px;
}

/* Mobile menu toggle */
.mobile-menu-toggle {
  display: none;
  background: var(--hijau-tua);
  color: var(--putih);
  border: none;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  font-size: 18px;
  cursor: pointer;
}

/* ===================== CARDS & WIDGETS ===================== */
.stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px;
  margin-bottom: 24px;
}

.stat-card {
  background: var(--putih);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
  border-left: 5px solid var(--hijau-tua);
  display: flex;
  align-items: center;
  gap: 16px;
}

.stat-card .stat-icon {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  background: var(--abu-muda);
}

.stat-card .stat-value {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.1;
}

.stat-card .stat-label {
  font-size: 12.5px;
  color: var(--abu);
  margin-top: 2px;
}

.card {
  background: var(--putih);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 22px;
  margin-bottom: 22px;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.card-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
}

/* ===================== TABEL ===================== */
.table-wrap { overflow-x: auto; }

table.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}

table.tbl th {
  background: var(--abu-muda);
  text-align: left;
  padding: 11px 14px;
  font-weight: 700;
  color: var(--abu-gelap);
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

table.tbl td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

table.tbl tbody tr:hover { background: #fafbfc; }

.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 700;
  text-transform: capitalize;
}
.badge-menunggu { background: #fef3c7; color: #92400e; }
.badge-dipanggil { background: #dbeafe; color: #1e40af; }
.badge-dilayani { background: #d1fae5; color: #065f46; }
.badge-selesai { background: #e5e7eb; color: #374151; }
.badge-dilewati { background: #fee2e2; color: #991b1b; }
.badge-batal { background: #f3f4f6; color: #6b7280; }

.badge-status-loket-buka { background: #d1fae5; color: #065f46; }
.badge-status-loket-tutup { background: #fee2e2; color: #991b1b; }
.badge-status-loket-sibuk { background: #fef3c7; color: #92400e; }
.badge-status-loket-istirahat { background: #e0e7ff; color: #3730a3; }

/* ===================== FORM ===================== */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--abu-gelap);
}
.form-control {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
}
.form-control:focus {
  outline: none;
  border-color: var(--hijau-tua);
}
textarea.form-control { resize: vertical; min-height: 90px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.form-help { font-size: 12px; color: var(--abu); margin-top: 4px; }

/* ===================== BUTTON ===================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: var(--radius-sm);
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
}
.btn-primary { background: var(--hijau-tua); color: var(--putih); }
.btn-primary:hover { background: var(--hijau-tua-dark); }
.btn-warning { background: var(--emas); color: var(--putih); }
.btn-warning:hover { background: #9c6f08; }
.btn-danger { background: var(--merah); color: var(--putih); }
.btn-danger:hover { background: #7a1616; }
.btn-secondary { background: var(--abu-muda); color: var(--abu-gelap); }
.btn-secondary:hover { background: #e5e7eb; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--abu-gelap); }
.btn-outline:hover { background: var(--abu-muda); }
.btn-sm { padding: 6px 12px; font-size: 12.5px; }
.btn-lg { padding: 15px 28px; font-size: 16px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ===================== ALERT ===================== */
.alert {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.alert-success { background: #d1fae5; color: #065f46; }
.alert-danger { background: #fee2e2; color: #991b1b; }
.alert-warning { background: #fef3c7; color: #92400e; }
.alert-info { background: #dbeafe; color: #1e40af; }

/* ===================== LOGIN PAGE ===================== */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--hijau-tua) 0%, var(--hijau-tua-dark) 55%, #0a2615 100%);
  padding: 20px;
  position: relative;
  overflow: hidden;
}
.login-page::before {
  content: '';
  position: absolute;
  width: 600px; height: 600px;
  background: radial-gradient(circle, rgba(212,160,23,0.12) 0%, transparent 70%);
  top: -200px; right: -200px;
}
.login-box {
  background: var(--putih);
  border-radius: 18px;
  padding: 42px 38px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 2;
}
.login-box .logo-wrap {
  text-align: center;
  margin-bottom: 18px;
}
.login-box .logo-wrap img {
  width: 72px;
  height: 72px;
  object-fit: contain;
}
.login-box h1 {
  text-align: center;
  font-size: 17px;
  margin: 0 0 4px;
  color: var(--hijau-tua-dark);
  line-height: 1.4;
}
.login-box .subtitle {
  text-align: center;
  font-size: 12.5px;
  color: var(--abu);
  margin-bottom: 26px;
}
.login-footer-note {
  text-align: center;
  margin-top: 22px;
  font-size: 11.5px;
  color: rgba(255,255,255,0.65);
  position: relative;
  z-index: 2;
}

/* ===================== KIOSK ===================== */
.kiosk-page {
  min-height: 100vh;
  background: linear-gradient(160deg, var(--hijau-tua) 0%, var(--hijau-tua-dark) 100%);
  display: flex;
  flex-direction: column;
}
.kiosk-header {
  text-align: center;
  padding: 28px 20px 18px;
  color: var(--putih);
}
.kiosk-header img {
  width: 64px; height: 64px;
  background: var(--putih);
  border-radius: 50%;
  padding: 6px;
  margin-bottom: 10px;
}
.kiosk-header h1 { margin: 0; font-size: 22px; }
.kiosk-header p { margin: 4px 0 0; font-size: 13px; opacity: 0.85; }

.kiosk-body {
  flex: 1;
  background: var(--abu-muda);
  border-radius: 28px 28px 0 0;
  padding: 36px 24px 50px;
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
}

.kiosk-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 22px;
  margin-top: 10px;
}

.kiosk-category-btn {
  background: var(--putih);
  border-radius: 18px;
  padding: 30px 20px;
  text-align: center;
  box-shadow: var(--shadow);
  cursor: pointer;
  border: 3px solid transparent;
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
.kiosk-category-btn:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.kiosk-category-btn .icon-circle {
  width: 76px; height: 76px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto 16px;
  font-size: 32px;
  color: var(--putih);
}
.kiosk-category-btn h3 { margin: 0 0 6px; font-size: 16px; }
.kiosk-category-btn p { margin: 0; font-size: 12.5px; color: var(--abu); }

.kiosk-priority-btn .icon-circle { background: var(--merah); }

.kiosk-success-box {
  text-align: center;
  background: var(--putih);
  border-radius: 22px;
  padding: 50px 30px;
  box-shadow: var(--shadow-lg);
}
.kiosk-success-box .nomor-tiket {
  font-size: 84px;
  font-weight: 900;
  color: var(--hijau-tua);
  letter-spacing: 3px;
  margin: 14px 0;
}
.kiosk-success-box .label-tiket {
  font-size: 13px;
  color: var(--abu);
  text-transform: uppercase;
  letter-spacing: 1.5px;
}

/* ===================== TV DISPLAY ===================== */
.tv-page {
  min-height: 100vh;
  background: #0a1f12;
  color: var(--putih);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.tv-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 36px;
  background: linear-gradient(90deg, var(--hijau-tua-dark), var(--hijau-tua));
  border-bottom: 4px solid var(--emas);
}
.tv-header .brand { display: flex; align-items: center; gap: 16px; }
.tv-header .brand img { width: 56px; height: 56px; background: var(--putih); border-radius: 50%; padding: 5px; }
.tv-header .brand h1 { margin: 0; font-size: 22px; }
.tv-header .brand p { margin: 2px 0 0; font-size: 13px; opacity: 0.85; }
.tv-header .tv-clock { text-align: right; }
.tv-header .tv-clock .time { font-size: 34px; font-weight: 800; letter-spacing: 2px; }
.tv-header .tv-clock .date { font-size: 13px; opacity: 0.85; }

.tv-main {
  flex: 1;
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 0;
  min-height: 0;
}

/* Mode split-screen: panel video aktif di sisi kiri */
.tv-main.with-video {
  grid-template-columns: var(--video-lebar, 55%) 1fr;
}

.tv-video-panel {
  background: #000;
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 4px solid var(--emas);
}
.tv-video-panel .video-stage {
  flex: 1;
  position: relative;
  min-height: 0;
  background: #000;
}
.tv-video-panel .video-stage iframe,
.tv-video-panel .video-stage video {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: none;
  object-fit: contain;
  background: #000;
}
.tv-video-panel .video-caption {
  padding: 10px 18px;
  background: rgba(0,0,0,0.55);
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.tv-video-panel .video-caption .judul-video {
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tv-video-panel .video-empty {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,0.4);
  font-size: 14px;
  text-align: center;
  padding: 20px;
}

/* Saat mode split-screen aktif, panel panggilan & sidebar menyesuaikan jadi 1 kolom vertikal yang ringkas namun tetap menonjol */
.tv-main.with-video .tv-info-stack {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.tv-main.with-video .tv-calling-panel {
  flex: 0 0 auto;
  max-height: 62%;
  overflow-y: auto;
}
.tv-main.with-video .tv-calling-grid {
  grid-template-columns: repeat(2, 1fr);
}
.tv-main.with-video .tv-calling-card .nomor-besar { font-size: 44px; }
.tv-main.with-video .tv-sidebar {
  flex: 1;
  min-height: 0;
}

.tv-calling-panel {
  padding: 28px 32px;
  display: flex;
  flex-direction: column;
}
.tv-calling-panel h2 {
  font-size: 16px;
  text-transform: uppercase;
  letter-spacing: 2px;
  opacity: 0.7;
  margin: 0 0 16px;
}

.tv-calling-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  flex: 1;
}

.tv-calling-card {
  background: rgba(255,255,255,0.06);
  border-radius: 18px;
  padding: 22px;
  border: 2px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.tv-calling-card.flash {
  animation: flashCard 1.2s ease-in-out 3;
}
@keyframes flashCard {
  0%, 100% { background: rgba(255,255,255,0.06); }
  50% { background: rgba(212,160,23,0.35); }
}
.tv-calling-card .loket-name {
  font-size: 14px;
  opacity: 0.75;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 8px;
}
.tv-calling-card .nomor-besar {
  font-size: 64px;
  font-weight: 900;
  letter-spacing: 2px;
  line-height: 1;
}
.tv-calling-card.empty .nomor-besar { opacity: 0.25; font-size: 40px; }

.tv-sidebar {
  background: rgba(0,0,0,0.25);
  padding: 28px 30px;
  display: flex;
  flex-direction: column;
  gap: 22px;
  overflow-y: auto;
}
.tv-sidebar h2 {
  font-size: 14px;
  text-transform: uppercase;
  letter-spacing: 2px;
  opacity: 0.7;
  margin: 0 0 4px;
}
.tv-queue-list { display: flex; flex-direction: column; gap: 8px; }
.tv-queue-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: rgba(255,255,255,0.05);
  padding: 9px 14px;
  border-radius: 10px;
  font-size: 14px;
}
.tv-queue-row .qnum { font-weight: 700; }
.tv-queue-row .qcount {
  background: var(--emas);
  color: var(--hijau-tua-dark);
  padding: 2px 10px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 700;
}

.tv-running-text {
  background: var(--emas);
  color: var(--hijau-tua-dark);
  font-weight: 700;
  font-size: 17px;
  padding: 12px 0;
  overflow: hidden;
  white-space: nowrap;
  position: relative;
}
.tv-running-text .marquee-content {
  display: inline-block;
  padding-left: 100%;
  animation: marquee 28s linear infinite;
}
@keyframes marquee {
  0% { transform: translateX(0); }
  100% { transform: translateX(-100%); }
}

/* ===================== RESPONSIVE ===================== */
@media (max-width: 900px) {
  .tv-main { grid-template-columns: 1fr; }
  .tv-calling-grid { grid-template-columns: 1fr; }
  .tv-main.with-video {
    grid-template-columns: 1fr;
    grid-template-rows: 45% 1fr;
  }
  .tv-main.with-video .tv-video-panel {
    border-right: none;
    border-bottom: 4px solid var(--emas);
  }
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: -260px;
    z-index: 100;
    transition: left 0.25s ease;
    height: 100vh;
  }
  .sidebar.open { left: 0; }
  .mobile-menu-toggle { display: inline-flex; align-items: center; justify-content: center; }
  .form-row { grid-template-columns: 1fr; }
  .page-body { padding: 18px 16px 50px; }
  .topbar-instansi { padding: 12px 16px; }
  .topbar-instansi .brand-text h1 { font-size: 13px; }
  .login-box { padding: 32px 24px; }
  .kiosk-success-box .nomor-tiket { font-size: 56px; }
}

@media (max-width: 480px) {
  .stat-grid { grid-template-columns: 1fr 1fr; }
  .kiosk-grid { grid-template-columns: 1fr 1fr; }
}

/* Overlay saat sidebar mobile terbuka */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 90;
}
.sidebar-overlay.show { display: block; }

/* Print area struk antrian */
@media print {
  body * { visibility: hidden; }
  .print-area, .print-area * { visibility: visible; }
  .print-area { position: absolute; top: 0; left: 0; width: 80mm; }
}
