/* ============================================================
   PDT MARAN — Main Stylesheet
   Mobile-first, government portal aesthetic
   ============================================================ */

:root {
  --pdt-blue:      #1a5276;
  --pdt-blue-lt:   #d6eaf8;
  --pdt-blue-dk:   #0d2b3e;
  --pdt-purple:    #6c3483;
  --pdt-purple-lt: #f4eeff;
  --green:         #1e8449;
  --green-lt:      #d5f5e3;
  --amber:         #d35400;
  --amber-lt:      #fdebd0;
  --red:           #c0392b;
  --red-lt:        #fce4e4;

  --text:          #1a1a1a;
  --text-muted:    #666;
  --border:        #e0e0e0;
  --surface:       #f5f6f8;
  --white:         #ffffff;
  --radius:        8px;
  --radius-lg:     14px;
}

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

html { font-size: 16px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--surface);
  color: var(--text);
  min-height: 100vh;
  padding-bottom: 80px; /* bottom nav space */
}

/* ── Typography ──────────────────────────────── */
h1 { font-size: 1.4rem; font-weight: 600; }
h2 { font-size: 1.15rem; font-weight: 600; }
h3 { font-size: 1rem; font-weight: 600; }
p  { line-height: 1.6; }
a  { color: var(--pdt-blue); text-decoration: none; }
.text-muted   { color: var(--text-muted); font-size: 13px; }
.text-center  { text-align: center; }

/* ── Layout ──────────────────────────────────── */
.container {
  max-width: 600px;
  margin: 0 auto;
  padding: 16px;
}
.container-narrow { max-width: 480px; }

/* ── Top navigation bar ──────────────────────── */
.topbar {
  background: var(--pdt-blue);
  color: #fff;
  padding: 12px 16px 14px;
  position: sticky; top: 0; z-index: 100;
}
.topbar-inner {
  max-width: 600px; margin: 0 auto;
  display: flex; align-items: center; justify-content: space-between;
}
.topbar h1 { font-size: 14px; font-weight: 500; }
.topbar p  { font-size: 11px; opacity: .8; margin-top: 1px; }
.topbar-logout { color: rgba(255,255,255,.75); font-size: 13px; }

/* ── Bottom nav ──────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 100;
  background: var(--white);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-item {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; padding: 8px 0 10px;
  gap: 3px; font-size: 10px; color: var(--text-muted);
  text-decoration: none;
}
.nav-item.active { color: var(--pdt-blue); }
.nav-item .nav-icon { font-size: 22px; line-height: 1; }

/* ── Page header ─────────────────────────────── */
.page-header {
  display: flex; align-items: flex-start; justify-content: space-between;
  margin-bottom: 16px; gap: 12px;
}
.page-header h2 { flex: 1; }
.badge-date { font-size: 11px; color: var(--text-muted); white-space: nowrap; margin-top: 4px; }
.btn-back { font-size: 13px; color: var(--pdt-blue); white-space: nowrap; }

/* ── Buttons ─────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  padding: 11px 20px; border-radius: var(--radius);
  font-size: 14px; font-weight: 500; cursor: pointer;
  border: 1px solid transparent; text-decoration: none;
  transition: opacity .15s;
}
.btn:active { opacity: .8; }
.btn-primary { background: var(--pdt-blue); color: #fff; }
.btn-ghost   { background: var(--white); border-color: var(--border); color: var(--text); }
.btn-full    { width: 100%; }
.btn-back    { background: none; border: none; padding: 0; }

/* ── Forms ───────────────────────────────────── */
.form-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.form-section-title {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-transform: uppercase; letter-spacing: .05em;
  margin: 16px 0 10px; border-bottom: 1px solid var(--border); padding-bottom: 6px;
}
.form-section-title:first-child { margin-top: 0; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; color: var(--text-muted);
  margin-bottom: 5px; font-weight: 500; }
.form-group input,
.form-group select,
.form-group textarea,
.form-inline input {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: var(--radius); font-size: 14px; color: var(--text);
  background: var(--white); appearance: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus,
.form-inline input:focus {
  outline: none; border-color: var(--pdt-blue);
  box-shadow: 0 0 0 3px rgba(26,82,118,.12);
}
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-actions { display: flex; gap: 10px; margin-top: 20px; }
.form-inline   { display: flex; gap: 8px; }
.form-inline input { min-width: 0; }   /* lets the box shrink beside its button on a phone */

/* ── Stats grid ──────────────────────────────── */
.stats-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px;
}
.stat-card {
  background: var(--white); border-radius: var(--radius);
  padding: 14px; border: 1px solid var(--border);
}
.stat-num { font-size: 26px; font-weight: 600; color: var(--pdt-blue); }
.stat-lbl { font-size: 11px; color: var(--text-muted); margin-top: 2px; }
.stat-card.accent-warning .stat-num { color: var(--amber); }
.stat-card.accent-info    .stat-num { color: var(--pdt-purple); }

