/* =========================================================================
   SMART Absensi Medsos — tampilan Material 3 (Android app shell)

   Catatan teknis:
   - Tidak ada aset eksternal: tanpa Tailwind CDN, tanpa Google Fonts, tanpa
     inline style/script. Semua gaya ada di berkas ini agar CSP tetap ketat
     (default-src 'self'; style-src 'self'; script-src 'self').
   - Ikon memakai SVG inline di HTML (bagian dari dokumen, bukan aset luar).
   - Tata letak: app bar tetap, hanya .app-main yang bergulir, bottom
     navigation sebagai bagian kerangka (bukan overlay).
   - Di layar lebar aplikasi dibingkai seperti perangkat (lebar 420px).
   ========================================================================= */

:root {
    color-scheme: light dark;

    /* Material 3 — peran warna (light) */
    --primary: #4355b9;
    --on-primary: #ffffff;
    --primary-container: #dee0ff;
    --on-primary-container: #00105c;
    --secondary-container: #e0e0f9;
    --on-secondary-container: #161935;
    --surface: #fbf8fd;
    --surface-lowest: #ffffff;
    --surface-low: #f6f2fa;
    --surface-container: #f0ecf4;
    --surface-high: #eae6ee;
    --surface-highest: #e4e0e8;
    --on-surface: #1b1b1f;
    --on-surface-variant: #46464f;
    --outline: #767680;
    --outline-variant: #c7c5d0;
    --success: #0b7a55;
    --success-container: #d5f4e5;
    --error: #b3261e;
    --error-container: #f9dedc;
    --warning-container: #fbe0c0;

    --page-bg: #12131a;
    --hero-from: #3b4ecc;
    --hero-via: #4657cb;
    --hero-to: #5b6be4;

    --radius-xl: 28px;
    --radius-lg: 24px;
    --radius-md: 16px;
    --radius-sm: 12px;

    --elevation-1:
        0 1px 3px 1px rgba(0, 0, 0, 0.08), 0 1px 2px 0 rgba(0, 0, 0, 0.12);
    --elevation-2:
        0 2px 6px 2px rgba(0, 0, 0, 0.08), 0 1px 2px 0 rgba(0, 0, 0, 0.14);
    --elevation-3:
        0 4px 8px 3px rgba(0, 0, 0, 0.1), 0 1px 3px 0 rgba(0, 0, 0, 0.15);

    --focus: 0 0 0 3px rgba(67, 85, 185, 0.32);
    --press: rgba(67, 85, 185, 0.12);
    --tabbar-height: 76px;
}

@media (prefers-color-scheme: dark) {
    :root {
        --primary: #bac3ff;
        --on-primary: #0b1b6b;
        --primary-container: #2a3a8f;
        --on-primary-container: #dee0ff;
        --secondary-container: #3a3d5c;
        --on-secondary-container: #e0e0f9;
        --surface: #141318;
        --surface-lowest: #1b1a20;
        --surface-low: #1f1e24;
        --surface-container: #24232a;
        --surface-high: #2b2a31;
        --surface-highest: #34333b;
        --on-surface: #e6e1e9;
        --on-surface-variant: #c7c5d0;
        --outline: #8f8d97;
        --outline-variant: #46464f;
        --success: #6fdcae;
        --success-container: #0b3d2b;
        --error: #ffb4ab;
        --error-container: #601410;
        --warning-container: #5c3a12;

        --page-bg: #0b0b10;
        --focus: 0 0 0 3px rgba(186, 195, 255, 0.35);
        --press: rgba(186, 195, 255, 0.16);

        --elevation-1:
            0 1px 3px 1px rgba(0, 0, 0, 0.4), 0 1px 2px 0 rgba(0, 0, 0, 0.4);
        --elevation-2:
            0 2px 6px 2px rgba(0, 0, 0, 0.45), 0 1px 2px 0 rgba(0, 0, 0, 0.45);
        --elevation-3:
            0 4px 10px 3px rgba(0, 0, 0, 0.5), 0 1px 3px 0 rgba(0, 0, 0, 0.5);
    }
}

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

