/*
 * App layout BBM — base + helper di atas tokens.css + components.css.
 * components.css class-only (tanpa body), jadi base layout ditaruh di sini.
 * Badge: alias semantik Indonesia → warna sama dgn FTTH (lihat design-system/README.md).
 */

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent-text); }

.wrap { width: min(1080px, 100%); margin: 0 auto; padding: 18px; }
.wrap--narrow { width: min(560px, 100%); }

.topbar {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px; background: var(--bg-elev);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 50;
}
.topbar h1 { font-size: 1.05rem; margin: 0; font-weight: 700; }
.topbar .spacer { flex: 1; }

.brand-name { font-family: var(--font-display); font-weight: 700; }

/* Logo aplikasi (PNG) — dipakai di topbar, menggantikan kotak .an-logo */
.app-logo { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; display: block; flex-shrink: 0; box-shadow: var(--shadow-sm); }
.app-logo--lg { width: 72px; height: 72px; border-radius: 18px; }
.page-title { font-family: var(--font-display); font-size: clamp(1.4rem, 3vw, 2rem); margin: 4px 0 2px; }
.muted { color: var(--text-muted); }
.subtle { color: var(--text-subtle); font-size: 0.85rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.mt { margin-top: 14px; } .mt-lg { margin-top: 22px; } .mt-sm { margin-top: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }

/* KPI cards */
.kpi-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 12px; }
.kpi { background: var(--bg-elev); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 14px; cursor: pointer; transition: box-shadow .12s ease; }
.kpi:hover { box-shadow: var(--shadow-sm); }
.kpi .n { font-size: 1.8rem; font-weight: 700; font-family: var(--font-mono); }
.kpi .l { font-size: 0.78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; }
.kpi.is-flag .n { color: var(--danger); }

/* Tabs */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin: 16px 0; }
.tab { padding: 9px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; font-weight: 600; font-size: 0.9rem; }
.tab.is-active { background: var(--navy); color: #fff; border-color: transparent; }

/* Table */
.tbl { width: 100%; border-collapse: collapse; font-size: 0.9rem; }
.tbl th, .tbl td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.tbl th { font-size: 0.74rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-subtle); }
.tbl tr:hover td { background: var(--surface-alt); }
.tbl .row-click { cursor: pointer; }

/* Photo tiles (form lapangan) */
.tile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.tile { border: 1px dashed var(--border-strong); border-radius: var(--radius-md); padding: 12px; background: var(--surface); display: grid; gap: 8px; text-align: center; }
.tile.has-img { border-style: solid; }
.tile img { width: 100%; height: 120px; object-fit: cover; border-radius: var(--radius-sm); }
.tile label { font-size: 0.82rem; font-weight: 600; color: var(--text-muted); }
.tile input[type=file] { display: none; }
.tile .pick { font-size: 0.8rem; }

/* Photo grid in detail modal */
.photo-strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.photo-strip figure { margin: 0; }
.photo-strip img { width: 100%; border-radius: var(--radius-sm); border: 1px solid var(--border); cursor: zoom-in; }
.photo-strip figcaption { font-size: 0.72rem; color: var(--text-subtle); text-align: center; margin-top: 2px; }

/* Flag list (ADMIN ONLY — honeypot) */
.flag-item { display: flex; gap: 8px; align-items: start; padding: 8px 10px; border-radius: var(--radius-sm); background: var(--danger-soft); color: var(--danger-text); font-size: 0.85rem; }

.toast { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 999px; box-shadow: var(--shadow); z-index: 2000; font-size: 0.9rem; opacity: 0; transition: opacity .2s ease; }
.toast.show { opacity: 1; }
.toast.err { background: var(--danger); color: #fff; }

.qr-box { display: grid; place-items: center; gap: 8px; padding: 16px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-md); }
.qr-box img { width: 200px; height: 200px; }

/* Badge alias semantik (warna mengikuti FTTH) */
.an-badge--diajukan    { background: var(--warn-soft);   color: var(--warn-text);   }
.an-badge--disetujui   { background: var(--navy-soft);   color: var(--accent-text); }
.an-badge--diisi       { background: color-mix(in oklab, var(--ok-soft) 50%, white); color: var(--ok-text); }
.an-badge--diverifikasi,
.an-badge--selesai     { background: var(--ok-soft);     color: var(--ok-text);     }
.an-badge--ditolak,
.an-badge--dibatalkan  { background: var(--danger-soft); color: var(--danger-text); }

