/* PWA Sales — token & pola visual SAMA dengan app.arizkatech.com (Tailwind config di sana),
 * ditulis manual di sini karena app ini vanilla JS tanpa build step (PRD §3.1). Kalau token warna
 * di app utama berubah, cek ulang nilai di sini juga (app.arizkatech.com/tailwind.config.js). */

:root {
    --navy-50: #F3F5FA;
    --navy-100: #E1E6F2;
    --navy-200: #C3CCE3;
    --navy-300: #8E9BC0;
    --navy-400: #5C6A96;
    --navy-500: #3F4D7D;
    --navy-600: #2B3A6C;
    --navy-700: #182552;
    --navy-800: #16234C;
    --navy-900: #10193B;
    --navy-950: #0B1330;

    --accent-50: #E3F8FA;
    --accent-100: #C7F0F5;
    --accent-200: #A3EAF1;
    --accent-300: #7FE3EC;
    --accent-400: #4DD9E8;
    --accent-500: #17C3D6;
    --accent-600: #0E9AAE;
    --accent-700: #0B7285;

    --emerald-50: #ECFDF5; --emerald-100: #D1FAE5; --emerald-600: #059669; --emerald-700: #047857;
    --amber-50: #FFFBEB; --amber-100: #FEF3C7; --amber-600: #D97706; --amber-700: #B45309;
    --red-50: #FEF2F2; --red-100: #FEE2E2; --red-500: #EF4444; --red-600: #DC2626; --red-700: #B91C1C;

    --font-display: 'Sora', system-ui, sans-serif;
    --font-sans: 'Plus Jakarta Sans', system-ui, sans-serif;
    --font-mono: 'IBM Plex Mono', ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
    margin: 0;
    font-family: var(--font-sans);
    background: var(--navy-50);
    color: var(--navy-900);
    -webkit-tap-highlight-color: transparent;
    overscroll-behavior-y: contain;
}
h1, h2, h3, .font-display { font-family: var(--font-display); }
button { font-family: inherit; cursor: pointer; }
a { color: inherit; text-decoration: none; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ── Shell ──────────────────────────────────────────────────────────── */
#app { display: flex; flex-direction: column; min-height: 100dvh; }

#topbar {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; gap: 12px;
    padding: 14px 16px calc(14px + env(safe-area-inset-top, 0px));
    padding-top: max(14px, env(safe-area-inset-top, 0px));
    background: rgba(255,255,255,.9);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--navy-100);
}
#topbar-title { font-weight: 800; font-size: 18px; color: var(--navy-900); line-height: 1.2; }
#topbar-sub { font-size: 11px; color: var(--navy-400); margin-top: 1px; }
#topbar-actions { margin-left: auto; display: flex; gap: 6px; align-items: center; }
.topbar-avatar {
    width: 34px; height: 34px; border-radius: 999px; border: none; flex-shrink: 0;
    background: linear-gradient(135deg, var(--accent-400), var(--accent-600)); color: #fff;
    font-weight: 800; font-size: 13px; display: flex; align-items: center; justify-content: center;
}
.topbar-avatar:active { transform: scale(.92); }

#page-content { flex: 1; padding: 16px 16px 100px; max-width: 720px; margin: 0 auto; width: 100%; }

#bottom-nav {
    position: fixed; left: 12px; right: 12px; bottom: 12px; z-index: 20;
    max-width: 640px; margin: 0 auto;
    display: flex;
    background: rgba(255,255,255,.9); backdrop-filter: blur(16px);
    border-radius: 18px; box-shadow: 0 20px 40px -16px rgba(16,25,59,.35);
    border: 1px solid var(--navy-100);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}
.nav-btn {
    flex: 1; border: none; background: none; display: flex; flex-direction: column; align-items: center;
    gap: 3px; padding: 10px 4px; color: var(--navy-400); position: relative;
}
.nav-btn.active { color: var(--accent-600); }
.nav-btn.active::before {
    content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 28px; height: 3px; border-radius: 0 0 4px 4px; background: var(--accent-400);
    box-shadow: 0 2px 10px rgba(23,195,214,.8);
}
.nav-btn i { font-size: 20px; }
.nav-btn span { font-size: 10px; font-weight: 700; }

