/* =====================================================================
   qatPDF/assets/css/app.css  -  Design tokens & komponen UI (mobile-first)
   Sprint 0 (T1.4) — referensi PRD §14.2 Design System
   Palet: Teal (brand) + Slate (netral), profesional & mudah dibaca
   ===================================================================== */

/* ---------------- Design tokens ---------------- */
:root {
    --brand:        #0f766e;
    --brand-600:    #0d9488;
    --brand-700:    #115e59;
    --brand-soft:   #ccfbf1;

    --bg:           #f1f5f9;
    --surface:      #ffffff;
    --surface-2:    #f8fafc;
    --border:       #e2e8f0;

    --text:         #0f172a;
    --muted:        #64748b;
    --muted-2:      #94a3b8;

    --ok:           #16a34a;
    --warn:         #d97706;
    --danger:       #dc2626;
    --info:         #2563eb;

    --radius:       14px;
    --radius-sm:    10px;
    --radius-lg:    20px;

    --shadow-sm:    0 1px 2px rgba(15, 23, 42, .06);
    --shadow:       0 6px 20px rgba(15, 23, 42, .08);
    --shadow-lg:    0 14px 40px rgba(15, 23, 42, .14);

    --appbar-h:     56px;
    --navbar-h:     62px;
    --safe-top:     env(safe-area-inset-top, 0px);
    --safe-bottom:  env(safe-area-inset-bottom, 0px);

    --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

/* ---------------- Reset dasar ---------------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    font-size: 15px;
    line-height: 1.5;
    overscroll-behavior-y: none;
}

a { color: var(--brand); text-decoration: none; }
img { max-width: 100%; display: block; }

/* ---------------- Struktur halaman ---------------- */
.app-bar {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: calc(var(--appbar-h) + var(--safe-top));
    padding: var(--safe-top) 14px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    background: linear-gradient(135deg, var(--brand-700) 0%, var(--brand) 60%, var(--brand-600) 100%);
    color: #fff;
    z-index: 900;
    box-shadow: var(--shadow);
}

.app-bar .app-title { font-size: 17px; font-weight: 700; letter-spacing: .2px; margin: 0; }
.app-bar .app-sub   { font-size: 11.5px; opacity: .8; }
.app-bar .app-actions { margin-left: auto; display: flex; gap: 6px; }
.app-bar .app-logo {
    width: 32px; height: 32px;
    flex: 0 0 auto;
    border-radius: 9px;
    background: #fff;
    object-fit: contain;
    box-shadow: 0 2px 6px rgba(0,0,0,.2);
}

.app-main {
    padding: calc(var(--appbar-h) + var(--safe-top) + 14px) 14px calc(var(--navbar-h) + var(--safe-bottom) + 24px);
    max-width: 640px;
    margin: 0 auto;
}

.page { display: none; }
.page.active { display: block; animation: fade-in .18s ease; }

@keyframes fade-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------------- Kartu ---------------- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    padding: 14px;
    margin-bottom: 12px;
}
.card-title { font-size: 14px; font-weight: 700; margin: 0 0 4px; }
.card-sub { font-size: 12.5px; color: var(--muted); margin: 0; }