html {
    height: 100%;
    -webkit-text-size-adjust: 100%;
    background: var(--page-bg);
}

html,
body {
    margin: 0;
}

/* Di layar lebar, aplikasi dibingkai seperti perangkat. */
@media (min-width: 640px) {
    html {
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 16px;
    }
}

body {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    height: 100dvh;
    margin: 0 auto;
    overflow: hidden;
    background: var(--surface);
    color: var(--on-surface);
    font-family:
        Roboto,
        "Segoe UI",
        system-ui,
        -apple-system,
        "Helvetica Neue",
        Arial,
        sans-serif;
    font-size: 16px;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    touch-action: manipulation;
    overscroll-behavior: none;
}

@media (min-width: 640px) {
    body {
        max-width: 420px;
        height: min(920px, calc(100dvh - 32px));
        border-radius: 40px;
        border: 1px solid rgba(148, 163, 184, 0.18);
        box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
    }
}

/* Teks tetap dapat dipilih di kolom isian dan data yang perlu disalin. */
input,
textarea,
.summary dd,
.history__meta dd,
.stat__value {
    -webkit-user-select: text;
    user-select: text;
}

[hidden] {
    display: none !important;
}

/* Ikon SVG inline mewarisi warna teks. */
.icon {
    display: inline-block;
    fill: currentColor;
}

.visually-hidden {
    position: fixed;
    top: 0;
    left: 0;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
    padding: 0;
    margin: 0;
}

.skip-link {
    position: fixed;
    top: -80px;
    left: 12px;
    z-index: 100;
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    background: var(--primary);
    color: var(--on-primary);
    font-weight: 600;
    text-decoration: none;
    transition: top 0.15s ease-in-out;
}

.skip-link:focus {
    top: calc(12px + env(safe-area-inset-top));
}

:focus-visible {
    outline: none;
    box-shadow: var(--focus);
    border-radius: var(--radius-sm);
}

/* ── App bar ────────────────────────────────────────────────────────── */

.app-header {
    position: relative;
    z-index: 30;
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: calc(8px + env(safe-area-inset-top)) 16px 10px;
    background: var(--surface);
}

.app-header__brand {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.app-header__tile {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 16px;
    background: linear-gradient(135deg, #3b4ecc, #5b6be4);
    box-shadow: 0 6px 16px rgba(67, 85, 185, 0.3);
}

.app-header__logo {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    display: block;
}

.app-header__name {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--on-surface);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.app-header__meta {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 2px 0 0;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--on-surface-variant);
    white-space: nowrap;
    overflow: hidden;
}

.app-header__dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
    flex: none;
}

.app-header .btn {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 7px 12px;
    border-radius: 999px;
    border: 1px solid rgba(67, 85, 185, 0.22);
    background: rgba(67, 85, 185, 0.1);
    color: var(--primary);
    font-size: 0.72rem;
    font-weight: 600;
    box-shadow: none;
}

.app-header .btn:hover:not(:disabled) {
    background: rgba(67, 85, 185, 0.16);
}

.app-header .btn .icon {
    width: 16px;
    height: 16px;
}

/* ── Area konten ────────────────────────────────────────────────────── */