/* ── Fase 2: Analitik & aging ── */
.tbl .r { text-align: right; }
.tbl .row-nyangkut td { background: var(--danger-soft); }
.pill-warn { font-size: 0.7rem; font-weight: 700; color: var(--danger-text); background: var(--danger-soft); border-radius: 999px; padding: 1px 8px; margin-left: 6px; white-space: nowrap; }
.chart-wrap { height: 280px; }

/* ── Portal / launcher (redesign Landing) ── */
.portal { min-height: 100svh; display: flex; align-items: center; justify-content: center; padding: 48px 24px; }
.portal-inner { width: 100%; max-width: 600px; display: flex; flex-direction: column; align-items: center; }
.portal-logo { width: 92px; height: 92px; border-radius: 22px; margin-bottom: 26px; box-shadow: none;
  filter: drop-shadow(0 14px 30px color-mix(in srgb, var(--accent) 16%, transparent)); }
.portal-title { font-family: var(--font-display); font-size: clamp(2.4rem, 7vw, 3.6rem); font-weight: 700;
  letter-spacing: -0.01em; text-align: center; line-height: 1.04; margin: 0 0 12px; }
.portal-sub { font-size: 1.12rem; color: var(--text-muted); text-align: center; margin: 0 0 40px; line-height: 1.45; }
.portal-foot { margin-top: 44px; font-size: 0.84rem; color: var(--text-subtle); text-align: center; }

.hub-stack { width: 100%; display: flex; flex-direction: column; gap: 16px; }
.hub-card { display: flex; align-items: center; gap: 18px; width: 100%; text-align: left;
  padding: 20px 22px; border-radius: var(--radius-lg); border: 1px solid var(--border);
  background: var(--surface); color: inherit; font: inherit; cursor: pointer;
  transition: transform .14s ease, box-shadow .14s ease; }
.hub-card:hover { transform: translateY(-2px); box-shadow: var(--shadow); }
.hub-card:active { transform: translateY(0); }
.hub-card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.hub-card--accent { background: var(--accent-soft); border-color: color-mix(in oklab, var(--accent) 22%, var(--border)); }
.hub-card--ok { background: var(--ok-soft); border-color: color-mix(in oklab, var(--ok) 22%, var(--border)); }
.hub-ico { width: 56px; height: 56px; border-radius: 16px; display: grid; place-items: center; flex-shrink: 0;
  background: var(--surface-alt); color: var(--text-muted); }
.hub-ico--accent { background: color-mix(in oklab, var(--accent) 14%, white); color: var(--accent); }
.hub-ico--ok { background: color-mix(in oklab, var(--ok) 14%, white); color: var(--ok); }
.hub-ico--muted { color: var(--text-muted); }
.hub-text { flex: 1; min-width: 0; }
.hub-title { display: block; font-size: 1.18rem; font-weight: 700; line-height: 1.2; }
.hub-sub { display: block; font-size: 0.9rem; color: var(--text-muted); margin-top: 3px; }
.hub-chev { display: grid; place-items: center; flex-shrink: 0; color: var(--text-subtle); }
.hub-chev--accent { color: var(--accent-text); }
.hub-chev--ok { color: var(--ok-text); }

/* Perkiraan biaya (poles wizard ajuan) */
.est-biaya { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-radius: var(--radius-md); background: var(--accent-soft); border: 1px solid color-mix(in oklab, var(--accent) 20%, var(--border)); }
.est-biaya .lbl { color: var(--accent-text); }
.est-biaya .sub { font-size: 0.78rem; color: var(--accent-text); opacity: .8; margin-top: 3px; }
.est-biaya .amt { font-family: var(--font-mono); font-weight: 700; font-size: 1.15rem; color: var(--accent-text); }

