/* =========================================================
   Absensi QR — stylesheet (mobile-first, responsif semua device)
   ========================================================= */

:root {
    --brand: #2f6fdd;
    --brand-dark: #2458b3;
    --brand-soft: #e8f0fd;
    --ink: #1f2937;
    --muted: #6b7280;
    --bg: #f4f7fb;
    --border: #e5e9f0;
    --radius: 16px;
    --shadow: 0 8px 24px rgba(31, 41, 55, .07);
}

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

html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

body {
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--ink);
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
}

/* Watermark halus di belakang konten */
body::before {
    content: "";
    position: fixed;
    inset: 0;
    background: url('../img/watermark.png') no-repeat center center;
    background-size: min(60%, 520px);
    opacity: .04;
    z-index: -1;
    pointer-events: none;
}

img, svg, video, canvas { max-width: 100%; height: auto; }

h1, h2, h3, h4, h5, h6 { color: #111827; font-weight: 700; }

a { color: var(--brand); }

/* ---------- Layout ---------- */
.app-main { flex: 1 0 auto; padding-top: 1.25rem; padding-bottom: 2rem; }
.container-narrow { max-width: 640px; }
.app-footer { font-size: .8rem; padding: 1rem .75rem calc(1rem + env(safe-area-inset-bottom)); }

.page-title { font-size: clamp(1.35rem, 1.1rem + 1.2vw, 1.9rem); margin-bottom: .25rem; }
.page-sub { color: var(--muted); margin-bottom: 1.25rem; }

/* ---------- Navbar ---------- */
.navbar-custom {
    background: linear-gradient(135deg, var(--brand), #4f8df0);
    box-shadow: 0 4px 16px rgba(47, 111, 221, .25);
    padding-top: calc(.5rem + env(safe-area-inset-top));
    padding-bottom: .5rem;
}
.navbar-custom .navbar-brand { color: #fff; }
.navbar-custom .nav-link { color: rgba(255, 255, 255, .85); font-weight: 500; border-radius: 10px; padding: .55rem .85rem; }
.navbar-custom .nav-link:hover { color: #fff; background: rgba(255, 255, 255, .12); }
.navbar-custom .nav-link.active { color: #fff; background: rgba(255, 255, 255, .2); }
.navbar-custom .navbar-toggler { border-color: rgba(255, 255, 255, .5); min-height: 44px; min-width: 44px; }
.nav-name { max-width: 180px; }
@media (max-width: 991.98px) {
    .navbar-collapse { padding: .5rem 0 .25rem; }
    .nav-user { justify-content: space-between; border-top: 1px solid rgba(255, 255, 255, .25); margin-top: .5rem; padding-top: .75rem; }
    .nav-name { max-width: 60%; }
}

/* ---------- Card ---------- */
.card { border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); background: #fff; }

.feature-card { display: flex; flex-direction: column; transition: transform .15s ease, box-shadow .15s ease; }
@media (hover: hover) { .feature-card:hover { transform: translateY(-3px); box-shadow: 0 14px 30px rgba(31, 41, 55, .1); } }
.feature-icon {
    width: 52px; height: 52px; border-radius: 14px; background: var(--brand-soft);
    display: flex; align-items: center; justify-content: center; font-size: 1.6rem; margin-bottom: .9rem;
}

.stat-card .stat-num { font-size: clamp(1.4rem, 1rem + 2vw, 2.2rem); font-weight: 800; line-height: 1.1; }
.stat-card .stat-label { font-size: .8rem; color: var(--muted); }

/* ---------- Buttons & form (nyaman disentuh) ---------- */
.btn { min-height: 44px; display: inline-flex; align-items: center; justify-content: center; gap: .35rem; font-weight: 600; border-radius: 12px; }
.btn-sm { min-height: 36px; border-radius: 10px; }
.btn-primary { background-color: var(--brand); border-color: var(--brand); }
.btn-primary:hover, .btn-primary:focus { background-color: var(--brand-dark); border-color: var(--brand-dark); }
.btn-outline-primary { color: var(--brand); border-color: var(--brand); }
.btn-outline-primary:hover { background-color: var(--brand); border-color: var(--brand); }

.form-control, .form-select { border-radius: 12px; min-height: 44px; font-size: 16px; /* cegah zoom otomatis iOS */ }
.form-control:focus, .form-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(47, 111, 221, .2); }
textarea.form-control { min-height: 96px; }
.form-label { font-weight: 600; font-size: .9rem; }

.alert { border-radius: 12px; font-size: .95rem; }
.badge { font-weight: 600; }

/* ---------- Tabel: jadi kartu bertumpuk di layar kecil ---------- */
.table { --bs-table-bg: transparent; }
.table th { white-space: nowrap; font-size: .85rem; }
.cell-wrap { min-width: 180px; }
.cell-actions { white-space: nowrap; text-align: right; }
.cell-actions form { margin: 0; }

@media (max-width: 767.98px) {
    .table-stack thead { display: none; }
    .table-stack, .table-stack tbody, .table-stack tr, .table-stack td { display: block; width: 100%; }
    .table-stack tr {
        border: 1px solid var(--border);
        border-radius: 14px;
        padding: .35rem .85rem;
        margin-bottom: .75rem;
        background: #fff;
    }
    .table-stack td {
        display: flex; justify-content: space-between; align-items: center; gap: 1rem;
        padding: .45rem 0; border: 0; border-bottom: 1px dashed var(--border);
        text-align: right; word-break: break-word; box-shadow: none; background: transparent;
    }
    .table-stack td:last-child { border-bottom: 0; }
    .table-stack td::before {
        content: attr(data-label); font-weight: 600; color: var(--muted);
        text-align: left; flex: 0 0 38%; font-size: .85rem;
    }
    .table-stack td[colspan] { justify-content: center; }
    .table-stack td[colspan]::before { display: none; }
    .table-stack td.cell-actions { justify-content: flex-end; flex-wrap: wrap; gap: .5rem; }
    .table-stack td.cell-actions::before { display: none; }
    .table-stack td.cell-wrap { min-width: 0; }
}

/* ---------- Landing ---------- */
.hero { padding: clamp(1.5rem, 6vw, 4rem) 0 1rem; }
.hero-badge {
    display: inline-block; background: var(--brand-soft); color: var(--brand-dark);
    border-radius: 999px; padding: .35rem .9rem; font-size: .85rem; font-weight: 600; margin-bottom: 1rem;
}
.hero-title { font-size: clamp(1.9rem, 1.2rem + 3.5vw, 3.2rem); font-weight: 800; line-height: 1.15; }
.hero-lead { max-width: 640px; margin: 1rem auto 0; color: var(--muted); font-size: clamp(1rem, .95rem + .3vw, 1.15rem); }
.text-gradient { background: linear-gradient(135deg, var(--brand), #7b61ff); -webkit-background-clip: text; background-clip: text; color: transparent; }

/* ---------- Login ---------- */
.auth-page .app-main { display: flex; align-items: center; justify-content: center; width: 100%; }
.auth-wrap { width: 100%; max-width: 440px; margin: 0 auto; }
.auth-logo {
    width: 64px; height: 64px; border-radius: 18px; background: var(--brand-soft);
    display: inline-flex; align-items: center; justify-content: center; font-size: 2rem; margin-bottom: .75rem;
}

/* ---------- QR & scanner ---------- */
.qr-box { width: min(100%, 340px); padding: 12px; background: #fff; border: 1px solid var(--border); border-radius: 18px; }
.qr-img { width: 100%; height: auto; image-rendering: pixelated; display: block; }

.scanner-box { width: 100%; max-width: 480px; margin: 0 auto; border-radius: 14px; overflow: hidden; background: #0b1220; min-height: 260px; }
#reader { width: 100%; }
#reader video { width: 100% !important; height: auto !important; border-radius: 14px; }
#reader__scan_region img { margin: 0 auto; }

.scan-result { border-radius: 14px; padding: 1rem 1.1rem; margin-bottom: 1rem; font-weight: 600; border: 1px solid transparent; }
.scan-result.success { background: #e7f7ee; color: #146c43; border-color: #b7e4c7; }
.scan-result.warning { background: #fff6e0; color: #8a6100; border-color: #ffe3a3; }
.scan-result.error   { background: #fdeaea; color: #a52828; border-color: #f5c2c2; }

/* ---------- Layar sangat kecil ---------- */
@media (max-width: 575.98px) {
    .app-main { padding-top: 1rem; }
    .card.p-4 { padding: 1.1rem !important; }
    .feature-icon { width: 46px; height: 46px; font-size: 1.4rem; }
}

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

/* ---------- Status terkunci / sudah absen / saklar izin ---------- */
.navbar-custom .nav-link.disabled { color: rgba(255, 255, 255, .6); cursor: not-allowed; pointer-events: auto; }
.feature-locked { opacity: .85; background: #f8f9fb; }
.feature-locked .feature-icon { filter: grayscale(.6); }
.absen-done { background: #e7f7ee; border: 1px solid #b7e4c7; border-radius: 16px; padding: 1.5rem 1rem; }
.absen-done-icon { font-size: 2.5rem; line-height: 1; margin-bottom: .5rem; }
.izin-switch.is-on  { border-left: 5px solid #198754; }
.izin-switch.is-off { border-left: 5px solid #6c757d; }

/* ---------- QR kelas (layar admin/petugas) ---------- */
.qr-display { width: min(100%, 420px); padding: 14px; background: #fff; border: 1px solid var(--border); border-radius: 18px; }
.qr-display .qr-img { min-height: 200px; }
#qr-stage:fullscreen { display: flex; flex-direction: column; align-items: center; justify-content: center; background: #fff; border-radius: 0; padding: 2rem; }
#qr-stage:fullscreen .qr-display { width: min(90vmin, 720px); border: 0; }

@media print {
    .navbar, .app-footer, .no-print, .alert { display: none !important; }
    body::before { display: none; }
    .card { box-shadow: none; border: 0; }
    .col-lg-6 { width: 100% !important; }
}