.app-main {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    padding: 4px 16px 20px;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior-y: contain;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.app-main::-webkit-scrollbar {
    width: 0;
    height: 0;
}

@media (min-width: 640px) {
    .app-main {
        scrollbar-width: thin;
    }

    .app-main::-webkit-scrollbar {
        width: 6px;
    }

    .app-main::-webkit-scrollbar-thumb {
        border-radius: 999px;
        background: var(--outline-variant);
    }
}

.view {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding-top: 2px;
}

.view__header {
    padding: 4px 4px 0;
}

.view__header--actions {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

.view__heading {
    flex: 1 1 auto;
    min-width: 0;
}

.view__actions {
    display: flex;
    flex: 0 0 auto;
    gap: 6px;
    margin-left: auto;
    text-align: right;
    justify-content: flex-end;
}

.view__actions .btn {
    min-height: 38px;
    padding: 8px 14px;
    font-size: 0.78rem;
    white-space: nowrap;
}

.view__header h1 {
    margin: 0 0 4px;
    font-size: 1.35rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.view__desc {
    margin: 0;
    color: var(--on-surface-variant);
    font-size: 0.82rem;
    line-height: 1.45;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

@media (min-width: 560px) {
    .grid-2 {
        grid-template-columns: 1fr 1fr;
    }
}

/* ── Kartu ──────────────────────────────────────────────────────────── */

.card {
    background: var(--surface-lowest);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: var(--radius-lg);
    padding: 18px;
    box-shadow: var(--elevation-1);
}

.card__title {
    margin: 0 0 12px;
    font-size: 0.86rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: var(--on-surface-variant);
}

/* Hero */

.hero {
    position: relative;
    overflow: hidden;
    border: none;
    padding: 22px 20px 20px;
    border-radius: var(--radius-xl);
    background: linear-gradient(
        135deg,
        var(--hero-from) 0%,
        var(--hero-via) 55%,
        var(--hero-to) 100%
    );
    color: #ffffff;
    box-shadow: var(--elevation-2);
}

.hero::before,
.hero::after {
    content: "";
    position: absolute;
    border-radius: 50%;
    pointer-events: none;
}

.hero::before {
    top: -60px;
    right: -60px;
    width: 200px;
    height: 200px;
    background: rgba(255, 255, 255, 0.12);
    filter: blur(28px);
}

.hero::after {
    bottom: -70px;
    left: -50px;
    width: 200px;
    height: 200px;
    background: rgba(30, 27, 120, 0.45);
    filter: blur(24px);
}

.hero > * {
    position: relative;
    z-index: 1;
}

.hero__chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 12px;
    padding: 5px 12px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: rgba(237, 240, 255, 0.92);
}

.hero__chip .icon {
    width: 14px;
    height: 14px;
}

.hero__eyebrow {
    margin: 0;
    font-size: 0.66rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.hero__title {
    margin: 0 0 8px;
    font-size: 1.5rem;
    font-weight: 800;
    line-height: 1.2;
    letter-spacing: -0.02em;
    color: #ffffff;
}

.hero__desc {
    margin: 0;
    font-size: 0.82rem;
    line-height: 1.5;
    color: rgba(226, 232, 255, 0.9);
}

.hero__actions {
    display: grid;
    gap: 10px;
    margin-top: 18px;
}

.hero__actions .btn {
    width: 100%;
    min-height: 50px;
    border-radius: var(--radius-md);
}

.hero .btn--primary {
    background: #ffffff;
    border-color: #ffffff;
    color: var(--primary);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
}

.hero .btn--primary:hover:not(:disabled) {
    background: #f4f6ff;
}

.hero .btn--secondary {
    background: rgba(255, 255, 255, 0.16);
    border-color: rgba(255, 255, 255, 0.28);
    color: #ffffff;
}

.hero .btn--secondary:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.24);
}

.hero__note {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.16);
}

.hero__note .icon {
    flex: none;
    width: 16px;
    height: 16px;
    margin-top: 2px;
    color: #f7d27a;
}

.hero .hint {
    margin: 0;
    color: rgba(226, 232, 255, 0.86);
}

/* Statistik */

.stat__head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 12px;
}

.stat__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    flex: none;
    border-radius: 12px;
    background: var(--primary-container);
    color: var(--on-primary-container);
}

.stat__icon .icon {
    width: 18px;
    height: 18px;
}

.stat__head .card__title {
    margin: 0;
}

.stat__value {
    margin: 0 0 4px;
    font-size: 1.12rem;
    font-weight: 700;
    overflow-wrap: anywhere;
}

.stat__detail {
    margin: 0;
    font-size: 0.8rem;
    line-height: 1.45;
    color: var(--on-surface-variant);
}