/* ---------------- Tombol ---------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 46px;
    padding: 0 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    background: var(--brand);
    color: #fff;
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 600;
    cursor: pointer;
    transition: transform .12s ease, filter .12s ease, background .12s ease;
}
.btn:active { transform: scale(.98); }
.btn:disabled { opacity: .6; pointer-events: none; }
.btn-block { width: 100%; }
.btn-ghost { background: transparent; color: var(--brand); border-color: var(--border); }
.btn-light { background: #fff; color: var(--text); border-color: var(--border); }
.btn-danger { background: var(--danger); }
.btn[data-loading="1"] { color: transparent !important; position: relative; }
.btn[data-loading="1"]::after {
    content: "";
    position: absolute;
    width: 18px; height: 18px;
    border: 2px solid rgba(255,255,255,.45);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------- Badge / chip ---------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    background: var(--surface-2);
    color: var(--muted);
    border: 1px solid var(--border);
}
.badge-ok     { background: #dcfce7; color: #166534; border-color: #bbf7d0; }
.badge-warn   { background: #fef3c7; color: #92400e; border-color: #fde68a; }
.badge-danger { background: #fee2e2; color: #991b1b; border-color: #fecaca; }

/* ---------------- Formulir ---------------- */
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.input, select.input, textarea.input {
    width: 100%;
    min-height: 46px;
    padding: 11px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    font-family: inherit;
    font-size: 15px;
    color: var(--text);
    outline: none;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.input:focus { border-color: var(--brand-600); box-shadow: 0 0 0 3px rgba(13,148,136,.15); }

/* ---------------- Bottom navigation + FAB ---------------- */
.bottom-nav {
    position: fixed;
    left: 0; right: 0; bottom: 0;
    height: calc(var(--navbar-h) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    display: flex;
    background: var(--surface);
    border-top: 1px solid var(--border);
    z-index: 900;
}
.bottom-nav .nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    border: none;
    background: none;
    color: var(--muted-2);
    font-family: inherit;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
    padding: 6px 0;
}
.bottom-nav .nav-item .ico { font-size: 19px; line-height: 1; }
.bottom-nav .nav-item.active { color: var(--brand); }

.fab {
    position: fixed;
    right: 16px;
    bottom: calc(var(--navbar-h) + var(--safe-bottom) + 16px);
    width: 56px; height: 56px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand-600), var(--brand-700));
    color: #fff;
    font-size: 26px;
    line-height: 1;
    box-shadow: var(--shadow-lg);
    cursor: pointer;
    z-index: 950;
}
.fab:active { transform: scale(.95); }