/* ── Form Pengisian Lapangan (FieldForm) ── */
@keyframes ff-bar { 0% { left: -40%; } 100% { left: 100%; } }
@keyframes ff-spin { to { transform: rotate(360deg); } }
.ff-app { min-height: 100svh; display: flex; flex-direction: column; background: var(--bg); }
.ff-header { display: flex; align-items: center; gap: 12px; padding: 10px 16px; background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20; }
.ff-h-title { flex: 1; min-width: 0; }
.ff-h-title b { display: block; font-size: 1rem; font-weight: 700; line-height: 1.2; }
.ff-h-title span { font-family: var(--font-mono); font-size: 0.7rem; color: var(--text-muted); }
.ff-scroll { flex: 1; width: min(560px, 100%); margin: 0 auto; padding: 16px 16px 120px; display: flex; flex-direction: column; gap: 16px; }
.ff-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; background: var(--accent-soft); z-index: 40; overflow: hidden; }
.ff-progress::after { content: ''; position: absolute; top: 0; width: 40%; height: 100%; background: var(--accent); animation: ff-bar 1.1s ease-in-out infinite; }
.ff-spin { width: 18px; height: 18px; border: 2.5px solid rgba(255,255,255,.4); border-top-color: #fff; border-radius: 999px; display: inline-block; animation: ff-spin .7s linear infinite; vertical-align: -3px; margin-right: 8px; }

/* context card */
.ff-ctx { gap: 0; padding: 0; overflow: hidden; }
.ff-ctx-top { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px; }
.ff-ctx-no { font-family: var(--font-mono); font-weight: 600; font-size: 0.95rem; }
.ff-ctx-row { border-top: 1px solid var(--border); display: flex; }
.ff-ctx-cell { flex: 1; padding: 11px 16px; }
.ff-ctx-cell + .ff-ctx-cell { border-left: 1px solid var(--border); }
.ff-ctx-cell .v { font-size: 0.82rem; font-weight: 500; margin-top: 3px; }

/* photo tiles */
.ff-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ff-tile { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; text-align: center; min-height: 132px; padding: 16px 10px; cursor: pointer; color: var(--text); border: 2px dashed var(--border-strong); border-radius: var(--radius-md); background: color-mix(in oklab, var(--surface) 70%, var(--bg)); }
.ff-tile .ff-cam { width: 48px; height: 48px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }
.ff-tile .ff-tlabel { font-size: 0.82rem; font-weight: 600; }
.ff-tile .ff-thint { font-size: 0.72rem; color: var(--text-muted); }
.ff-tile input[type=file] { display: none; }
.ff-tile.has-img { border-style: solid; border-color: var(--border); padding: 0; overflow: hidden; background: repeating-linear-gradient(135deg, color-mix(in oklab, var(--accent) 10%, var(--surface)) 0 14px, color-mix(in oklab, var(--accent) 5%, var(--surface)) 14px 28px); }
.ff-tile.has-img img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.ff-cap-chip { position: absolute; top: 8px; left: 8px; z-index: 2; display: flex; align-items: center; gap: 6px; background: color-mix(in oklab, #2D2A24 78%, transparent); color: #F8F5EC; padding: 5px 9px; border-radius: 8px; font-family: var(--font-mono); font-size: 0.62rem; }
.ff-cap-chip .dot { width: 6px; height: 6px; border-radius: 999px; background: var(--accent); }
.ff-badge-label { position: absolute; bottom: 8px; left: 8px; z-index: 2; font-family: var(--font-mono); font-size: 0.6rem; letter-spacing: .1em; text-transform: uppercase; color: var(--accent-text); background: color-mix(in oklab, var(--surface) 85%, transparent); padding: 4px 8px; border-radius: 999px; }
.ff-redo { position: absolute; top: 8px; right: 8px; z-index: 2; background: var(--surface); color: var(--text); border: 1px solid var(--border); padding: 5px 10px; border-radius: 999px; font-size: 0.72rem; font-weight: 600; }

/* number boxes */
.ff-nums { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.ff-nums > div { min-width: 0; }
.ff-box { display: flex; align-items: baseline; gap: 6px; border: 1px solid var(--border); background: var(--surface); border-radius: 14px; padding: 11px 14px; }
.ff-box--accent { border-color: color-mix(in oklab, var(--accent) 28%, var(--border)); }
.ff-box--lock { background: var(--bg-sunken); }
.ff-box input { flex: 1; min-width: 0; border: none; background: transparent; outline: none; padding: 0; color: var(--text); font-family: var(--font-mono); font-size: 1.4rem; font-weight: 700; }
.ff-box .unit { font-size: 0.8rem; color: var(--text-muted); font-weight: 600; }
.ff-box .val { font-family: var(--font-mono); font-size: 1.4rem; font-weight: 700; color: var(--text-muted); }

/* total */
.ff-total { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px; border-radius: var(--radius-md); background: var(--accent-soft); border: 1px solid color-mix(in oklab, var(--accent) 20%, var(--border)); }
.ff-total .lbl { color: var(--accent-text); }
.ff-total .sub { font-size: 0.75rem; color: var(--accent-text); opacity: .8; margin-top: 3px; }
.ff-total .amt { font-family: var(--font-mono); font-size: 1.6rem; font-weight: 700; color: var(--accent-text); }

/* auto meta */
.ff-auto { gap: 0; padding: 0; }
.ff-auto-row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; }
.ff-auto-row + .ff-auto-row { border-top: 1px solid var(--border); }
.ff-auto-ico { width: 36px; height: 36px; border-radius: 10px; background: var(--info-soft); color: var(--info-text); display: grid; place-items: center; flex-shrink: 0; }
.ff-auto-row .t { flex: 1; min-width: 0; }
.ff-auto-row .t b { display: block; font-size: 0.84rem; font-weight: 600; }
.ff-auto-row .t span { font-family: var(--font-mono); font-size: 0.72rem; color: var(--text-muted); }

/* sticky CTA */
.ff-cta { position: fixed; bottom: 0; left: 0; right: 0; z-index: 25; padding: 14px 16px 22px; background: linear-gradient(180deg, transparent, var(--bg) 38%); }
.ff-cta .an-btn { width: min(560px, 100%); margin: 0 auto; height: 54px; font-size: 1rem; border-radius: 14px; }

/* success */
.ff-ok-wrap { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding-top: 8px; }
.ff-ok-circle { width: 74px; height: 74px; border-radius: 999px; background: var(--ok-soft); color: var(--ok-text); display: grid; place-items: center; }
.ff-ok-title { font-size: 1.35rem; font-weight: 700; }
.ff-ok-sub { font-size: 0.84rem; color: var(--text-muted); line-height: 1.5; max-width: 280px; }
.ff-qr { width: 170px; height: 170px; padding: 10px; background: #fff; border-radius: 12px; border: 1px solid var(--border); }
.ff-qr img { width: 100%; height: 100%; display: block; }

/* ── Lightbox foto (shared) ── */
.lightbox { position: fixed; inset: 0; z-index: 3000; display: none; align-items: center; justify-content: center; padding: 24px; background: color-mix(in srgb, #2D2A24 82%, transparent); cursor: zoom-out; }
.lightbox.show { display: flex; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); }

/* ── Admin shell (reskin: sidebar + topbar) ── */
.admin-shell { display: flex; min-height: 100svh; }
.admin-sidebar { width: 248px; flex-shrink: 0; height: 100svh; position: sticky; top: 0; display: flex; flex-direction: column; gap: 8px; padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--border); }
.admin-brand { display: flex; align-items: center; gap: 10px; padding: 6px 8px 12px; }
.admin-brand .app-logo { width: 40px; height: 40px; }
.admin-brand-txt b { display: block; font-family: var(--font-display); font-size: 1.05rem; line-height: 1.1; }
.admin-brand-txt .an-tiny { color: var(--text-subtle); }
.admin-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; padding: 10px 12px; border: none; border-radius: var(--radius-sm); background: transparent; color: var(--text-muted); font: inherit; font-weight: 600; font-size: 0.92rem; cursor: pointer; }
.nav-item:hover { background: var(--surface-alt); color: var(--text); }
.nav-item.is-active { background: var(--accent-soft); color: var(--accent-text); }
.nav-item svg { flex-shrink: 0; }
.admin-user { border-top: 1px solid var(--border); padding-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.admin-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.admin-topbar { position: sticky; top: 0; z-index: 10; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 24px; background: var(--bg); border-bottom: 1px solid var(--border); }
.admin-topbar h1 { margin: 0; font-family: var(--font-display); font-size: 1.45rem; }
.admin-main #view { padding: 20px 24px; }

@media (max-width: 860px) {
  .admin-shell { flex-direction: column; }
  .admin-sidebar { width: auto; height: auto; position: sticky; top: 0; z-index: 20; flex-direction: row; align-items: center; gap: 8px; padding: 10px 12px; overflow-x: auto; }
  .admin-brand { padding: 0 6px 0 0; flex-shrink: 0; }
  .admin-brand-txt { display: none; }
  .admin-nav { flex-direction: row; gap: 6px; flex: 1; }
  .nav-item { white-space: nowrap; padding: 8px 12px; }
  .admin-user { border-top: none; padding-top: 0; flex-direction: row; flex-shrink: 0; align-items: center; }
  .admin-user #who { display: none; }
  .admin-topbar { padding: 12px 16px; }
  .admin-topbar h1 { font-size: 1.2rem; }
  .admin-main #view { padding: 14px 16px; }
}
