/* ==========================================================================
   LateTracker — Mobile-first redesign (2026-11-20)
   Base = HP. Desktop ditingkatkan lewat @media (min-width: ...).
   Logika & api.php TIDAK diubah. Palet dipertahankan: biru Bootstrap
   + sidebar gelap, flat tanpa gradien/kaca.
   ========================================================================== */

:root {
    --lt-primary: #0d6efd;
    --lt-primary-dark: #0b5ed7;
    --lt-navy: #111827;
    --lt-sidebar: #212529;
    --lt-bg: #f1f4f8;
    --lt-card: #ffffff;
    --lt-text: #1f2937;
    --lt-muted: #6b7280;
    --lt-border: #e5e7eb;
    --lt-radius: 16px;
    --lt-radius-sm: 12px;
    --lt-bottom-nav-h: 60px;
    --lt-touch: 48px;
}

* { box-sizing: border-box; }

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

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    background-color: var(--lt-bg);
    color: var(--lt-text);
    overflow-x: hidden;
    margin: 0;
}

/* ---------- Dasar: sentuhan besar, teks tidak zoom di iOS ---------- */
.form-control,
.form-select {
    min-height: var(--lt-touch);
    font-size: 16px;
    border-radius: var(--lt-radius-sm);
}

.form-control:focus,
.form-select:focus {
    border-color: var(--lt-primary);
    box-shadow: 0 0 0 3px rgba(13, 110, 253, .18);
}

.btn {
    min-height: var(--lt-touch);
    border-radius: var(--lt-radius-sm);
    font-weight: 600;
}

.btn-sm {
    min-height: 40px;
    padding: .35rem .7rem;
    font-size: .875rem;
}

label.form-label { font-weight: 600; margin-bottom: .35rem; }