/* ---------------- Toast ---------------- */
.toast-wrap {
    position: fixed;
    top: calc(var(--safe-top) + 10px);
    left: 12px; right: 12px;
    z-index: 3000;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: #1e293b;
    color: #fff;
    box-shadow: var(--shadow-lg);
    font-size: 13.5px;
    font-weight: 500;
    animation: toast-in .2s ease;
    pointer-events: auto;
}
.toast.out { animation: toast-out .18s ease forwards; }
.toast .t-ico { font-size: 15px; line-height: 1.35; }
.toast-ok     { background: #15803d; }
.toast-err    { background: #b91c1c; }
.toast-warn   { background: #b45309; }
.toast-info   { background: #1e293b; }
@keyframes toast-in  { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: none; } }
@keyframes toast-out { to { opacity: 0; transform: translateY(-10px); } }

/* ---------------- Loading / progress ---------------- */
.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 2500;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, .45);
    backdrop-filter: blur(2px);
}
.loading-overlay.show { display: flex; }
.loading-box {
    min-width: 220px;
    max-width: 320px;
    padding: 18px 20px;
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.spinner {
    width: 34px; height: 34px;
    margin: 0 auto 10px;
    border: 3px solid var(--brand-soft);
    border-top-color: var(--brand);
    border-radius: 50%;
    animation: spin .8s linear infinite;
}
.loading-text { font-size: 14px; font-weight: 600; }
.loading-sub  { font-size: 12px; color: var(--muted); margin-top: 3px; min-height: 16px; }
.progress { height: 6px; border-radius: 999px; background: var(--border); overflow: hidden; margin-top: 12px; }
.progress > i { display: block; height: 100%; width: 0%; background: var(--brand); transition: width .25s ease; }

/* ---------------- Skeleton & empty state ---------------- */
.skeleton {
    border-radius: var(--radius-sm);
    background: linear-gradient(90deg, #eef2f7 25%, #e2e8f0 37%, #eef2f7 63%);
    background-size: 400% 100%;
    animation: shimmer 1.3s ease infinite;
    min-height: 14px;
}
@keyframes shimmer { 0% { background-position: 100% 0; } 100% { background-position: 0 0; } }

.empty-state { text-align: center; padding: 40px 18px; color: var(--muted-2); }
.empty-state .ico { font-size: 44px; display: block; margin-bottom: 10px; opacity: .55; }
.empty-state .ttl { font-size: 14.5px; font-weight: 700; color: var(--muted); }
.empty-state .sub { font-size: 12.5px; margin-top: 4px; }

/* ---------------- Util kecil ---------------- */
.row { display: flex; align-items: center; gap: 10px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 12px; }
.mb-0 { margin-bottom: 0; }
.hide { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; word-break: break-all; }

/* ---------------- Layout halaman auth (login/registrasi) ---------------- */
.auth-wrap {
    min-height: 100vh;
    padding: calc(28px + var(--safe-top)) 16px calc(28px + var(--safe-bottom));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    background: linear-gradient(160deg, var(--brand-700) 0%, var(--brand) 42%, var(--bg) 42.1%, var(--bg) 100%);
}
.auth-card {
    width: 100%;
    max-width: 440px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: 22px 18px;
    margin-top: 6px;
}
.auth-brand { text-align: center; color: #fff; margin-bottom: 18px; }
.auth-brand .logo {
    width: 76px; height: 76px;
    margin: 0 auto 10px;
    border-radius: 20px;
    display: block;
    background: #fff;
    object-fit: contain;
    box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.auth-brand h1 { font-size: 22px; font-weight: 800; margin: 0; letter-spacing: .3px; }
.auth-brand p  { font-size: 12.5px; margin: 4px 0 0; opacity: .88; }
.auth-card .card-title { font-size: 16px; }
.auth-foot { text-align: center; font-size: 13px; color: var(--muted); margin-top: 14px; }

/* Kekuatan password */
.pw-meter { height: 5px; border-radius: 999px; background: var(--border); overflow: hidden; margin-top: 8px; }
.pw-meter > i { display: block; height: 100%; width: 0%; background: var(--danger); transition: width .2s ease, background .2s ease; }
.pw-hint { font-size: 11.5px; color: var(--muted); margin-top: 5px; }
.field .err-msg { font-size: 11.5px; color: var(--danger); margin-top: 5px; display: none; }
.field.has-error .input { border-color: var(--danger); }
.field.has-error .err-msg { display: block; }

/* Banner masa berlaku */
.banner {
    display: flex; align-items: flex-start; gap: 10px;
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 13px;
    margin-bottom: 12px;
}
.banner .b-ico { font-size: 17px; line-height: 1.3; }
.banner-ok     { background: #dcfce7; border-color: #bbf7d0; color: #166534; }
.banner-warn   { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.banner-danger { background: #fee2e2; border-color: #fecaca; color: #991b1b; }

/* =====================================================================
   Panel Super Admin (Sprint 3) — layout desktop, tetap rapi di mobile
   ===================================================================== */
.admin-head {
    position: sticky; top: 0; z-index: 40;
    display: flex; align-items: center; gap: 12px;
    padding: calc(11px + var(--safe-top)) 18px 11px;
    background: linear-gradient(135deg, var(--brand-700), var(--brand));
    color: #fff;
    box-shadow: var(--shadow);
}
.admin-head img { width: 34px; height: 34px; border-radius: 10px; background: #fff; object-fit: contain; flex: 0 0 auto; }
.admin-head .a-title { font-size: 15px; font-weight: 800; margin: 0; letter-spacing: .2px; }
.admin-head .a-sub   { font-size: 11.5px; opacity: .85; }
.admin-head .a-right { margin-left: auto; display: flex; align-items: center; gap: 10px; }
.admin-user { font-size: 12.5px; opacity: .95; white-space: nowrap; }

.admin-main { max-width: 1180px; margin: 0 auto; padding: 18px 16px calc(24px + var(--safe-bottom)); }

/* Kartu ringkasan */
.stat-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.stat-card {
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 12px 14px; box-shadow: var(--shadow-sm);
}
.stat-card .s-label { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat-card .s-val { font-size: 25px; font-weight: 800; line-height: 1.15; margin-top: 4px; }
.stat-card.is-pending   .s-val { color: var(--warn); }
.stat-card.is-aktif     .s-val { color: var(--ok); }
.stat-card.is-kadaluarsa .s-val { color: var(--danger); }

/* Toolbar filter */
.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.toolbar .input, .toolbar select.input { height: 40px; margin: 0; }
.toolbar .grow { flex: 1 1 220px; min-width: 180px; }

/* Tabel data (header sticky) */
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); }
.table-scroll { max-height: 64vh; overflow: auto; }
table.data { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13px; }
table.data thead th {
    position: sticky; top: 0; z-index: 2;
    background: var(--surface-2); color: var(--muted);
    font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px;
    text-align: left; padding: 10px 12px; white-space: nowrap;
    border-bottom: 1px solid var(--border);
}
table.data tbody td { padding: 10px 12px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data tbody tr:hover { background: var(--surface-2); }
table.data tbody tr:last-child td { border-bottom: 0; }
table.data .col-act { text-align: right; white-space: nowrap; }
table.data .kv { font-weight: 600; }
table.data .sub { font-size: 11.5px; color: var(--muted); }

/* Tombol kecil */
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 9px; }
.btn-warn { background: var(--warn); }
.btn-ok { background: var(--ok); }
.btn-outline { background: transparent; color: var(--text); border-color: var(--border); }
.btn + .btn-sm { margin-left: 4px; }

/* Chip pilihan cepat */
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip {
    border: 1px solid var(--border); background: var(--surface-2); color: var(--text);
    padding: 5px 11px; border-radius: 999px; font-size: 12px; cursor: pointer;
}
.chip:hover { border-color: var(--brand-600); color: var(--brand); }

/* Modal */
.modal {
    position: fixed; inset: 0; z-index: 60;
    display: none; align-items: center; justify-content: center;
    padding: 16px;
    background: rgba(15, 23, 42, .55);
    backdrop-filter: blur(2px);
}
.modal.show { display: flex; }
.modal-box {
    width: 100%; max-width: 520px; max-height: 92vh; overflow: auto;
    background: var(--surface); border: 1px solid var(--border);
    border-radius: var(--radius-lg); box-shadow: var(--shadow-lg);
}
.modal-box.wide { max-width: 680px; }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 15px 18px; border-bottom: 1px solid var(--border); }
.modal-head h3 { margin: 0; font-size: 15px; font-weight: 700; }
.modal-head .x { margin-left: auto; border: 0; background: transparent; font-size: 20px; line-height: 1; color: var(--muted); cursor: pointer; }
.modal-body { padding: 16px 18px; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 13px 18px; border-top: 1px solid var(--border); background: var(--surface-2); }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* Riwayat perpanjangan */
.riwayat { list-style: none; margin: 0; padding: 0; }
.riwayat li { display: flex; gap: 10px; padding: 9px 0; border-bottom: 1px dashed var(--border); font-size: 12.5px; }
.riwayat li:last-child { border-bottom: 0; }
.riwayat .r-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; background: var(--brand-600); margin-top: 6px; }

@media (max-width: 820px) {
    .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    table.data { font-size: 12.5px; }
    table.data thead th, table.data tbody td { padding: 9px 10px; }
    .grid-2 { grid-template-columns: 1fr; }
}

/* ---------------- Dark mode (FR: §14.8) ---------------- */
@media (prefers-color-scheme: dark) {
    :root {
        --bg:        #0b1220;
        --surface:   #131c2e;
        --surface-2: #1b2537;
        --border:    #263349;
        --text:      #e6edf7;
        --muted:     #9fb0c7;
        --muted-2:   #7c8ba3;
        --shadow-sm: 0 1px 2px rgba(0,0,0,.4);
        --shadow:    0 6px 20px rgba(0,0,0,.45);
        --shadow-lg: 0 14px 40px rgba(0,0,0,.55);
    }
    .btn-light { background: var(--surface-2); color: var(--text); }
    .skeleton { background: linear-gradient(90deg, #1b2537 25%, #263349 37%, #1b2537 63%); background-size: 400% 100%; }
}
