/* =====================================================================
   STAPROGS - Mobile-first & PWA. Dimuat SETELAH style.css.
   ===================================================================== */
:root { --bn-h: 64px; --safe-t: env(safe-area-inset-top, 0px); --safe-b: env(safe-area-inset-bottom, 0px); }
html { -webkit-text-size-adjust: 100%; }
body { -webkit-tap-highlight-color: transparent; }
body.bare { padding-top: max(1rem, var(--safe-t)); padding-bottom: max(1rem, var(--safe-b)); }

/* ---- Animasi ringan (dimatikan bila pengguna memilih "kurangi gerakan") ---- */
@keyframes stFadeUp { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
/* fill-mode 'backwards' (bukan 'both'): setelah animasi selesai, main tidak lagi jadi lapisan tersendiri. Dengan 'both', modal di dalam main terkunci DI BAWAH lapisan gelap (backdrop) Bootstrap sehingga layar gelap dan tidak bisa diklik. */
main { animation: stFadeUp .22s ease-out backwards; }
.btn { transition: transform .08s ease, background-color .15s ease, border-color .15s ease, box-shadow .15s ease; }
.btn:active:not(:disabled) { transform: scale(.97); }
.card { transition: box-shadow .15s ease; }
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---- Topbar aman dari notch / status bar ---- */
.topbar {
    height: auto; min-height: calc(60px + var(--safe-t)); padding-top: var(--safe-t);
    padding-left: max(1rem, env(safe-area-inset-left, 0px)); padding-right: max(1rem, env(safe-area-inset-right, 0px));
}

/* ---- Login modern ---- */
.auth-modern { border-radius: 20px; overflow: hidden; }
.brand-logo {
    width: 72px; height: 72px; border-radius: 20px; display: grid; place-items: center; font-size: 2.1rem; color: #fff;
    background: linear-gradient(160deg, #1e88e5, #0b1f45); box-shadow: 0 10px 24px rgba(13,71,161,.35);
}
.auth-modern .form-control:focus, .auth-modern .form-select:focus { box-shadow: 0 0 0 .2rem rgba(13,110,253,.18); }
.btn-pw-toggle { border-color: #ced4da; background: #fff; color: #5d6b82; }

/* ---- Navigasi bawah (hanya layar kecil) ---- */
.bottom-nav { display: none; }

/* ---- Banner pasang aplikasi, bilah offline, toast pembaruan ---- */
.pwa-banner {
    position: fixed; left: .75rem; right: .75rem; bottom: calc(var(--bn-h) + var(--safe-b) + .75rem); z-index: 1035;
    background: #fff; border: 1px solid #dfe7f1; border-radius: 16px; padding: .8rem .9rem; display: none;
    box-shadow: 0 10px 30px rgba(18,38,63,.18); animation: stFadeUp .25s ease-out both;
}
.pwa-banner.show { display: flex; align-items: center; gap: .75rem; }
.pwa-banner img { width: 44px; height: 44px; border-radius: 11px; flex-shrink: 0; }
body.bare .pwa-banner { bottom: calc(var(--safe-b) + .75rem); }
.offline-bar {
    position: fixed; top: 0; left: 0; right: 0; z-index: 2000; background: #b02a37; color: #fff; text-align: center; font-size: .85rem;
    padding: calc(.4rem + var(--safe-t)) .5rem .4rem; transform: translateY(-110%); transition: transform .2s ease;
}
.offline-bar.show { transform: none; }
.update-toast {
    position: fixed; left: .75rem; right: .75rem; top: calc(var(--safe-t) + .75rem); z-index: 2001; background: #12263f; color: #fff;
    border-radius: 14px; padding: .7rem .9rem; display: none; align-items: center; justify-content: space-between; gap: .75rem;
    box-shadow: 0 10px 30px rgba(0,0,0,.3);
}
.update-toast.show { display: flex; }

/* ---- Foto atlet: kamera / galeri ---- */
.photo-preview { width: 72px; height: 72px; border-radius: 50%; object-fit: cover; border: 2px solid #dfe7f1; background: #f3f7fc; }

/* ---- Layar kecil (HP) ---- */
@media (max-width: 767.98px) {
    body.app { padding-bottom: calc(var(--bn-h) + var(--safe-b)); }
    main { padding: 1rem .8rem !important; }
    .btn, .form-control, .form-select { min-height: 44px; }
    .btn-sm { min-height: 36px; padding-left: .7rem; padding-right: .7rem; }
    input, select, textarea, .form-control, .form-select { font-size: 16px; }   /* cegah zoom otomatis di iPhone */
    .modal-dialog { margin: .75rem; }
    h1.h5 { font-size: 1.05rem; }

    .bottom-nav {
        display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 1030; background: #fff; border-top: 1px solid #e3e8f0;
        padding-bottom: var(--safe-b); box-shadow: 0 -4px 16px rgba(18,38,63,.08);
    }
    .bottom-nav a, .bottom-nav button {
        flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; min-height: var(--bn-h);
        font-size: .68rem; color: #5d6b82; background: none; border: 0; text-decoration: none; padding: 0;
    }
    .bottom-nav i { font-size: 1.35rem; line-height: 1; transition: transform .15s ease; }
    .bottom-nav .active { color: #0d6efd; font-weight: 700; }
    .bottom-nav .active i { transform: translateY(-2px); }
    .bottom-nav a:active, .bottom-nav button:active { background: #f3f7fc; }
}
@media (min-width: 768px) {
    .pwa-banner { left: auto; right: 1rem; bottom: 1rem; max-width: 380px; }
    body.bare .pwa-banner { bottom: 1rem; }
}

/* ---- Tabel menjadi kartu di layar sangat kecil (label kolom diisi oleh mobile.js) ---- */
@media screen and (max-width: 575.98px) {
    .table-cards { border: 0; }
    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
    .table-cards tbody tr {
        width: auto; margin: .65rem; padding: .3rem .85rem; background: #fff; border: 1px solid #e3e8f0; border-radius: 12px;
        box-shadow: 0 1px 3px rgba(18,38,63,.05);
    }
    .table-cards td {
        display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .42rem 0 !important; border: 0 !important;
        text-align: right; background: transparent !important; box-shadow: none !important;
    }
    .table-cards td + td { border-top: 1px dashed #edf0f6 !important; }
    .table-cards td::before { content: attr(data-label); flex: 0 0 38%; max-width: 45%; text-align: left; font-size: .76rem; font-weight: 600; color: #6c757d; }
    .table-cards td[data-label=""]::before { display: none; }
    .table-cards td[colspan] { justify-content: center; text-align: center; }
    .table-cards td[colspan]::before { display: none; }
    .table-cards td.text-nowrap { white-space: normal !important; flex-wrap: wrap; justify-content: flex-end; }
}

/* ---- Cetak / PDF: tampilan kartu & navigasi dimatikan ---- */
@media print {
    .bottom-nav, .pwa-banner, .offline-bar, .update-toast { display: none !important; }
    body.app { padding-bottom: 0 !important; }
    main { animation: none !important; }
}