/* Ringkasan */

.summary {
    margin: 0;
    display: grid;
    grid-template-columns: minmax(112px, 42%) 1fr;
    font-size: 0.85rem;
    background: var(--surface-low);
    border-radius: var(--radius-md);
    padding: 2px 14px;
}

.summary dt,
.summary dd {
    margin: 0;
    padding: 10px 0;
    border-bottom: 1px solid var(--outline-variant);
}

.summary dt {
    color: var(--on-surface-variant);
    font-weight: 500;
}

.summary dd {
    overflow-wrap: anywhere;
    font-weight: 600;
    text-align: right;
}

.summary > *:nth-last-child(-n + 2) {
    border-bottom: none;
}

.summary dd.is-empty {
    color: var(--outline);
    font-weight: 500;
    font-style: italic;
}

.hint {
    margin: 10px 0 0;
    font-size: 0.78rem;
    line-height: 1.5;
    color: var(--on-surface-variant);
}

/* ── Pemberitahuan ──────────────────────────────────────────────────── */

.alert {
    flex: none;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin: 8px 16px 0;
    padding: 12px 14px;
    border-radius: var(--radius-md);
    font-size: 0.84rem;
    border: 1px solid transparent;
}

.app-main .alert {
    margin: 0;
}

.alert p {
    margin: 0;
}

.alert--info {
    background: var(--secondary-container);
    border-color: rgba(67, 85, 185, 0.24);
    color: var(--on-secondary-container);
}

.alert--error {
    background: var(--error-container);
    border-color: rgba(179, 38, 30, 0.28);
    color: var(--error);
}

/* ── Kolom isian ────────────────────────────────────────────────────── */

.field-group {
    margin-bottom: 16px;
}

.field {
    display: block;
    margin-bottom: 6px;
    font-size: 0.78rem;
    font-weight: 600;
    letter-spacing: 0.01em;
    color: var(--on-surface-variant);
}

.input-row {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.input {
    width: 100%;
    min-width: 0;
    min-height: 54px;
    padding: 14px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    background: var(--surface-container);
    color: var(--on-surface);
    font: inherit;
    font-size: 0.94rem;
    transition:
        border-color 0.15s ease,
        background-color 0.15s ease;
}

.input:focus {
    border-color: var(--primary);
    background: var(--surface-lowest);
}

.input::placeholder {
    color: var(--outline);
}

.input[aria-invalid="true"] {
    border-color: var(--error);
}

.field-error {
    margin: 6px 0 0;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--error);
}

.source {
    margin: 8px 0 0;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--on-surface-variant);
}

/* ── Tombol ─────────────────────────────────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 48px;
    padding: 12px 18px;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    font: inherit;
    font-size: 0.92rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    touch-action: manipulation;
    transition:
        background-color 0.15s ease,
        border-color 0.15s ease,
        transform 0.12s ease;
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn .icon {
    width: 20px;
    height: 20px;
    flex: none;
}

.btn--primary {
    background: var(--primary);
    color: var(--on-primary);
    box-shadow: 0 6px 16px rgba(67, 85, 185, 0.24);
}

.btn--primary:hover:not(:disabled) {
    filter: brightness(1.06);
}

.btn--secondary {
    background: var(--secondary-container);
    color: var(--on-secondary-container);
}

.btn--ghost {
    background: var(--surface-low);
    border-color: rgba(148, 163, 184, 0.24);
    color: var(--on-surface);
}

.btn--ghost:hover:not(:disabled) {
    background: var(--surface-container);
}

.btn--danger-ghost {
    background: transparent;
    border-color: rgba(179, 38, 30, 0.4);
    color: var(--error);
}

.btn--danger-ghost:hover:not(:disabled) {
    background: var(--error-container);
}

.btn--small {
    min-height: 36px;
    padding: 7px 14px;
    font-size: 0.78rem;
    border-radius: 999px;
}

.btn--icon {
    flex: none;
    min-height: auto;
    padding: 0 14px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

.btn--wide {
    width: 100%;
}

.btn--file {
    position: relative;
    overflow: hidden;
}

.btn--file input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
    font-size: 0;
}

.button-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 14px;
}

/* ── Lencana & riwayat ─────────────────────────────────────────────── */

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.01em;
}