/* ── Quick actions ───────────────────────────── */
.quick-actions {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px;
}
.action-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  text-decoration: none; font-size: 13px; font-weight: 500; color: var(--text);
  text-align: center;
}
.action-card.action-primary { background: var(--pdt-blue); color: #fff; border-color: transparent; }
.action-card.action-scan    { background: var(--pdt-purple); color: #fff; border-color: transparent; }

/* ── Card ────────────────────────────────────── */
.card { background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); overflow: hidden; }
.card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.link-more { font-size: 13px; color: var(--pdt-blue); }

/* ── Fail list ───────────────────────────────── */
.fail-list { padding: 0 16px; }
.fail-row  {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
  text-decoration: none; color: var(--text);
}
.fail-row:last-child { border-bottom: none; }
.fail-icon { width: 36px; height: 36px; background: var(--pdt-blue-lt);
  border-radius: 8px; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; color: var(--pdt-blue); }
.fail-info { flex: 1; min-width: 0; }
.fail-no   { font-size: 13px; font-weight: 600; }
.fail-sub  { font-size: 11px; color: var(--text-muted); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty-state { padding: 24px; text-align: center; color: var(--text-muted); font-size: 13px; }

/* ── Badges ──────────────────────────────────── */
.badge {
  display: inline-block; font-size: 11px; padding: 3px 9px;
  border-radius: 20px; font-weight: 500; white-space: nowrap;
}
.badge-aktif   { background: var(--pdt-blue-lt); color: var(--pdt-blue); }
.badge-selesai { background: var(--green-lt);     color: var(--green); }
.badge-ditolak { background: var(--red-lt);       color: var(--red); }
.badge-tangguh { background: var(--amber-lt);     color: var(--amber); }
.badge-batal   { background: var(--red-lt);       color: var(--red); }

/* ── Info cards ──────────────────────────────── */
.info-card {
  background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 16px; margin-bottom: 14px;
}
.info-card-purple { border-color: var(--pdt-purple); background: var(--pdt-purple-lt); }
.info-card-green  { border-color: #a9dfbf; background: var(--green-lt); }
.info-card-label  { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.info-no-fail     { font-size: 20px; font-weight: 700; color: var(--pdt-blue); }

/* ── Detail card ─────────────────────────────── */
.detail-card { background: var(--white); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 6px 16px; margin-bottom: 14px; }
.detail-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 9px 0; border-bottom: 1px solid var(--border); font-size: 13px;
  gap: 12px;
}
.detail-row:last-child { border-bottom: none; }
.detail-row span  { color: var(--text-muted); flex-shrink: 0; }
.detail-row strong { text-align: right; word-break: break-word; }

/* ── Alert ───────────────────────────────────── */
.alert { padding: 12px 14px; border-radius: var(--radius);
  font-size: 13px; margin-bottom: 14px; }
.alert-danger  { background: var(--red-lt);   border: 1px solid #f1a9a0; color: #7b241c; }
.alert-warning { background: var(--amber-lt); border: 1px solid #f0b27a; color: #784212; }
.alert-info    { background: var(--pdt-blue-lt); border: 1px solid #85c1e9; color: #1a5276; }
.alert-success { background: #eafaf1; border: 1px solid #a9dfbf; color: #1e8449; }

/* ── Scanner ─────────────────────────────────── */
.scanner-box {
  background: #000; border-radius: var(--radius-lg); overflow: hidden;
  position: relative; width: 100%; aspect-ratio: 1;
  max-height: 300px;
}
.scanner-box video { width: 100%; height: 100%; object-fit: cover; }
.scanner-frame {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
}
.scanner-frame .corner {
  position: absolute; width: 24px; height: 24px;
}
.corner.tl { top: 20%; left: 20%; border-top: 3px solid #3498db; border-left: 3px solid #3498db; border-radius: 4px 0 0 0; }
.corner.tr { top: 20%; right: 20%; border-top: 3px solid #3498db; border-right: 3px solid #3498db; border-radius: 0 4px 0 0; }
.corner.bl { bottom: 20%; left: 20%; border-bottom: 3px solid #3498db; border-left: 3px solid #3498db; border-radius: 0 0 0 4px; }
.corner.br { bottom: 20%; right: 20%; border-bottom: 3px solid #3498db; border-right: 3px solid #3498db; border-radius: 0 0 4px 0; }
.scanner-box-purple .corner.tl,
.scanner-box-purple .corner.tr,
.scanner-box-purple .corner.bl,
.scanner-box-purple .corner.br { border-color: #a569bd; }
.scanner-hint {
  position: absolute; bottom: 14px; left: 0; right: 0;
  text-align: center; color: rgba(255,255,255,.75); font-size: 12px;
}

/* ── Audit trail ─────────────────────────────── */
.trail-list { padding: 12px 16px; }
.trail-item {
  display: flex; gap: 12px; padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.trail-item:last-child { border-bottom: none; }
.trail-dot { font-size: 18px; flex-shrink: 0; margin-top: 2px; color: var(--pdt-blue); }
.trail-title { font-size: 13px; font-weight: 600; overflow-wrap: anywhere; }
.trail-sub   { font-size: 11px; color: var(--text-muted); margin-top: 2px; overflow-wrap: anywhere; }

/* ── Login ───────────────────────────────────── */
.halaman-login { display: flex; align-items: center; justify-content: center;
  min-height: 100vh; padding: 20px; }
.login-wrap { background: var(--white); border-radius: var(--radius-lg);
  padding: 32px 24px; width: 100%; max-width: 380px;
  border: 1px solid var(--border); }
.login-header { text-align: center; margin-bottom: 28px; }
.login-logo { width: 60px; height: 60px; background: var(--pdt-blue);
  color: #fff; font-size: 20px; font-weight: 700;
  border-radius: 50%; display: inline-flex; align-items: center;
  justify-content: center; margin-bottom: 12px; }
.login-header h1 { font-size: 15px; }
.login-header p  { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.login-form .form-group { margin-bottom: 16px; }
.login-footer { font-size: 12px; color: var(--text-muted); text-align: center;
  margin-top: 20px; }
.topbar-logo { height: 40px; width: 40px; object-fit: contain; display: block; flex-shrink: 0; background: #fff; border-radius: 8px; padding: 3px; }
.login-logo-img { height: 88px; width: auto; display: block; margin: 0 auto 12px; }
/* Up to 7 tabs (admins): labels stay on one line */
.nav-item { min-width: 0; }
.nav-item span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
/* Narrow phones (e.g. iPhone SE) with many tabs: wrap labels instead of cutting them */
@media (max-width: 380px) {
  .nav-item { font-size: 9px; padding: 7px 1px 8px; }
  .nav-item span:last-child { white-space: normal; text-align: center; line-height: 1.15; overflow: visible; }
  .nav-item .nav-icon { font-size: 20px; }
}

/* ── Responsive: tablet & desktop ────────────────────────────
   Phone (<768px) keeps the layout above. Wider screens get a left
   sidebar instead of the bottom tabs and a wider content area. */
@media screen and (min-width: 768px) {
  body:has(.bottom-nav) { padding-bottom: 24px; padding-left: 200px; }
  .container { max-width: 900px; padding: 24px; }
  .container-narrow { max-width: 560px; }
  body:has(.bottom-nav) .topbar { margin-left: -200px; padding-left: 24px; padding-right: 24px; }
  body:has(.bottom-nav) .topbar-inner { max-width: none; }
  .bottom-nav {
    top: 0; right: auto; bottom: 0; width: 200px; z-index: 90;
    flex-direction: column; justify-content: flex-start;
    border-top: none; border-right: 1px solid var(--border);
    padding: 76px 10px 16px; overflow-y: auto;
  }
  .nav-item {
    flex: 0 0 auto; flex-direction: row; justify-content: flex-start;
    gap: 12px; padding: 11px 12px; font-size: 14px; border-radius: 8px;
  }
  .nav-item:hover { background: var(--surface, #f5f6f8); }
  .nav-item.active { background: var(--blue-lt, var(--pdt-blue-lt, #d6eaf8)); font-weight: 600; }
  .nav-item .nav-icon { font-size: 18px; width: 24px; text-align: center; }
  .nav-item span:last-child { white-space: normal; overflow: visible; }
  .stats-grid, .quick-actions, .proses-grid { grid-template-columns: repeat(4, 1fr); gap: 14px; }
  .form-actions .btn { flex: 0 0 auto; min-width: 160px; }
}
@media (min-width: 768px) and (max-width: 1023px) {
  .stats-grid, .quick-actions, .proses-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 1200px) {
  .container { max-width: 1040px; }
}
/* Landscape phones: keep bottom tabs, just use the space */
@media (max-width: 767px) and (orientation: landscape) {
  .container { max-width: 720px; }
  .nav-item { flex-direction: row; justify-content: center; gap: 6px; padding: 6px 2px; }
}

/* ── Line icons (assets/ikon.svg, via ikon() in helpers.php) ── */
.ikon { width: 1.15em; height: 1.15em; flex-shrink: 0; vertical-align: -0.2em;
  fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.btn .ikon, .link-more .ikon { margin-right: 6px; }
.action-card .ikon { width: 26px; height: 26px; stroke-width: 1.75; }
.nav-icon .ikon { width: 22px; height: 22px; stroke-width: 1.75; vertical-align: 0; }
.fail-icon .ikon, .trail-dot .ikon { width: 20px; height: 20px; stroke-width: 1.75; vertical-align: 0; }
.ikon.ok { color: var(--green, #1e8449); }
.ikon.amaran { color: #b9770e; }
.ikon.bahaya { color: var(--red, #c0392b); }
.ikon.tunggu { color: #d35400; }