/* ── Cards & surfaces ───────────────────────────────────────────────── */
.surface {
    background: #fff; border-radius: 16px; border: 1px solid var(--navy-100);
    box-shadow: 0 1px 2px rgba(16,25,59,.04), 0 8px 24px -12px rgba(16,25,59,.14);
}
.section-label { font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--navy-400); }

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn-icon {
    width: 36px; height: 36px; border-radius: 12px; border: none; background: var(--navy-50);
    color: var(--navy-500); display: flex; align-items: center; justify-content: center;
}
.btn-icon:active { transform: scale(.94); }
.btn-primary {
    background: linear-gradient(135deg, var(--accent-400), var(--accent-600));
    color: #fff; border: none; border-radius: 14px; font-weight: 700; font-size: 14px;
    padding: 13px 18px; display: flex; align-items: center; justify-content: center; gap: 8px;
    box-shadow: 0 10px 24px -8px rgba(23,195,214,.6);
}
.btn-primary:disabled { opacity: .4; box-shadow: none; }
.btn-primary:active { transform: scale(.98); }
.btn-secondary {
    background: var(--navy-50); color: var(--navy-600); border: none; border-radius: 14px;
    font-weight: 700; font-size: 14px; padding: 13px 18px;
}
.btn-danger { background: var(--red-50); color: var(--red-600); border: none; border-radius: 14px; font-weight: 700; padding: 13px 18px; }
.chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px;
    font-size: 12px; font-weight: 700; white-space: nowrap; border: 1px solid var(--navy-100); background: #fff; color: var(--navy-500);
}
.chip.active { background: var(--navy-900); color: #fff; border-color: var(--navy-900); }
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; }

/* ── Forms ──────────────────────────────────────────────────────────── */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12px; font-weight: 700; color: var(--navy-500); margin-bottom: 5px; }
.field input, .field select, .field textarea {
    width: 100%; padding: 11px 13px; border-radius: 12px; border: 1px solid var(--navy-100);
    background: #fff; color: var(--navy-900);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent-500); box-shadow: 0 0 0 3px var(--accent-100); }
.field-error { color: var(--red-600); font-size: 12px; margin-top: 4px; }

/* ── FAB ────────────────────────────────────────────────────────────── */
#fab {
    position: fixed; left: 16px; bottom: calc(88px + env(safe-area-inset-bottom, 0px)); z-index: 25;
    width: 56px; height: 56px; border-radius: 999px; border: none;
    background: linear-gradient(135deg, var(--accent-400), var(--accent-600)); color: #fff;
    display: flex; align-items: center; justify-content: center; font-size: 22px;
    box-shadow: 0 14px 28px -8px rgba(23,195,214,.7);
}
#fab:active { transform: scale(.94); }

/* ── Bottom sheet ───────────────────────────────────────────────────── */
#sheet-backdrop {
    position: fixed; inset: 0; background: rgba(11,19,48,.6); backdrop-filter: blur(2px);
    z-index: 50; display: none; align-items: flex-end; justify-content: center;
}
#sheet-backdrop.open { display: flex; }
#sheet {
    width: 100%; max-width: 560px; max-height: 90dvh; background: #fff; border-radius: 24px 24px 0 0;
    box-shadow: 0 -20px 60px rgba(16,25,59,.4); display: flex; flex-direction: column; overflow: hidden;
}
#sheet-handle { width: 40px; height: 5px; border-radius: 999px; background: var(--navy-200); margin: 10px auto; }
#sheet-header { display: flex; align-items: center; justify-content: space-between; padding: 4px 20px 12px; border-bottom: 1px solid var(--navy-100); }
#sheet-title { font-family: var(--font-display); font-weight: 800; font-size: 17px; }
#sheet-body { padding: 18px 20px; overflow-y: auto; }
#sheet-footer { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px calc(14px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--navy-100); }

/* ── Toast ──────────────────────────────────────────────────────────── */
#toast-container { position: fixed; left: 16px; right: 16px; bottom: calc(96px + env(safe-area-inset-bottom, 0px)); z-index: 80; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast {
    max-width: 420px; padding: 12px 18px; border-radius: 14px; font-size: 13px; font-weight: 600; color: #fff;
    background: var(--navy-900); box-shadow: 0 10px 30px -8px rgba(16,25,59,.5);
    animation: toast-in .2s ease-out;
}
.toast.err { background: var(--red-600); }
.toast.ok { background: var(--emerald-600); }
@keyframes toast-in { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* ── Misc ───────────────────────────────────────────────────────────── */
/* min-height claims most of the visible screen and centers within it, instead of sitting as a
   small stub at the top with a long dead gray void trailing below on short/empty content. */
.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; min-height: 50vh; text-align: center; padding: 24px 16px; color: var(--navy-300); font-size: 13px; }