/* ---------- Shell aplikasi ---------- */
.app-shell {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.app-content {
    padding-bottom: calc(var(--lt-bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 24px);
    -webkit-overflow-scrolling: touch;
}

[id^="page-"] h2.fw-bold {
    font-size: clamp(1.25rem, 1rem + 2vw, 1.75rem);
    line-height: 1.25;
}

/* ---------- Top bar HP ---------- */
.navbar.d-md-none {
    background-color: var(--lt-navy) !important;
    min-height: 56px;
    padding: .5rem .75rem !important;
}
.navbar.d-md-none .navbar-brand { font-size: 1.05rem; font-weight: 700; }
.navbar.d-md-none .btn { min-height: 44px; min-width: 44px; }

/* ---------- Bottom navigation (HP saja) ---------- */
.bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    display: flex;
    background: #fff;
    border-top: 1px solid var(--lt-border);
    box-shadow: 0 -4px 16px rgba(17, 24, 39, .08);
    padding-bottom: env(safe-area-inset-bottom, 0px);
    height: calc(var(--lt-bottom-nav-h) + env(safe-area-inset-bottom, 0px));
}

.bottom-nav-item {
    flex: 1 1 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    min-height: var(--lt-bottom-nav-h);
    padding: 6px 2px 8px;
    color: var(--lt-muted);
    text-decoration: none;
    background: none;
    border: 0;
    cursor: pointer;
    font-size: .68rem;
    font-weight: 600;
    line-height: 1;
}

.bottom-nav-item i { font-size: 1.35rem; line-height: 1; }
.bottom-nav-item:hover { color: var(--lt-text); }
.bottom-nav-item.active { color: var(--lt-primary); }

/* Sidebar desktop */
.sidebar,
.sidebar-desktop {
    background-color: var(--lt-sidebar);
    color: #fff;
}

.nav-link {
    color: rgba(255, 255, 255, .75);
    margin-bottom: 5px;
    cursor: pointer;
    border-radius: 8px;
}
.nav-link:hover { color: #fff; background-color: rgba(255, 255, 255, .1); }
.nav-link.active { background-color: var(--lt-primary); color: #fff; }
.nav-link i { margin-right: 10px; }

.offcanvas { width: min(320px, 86vw); }
.offcanvas .nav-link { min-height: 44px; display: flex; align-items: center; }

/* ---------- Kartu & statistik ---------- */
.card {
    border: 1px solid var(--lt-border);
    border-radius: var(--lt-radius);
    box-shadow: 0 1px 3px rgba(17, 24, 39, .06);
}
.card-header { background: #fff; border-bottom: 1px solid var(--lt-border); }

.stats-card { transition: transform .2s; border: none; }
.stats-card:hover { transform: translateY(-3px); }
.stats-card .card-body { padding: .85rem .95rem; }
.stats-card .text-muted { font-size: .8rem; }

#stat-today, #stat-week, #stat-month, #stat-year { font-size: 1.7rem; line-height: 1.1; }

.chart-box { height: 210px; }

/* ---------- Tabel jadi kartu di HP ---------- */
.table-custom th {
    background-color: #f8f9fa;
    text-transform: uppercase;
    font-size: .8rem;
    letter-spacing: .5px;
}

@media (max-width: 767.98px) {
    .table { font-size: .9rem; margin-bottom: 0; }
    .table td, .table th { padding: .5rem .6rem; }

    .table-cards thead { display: none; }
    .table-cards, .table-cards tbody, .table-cards tr, .table-cards td { display: block; width: 100%; }
    .table-cards tbody tr {
        background: #fff;
        border: 1px solid var(--lt-border);
        border-radius: var(--lt-radius);
        padding: .35rem .9rem .6rem;
        margin-bottom: .75rem;
        box-shadow: 0 1px 3px rgba(17, 24, 39, .05);
    }
    .table-cards tbody tr:last-child { margin-bottom: 0; }
    .table-cards td {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        border: 0;
        border-bottom: 1px solid #f1f3f5;
        padding: .55rem 0;
        text-align: right;
    }
    .table-cards td:last-child { border-bottom: 0; }
    .table-cards td::before {
        content: attr(data-label);
        font-size: .78rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: .4px;
        color: var(--lt-muted);
        text-align: left;
        flex-shrink: 0;
    }
    .table-cards td[data-label=""]::before { display: none; }
    .table-cards td[data-label=""] { justify-content: flex-start; }
    .table-cards td[colspan] { display: block; text-align: center; }
    .table-cards td[colspan]::before { display: none; }
    .table-cards td[data-label="Aksi"] { justify-content: flex-end; gap: 8px; }
    .table-cards td[data-label="Aksi"]::before { display: none; }
    .table-cards td[data-label="Aksi"] .btn { flex: 1; min-height: 44px; }
    .table-cards td[data-label="Pilih"] { justify-content: flex-start; }
    .table-cards td[data-label="Pilih"]::before { display: none; }
    .table-cards td[data-label="Pilih"] .form-check-input { width: 22px; height: 22px; }
    .table-cards td[data-label="Foto"] { display: block; padding: .4rem 0 .2rem; }
    .table-cards td[data-label="Foto"]::before { display: none; }
    .table-cards td[data-label="Foto"] .validation-photo { width: 100%; max-height: 200px; }

    .table-cards { background: transparent; }

    #page-records .form-select.w-auto { width: 100% !important; }
    #page-students .btn, #page-users .btn, #page-classes .btn { flex: 1 1 auto; }
    #filter-students-class { flex: 1 1 140px; }
}

/* ---------- Login: mobile-first, flat ---------- */
.login-container {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}
.login-container .card { border-radius: 20px; }
.login-btn-hover { transition: transform .2s ease, box-shadow .2s ease; }
.login-btn-hover:hover { transform: translateY(-2px); box-shadow: 0 .5rem 1rem rgba(0, 0, 0, .15) !important; }
.transition-hover { transition: background-color .2s ease, transform .2s ease; padding: 10px; border-radius: 10px; }
.transition-hover:hover { background-color: rgba(255, 255, 255, .1); transform: translateX(5px); }

/* ---------- Input keterlambatan ---------- */
#page-input .card { max-width: 800px; }
#student-photo { min-height: var(--lt-touch); }
#preview-image { width: 100%; max-height: 260px; object-fit: cover; border-radius: var(--lt-radius-sm); }

.form-actions-sticky {
    position: sticky;
    bottom: calc(var(--lt-bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 12px);
    z-index: 20;
    background: #fff;
    border: 1px solid var(--lt-border);
    border-radius: var(--lt-radius-sm);
    padding: .75rem;
    margin: 0 -.25rem;
    box-shadow: 0 -4px 16px rgba(17, 24, 39, .08);
}
.form-actions-sticky .btn { width: 100%; min-height: 52px; font-size: 1rem; }

/* ---------- Foto validasi ---------- */
.avatar-circle {
    width: 40px; height: 40px;
    background-color: #495057;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; color: #fff;
}

.validation-photo {
    width: 150px; height: 150px;
    object-fit: cover;
    border-radius: 8px;
    border: 2px solid #dee2e6;
    cursor: pointer;
    transition: transform .2s, border-color .2s;
}
.validation-photo:hover { transform: scale(1.03); border-color: var(--lt-primary); }

/* ---------- Surat peringatan ---------- */
#warnings-list .alert { border-radius: var(--lt-radius); align-items: center; }
#warnings-list .btn { min-height: 44px; }

/* ---------- Modal ---------- */
.modal-content { border-radius: 16px; border: 0; }
.modal-header, .modal-footer { border-color: var(--lt-border); }

#letter-content { font-size: 14px; }
@media (max-width: 767.98px) {
    #letter-content { padding: 14px 16px !important; font-size: 13px; }
    #letter-content table { font-size: 13px !important; }
}

/* ---------- Loading ---------- */
#loading-overlay {
    position: fixed; inset: 0;
    background: rgba(255, 255, 255, .85);
    z-index: 9999;
    display: flex; justify-content: center; align-items: center; flex-direction: column;
}

/* ---------- Desktop ---------- */
@media (min-width: 768px) {
    .app-content { padding-bottom: 24px; }
    .bottom-nav { display: none !important; }
    .form-actions-sticky {
        position: static;
        background: transparent;
        border: 0;
        box-shadow: none;
        padding: 0;
        margin: 0;
    }
    .form-actions-sticky .btn { width: auto; min-height: var(--lt-touch); }
    .chart-box { height: 300px; }
    .stats-card .card-body { padding: 1rem 1.25rem; }
    #stat-today, #stat-week, #stat-month, #stat-year { font-size: 2rem; }
    .sidebar-desktop { width: 260px !important; }
}

@media (min-width: 768px) and (max-width: 991.98px) {
    .sidebar-desktop { width: 220px !important; }
}

@media (min-width: 992px) {
    .container-fluid.px-md-4 { max-width: 1200px; }
}

:focus-visible { outline: 3px solid rgba(13, 110, 253, .45); outline-offset: 2px; }

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