.badge--opened {
    background: var(--primary-container);
    color: var(--on-primary-container);
}

.badge--prepared {
    background: var(--success-container);
    color: var(--success);
}

.history {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 10px;
}

.history__item {
    background: var(--surface-lowest);
    border: 1px solid rgba(148, 163, 184, 0.16);
    border-radius: var(--radius-lg);
    padding: 14px 16px;
    box-shadow: var(--elevation-1);
    transition: background-color 0.15s ease;
}

.history__item:active {
    background: var(--surface-low);
}

.history__head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
}

.history__time {
    font-weight: 700;
    font-size: 0.85rem;
}

.history__meta {
    margin: 0;
    display: grid;
    grid-template-columns: minmax(112px, 44%) 1fr;
    gap: 6px 12px;
    font-size: 0.8rem;
}

.history__meta dt {
    color: var(--on-surface-variant);
    font-weight: 500;
}

.history__meta dd {
    margin: 0;
    font-weight: 600;
    text-align: right;
    overflow-wrap: anywhere;
}

.empty {
    text-align: center;
    color: var(--on-surface-variant);
}

/* ── Bottom navigation ─────────────────────────────────────────────── */

.tabbar {
    flex: none;
    z-index: 40;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    padding: 6px 12px 0;
    padding-bottom: calc(4px + env(safe-area-inset-bottom));
    background: var(--surface-lowest);
    border-top: 1px solid rgba(148, 163, 184, 0.2);
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.06);
}

.tabbar__btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    min-height: 56px;
    padding: 4px 2px;
    border: none;
    border-radius: var(--radius-md);
    background: transparent;
    color: var(--on-surface-variant);
    font: inherit;
    font-size: 0.7rem;
    font-weight: 500;
    cursor: pointer;
    transition: color 0.15s ease;
}

.tabbar__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 32px;
    border-radius: 999px;
    transition:
        background-color 0.18s ease,
        transform 0.18s ease;
}

.tabbar__icon svg {
    width: 22px;
    height: 22px;
    fill: currentColor;
}

.tabbar__btn:active .tabbar__icon {
    background: var(--press);
    transform: scale(0.94);
}

.tabbar__label {
    line-height: 1.1;
    letter-spacing: 0.01em;
}

.tabbar__btn[aria-current="page"] {
    color: var(--on-secondary-container);
    font-weight: 700;
}

.tabbar__btn[aria-current="page"] .tabbar__icon {
    background: var(--secondary-container);
}

/* Indikator gestur bawah (dekoratif, seperti aplikasi Android). */
.tabbar__handle {
    grid-column: 1 / -1;
    width: 96px;
    height: 4px;
    margin: 8px auto 6px;
    border-radius: 999px;
    background: var(--outline-variant);
    opacity: 0.7;
}

/* ── Toast ──────────────────────────────────────────────────────────── */

.toast {
    position: fixed;
    left: 50%;
    bottom: calc(var(--tabbar-height) + 12px + env(safe-area-inset-bottom));
    transform: translateX(-50%);
    z-index: 50;
    width: min(380px, calc(100% - 24px));
    padding: 13px 16px;
    border-radius: var(--radius-md);
    background: #1f2430;
    color: #ffffff;
    font-size: 0.82rem;
    line-height: 1.45;
    box-shadow: var(--elevation-3);
    -webkit-user-select: none;
    user-select: none;
}

.toast--success {
    background: #0f5132;
}

.toast--error {
    background: #7a271a;
}

.toast--warning {
    background: #7a3e0e;
}

/* ── Preferensi gerak ───────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        transition: none !important;
        animation: none !important;
    }

    .btn:active:not(:disabled),
    .tabbar__btn:active .tabbar__icon {
        transform: none;
    }
}