/* ── Dashboard stat cards (Kunjungan Hari Ini = beranda) ───────────────── */
.stat-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 18px; }
.stat-card {
    background: #fff; border-radius: 16px; border: 1px solid var(--navy-100); padding: 14px;
    text-align: left; box-shadow: 0 1px 2px rgba(16,25,59,.04);
}
.stat-card:active { transform: scale(.97); }
.stat-card .stat-icon { width: 30px; height: 30px; border-radius: 10px; display: flex; align-items: center; justify-content: center; font-size: 13px; margin-bottom: 8px; }
.stat-card .stat-value { font-size: 20px; font-weight: 800; font-family: var(--font-mono); line-height: 1; }
.stat-card .stat-label { font-size: 11px; color: var(--navy-400); font-weight: 600; margin-top: 4px; }

/* ── Icon grid (Lainnya, dan menu grid lain) — pola sama x-icon-btn di app.arizkatech.com:
   label jadi caption kecil di bawah ikon, bukan baris teks sejajar ikon. ── */
.icon-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
.icon-grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
.icon-grid-item { display: flex; flex-direction: column; align-items: center; gap: 7px; padding: 14px 4px; border: none; background: none; color: var(--navy-600); }
.icon-grid-item:active .icon-grid-circle { transform: scale(.92); }
.icon-grid-circle { width: 48px; height: 48px; border-radius: 999px; background: var(--navy-50); color: var(--navy-500); display: flex; align-items: center; justify-content: center; font-size: 18px; transition: transform .1s; }
.icon-grid-item span { font-size: 11px; font-weight: 600; line-height: 1.2; }
.icon-grid-item.danger .icon-grid-circle { background: var(--red-50); color: var(--red-600); }
.icon-grid-item.danger span { color: var(--red-600); }
.spinner { width: 28px; height: 28px; border-radius: 999px; border: 3px solid var(--navy-100); border-top-color: var(--accent-500); animation: spin .7s linear infinite; margin: 40px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 3px 9px; border-radius: 999px; font-size: 11px; font-weight: 700; }
.badge-amber { background: var(--amber-100); color: var(--amber-700); }
.badge-emerald { background: var(--emerald-100); color: var(--emerald-700); }
.badge-navy { background: var(--navy-50); color: var(--navy-500); }
.badge-red { background: var(--red-100); color: var(--red-700); }
[x-cloak], .hidden { display: none !important; }

/* ═══ PWA Teknisi — tambahan di atas pola PWA Sales ═══════════════════════ */
#topbar-back { flex-shrink: 0; }
.btn-icon[hidden], #net-banner[hidden], #action-dock[hidden], #nav-badge[hidden] { display: none !important; }

#net-banner { position: sticky; top: 62px; z-index: 29; padding: 8px 16px; font-size: 12px; font-weight: 600; line-height: 1.5; text-align: center; }
#net-banner.off { background: var(--navy-900); color: #fff; }
#net-banner.sync { background: var(--accent-100); color: var(--accent-700); }
#net-banner.err { background: var(--red-100); color: var(--red-700); }
#net-banner a { text-decoration: underline; }

#nav-badge { position: absolute; top: 4px; left: 54%; min-width: 17px; height: 17px; padding: 0 5px; border-radius: 999px; background: var(--red-500); color: #fff; font-size: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center; }

#page-content.has-dock { padding-bottom: 168px; }
#action-dock {
    position: fixed; left: 12px; right: 12px; bottom: calc(82px + env(safe-area-inset-bottom, 0px)); z-index: 22; max-width: 640px; margin: 0 auto;
    display: flex; gap: 8px; padding: 10px; background: rgba(255,255,255,.94); backdrop-filter: blur(14px);
    border: 1px solid var(--navy-100); border-radius: 18px; box-shadow: 0 16px 36px -14px rgba(16,25,59,.4);
}
#action-dock button { flex: 1; min-height: 48px; }

.task-card { display: block; width: 100%; text-align: left; padding: 14px 16px; margin-bottom: 10px; border: none; }
.task-card:active { transform: scale(.985); }
.task-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; }
.task-no { font-family: var(--font-mono); font-size: 11px; color: var(--navy-400); font-weight: 600; }
.task-client { font-family: var(--font-display); font-weight: 700; font-size: 16px; margin-top: 2px; }
.task-meta { font-size: 12px; color: var(--navy-400); margin-top: 6px; display: flex; gap: 6px; align-items: flex-start; }
.progress { height: 8px; border-radius: 999px; background: var(--navy-100); overflow: hidden; margin-top: 12px; }
.progress > i { display: block; height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent-500), var(--accent-300)); }
.progress.done > i { background: var(--emerald-600); }
.task-foot { display: flex; justify-content: space-between; font-size: 12px; margin-top: 7px; color: var(--navy-500); }
.task-foot b { color: var(--navy-900); }

.info-row { display: flex; gap: 12px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--navy-50); font-size: 13px; }
.info-row:last-child { border-bottom: none; }
.info-row > i { width: 18px; margin-top: 2px; color: var(--accent-600); text-align: center; }
.info-row .label { font-size: 11px; color: var(--navy-400); font-weight: 600; }
.info-row .link { color: var(--accent-700); font-weight: 700; }

.stage-item { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; }
.stage-dot { width: 26px; height: 26px; border-radius: 999px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; font-size: 11px; background: var(--navy-100); color: var(--navy-300); }
.stage-item.done .stage-dot { background: var(--emerald-600); color: #fff; }
.stage-item.current .stage-dot { background: var(--accent-500); color: #fff; box-shadow: 0 0 0 4px var(--accent-100); }
.stage-item.pending-sync .stage-dot { background: var(--amber-100); color: var(--amber-700); }
.stage-name { font-weight: 700; font-size: 14px; }
.stage-item.todo .stage-name { color: var(--navy-300); font-weight: 600; }
.stage-sub { font-size: 11px; color: var(--navy-400); margin-top: 1px; }

.feed-item { padding: 12px 0; border-bottom: 1px solid var(--navy-50); }
.feed-item:last-child { border-bottom: none; }
.feed-note { font-size: 14px; white-space: pre-line; word-break: break-word; }
.feed-meta { font-size: 11px; color: var(--navy-400); margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 8px; }
.photo-grid button, .photo-grid .ph { aspect-ratio: 1; border-radius: 12px; overflow: hidden; border: none; padding: 0; background: var(--navy-100); position: relative; }
.photo-grid img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-grid .rm { position: absolute; top: 4px; right: 4px; width: 24px; height: 24px; border-radius: 999px; border: none; background: rgba(16,25,59,.75); color: #fff; font-size: 11px; display: flex; align-items: center; justify-content: center; }

.pick-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.pick-btn { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 8px; border-radius: 14px; border: 1.5px dashed var(--navy-200); background: var(--navy-50); color: var(--navy-500); font-size: 12px; font-weight: 700; }
.pick-btn i { font-size: 22px; color: var(--accent-600); }

.sig-wrap { border: 1.5px solid var(--navy-200); border-radius: 14px; background: #fff; touch-action: none; position: relative; }
.sig-wrap canvas { width: 100%; height: 180px; display: block; border-radius: 14px; }
.sig-hint { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); text-align: center; color: var(--navy-200); font-size: 13px; pointer-events: none; }

.sync-row { display: flex; gap: 10px; align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--navy-50); font-size: 13px; }
.sync-row:last-child { border-bottom: none; }
.viewer-img { width: 100%; max-height: 70dvh; object-fit: contain; border-radius: 12px; background: var(--navy-900); }
.badge-cyan { background: var(--accent-100); color: var(--accent-700); }
.big-input { font-size: 16px !important; }

/* kendala (eskalasi ke admin) */
#action-dock .btn-icon-only, #action-dock .btn-issue { flex: 0 0 52px; }
.btn-issue { background: var(--red-50); color: var(--red-600); border: 1px solid var(--red-100); border-radius: 14px; font-size: 18px; min-height: 48px; }
.btn-issue:active { transform: scale(.96); }
.feed-item.issue { background: var(--red-50); margin: 0 -16px; padding-left: 16px; padding-right: 16px; border-left: 3px solid var(--red-500); }
.issue-toggle { display: flex; align-items: center; gap: 10px; margin-top: 14px; padding: 12px 14px; border-radius: 14px; background: var(--red-50); color: var(--red-700); font-size: 13px; }
.issue-toggle input { width: 20px; height: 20px; accent-color: var(--red-600); flex-shrink: 0; }

/* tahap yang didelegasikan ke teknisi lain/kantor: terlihat tetapi tidak bisa diubah */
.stage-item.office { opacity: .62; }
.mine-note { margin-top: 10px; padding: 8px 10px; border-radius: 10px; background: var(--accent-50, #ECFAFC); color: var(--navy-600); font-size: 12px; font-weight: 600; }
.mine-note i { color: var(--accent-600, #0E9AAE); margin-right: 4px; }
