/*
|==========================================================================
| style.css — Mobile-First Responsive
| Hadirin SMK
|==========================================================================
|
| Struktur:
|   1. CSS Variables (design tokens)
|   2. Reset & Base
|   3. Layout — Sidebar (desktop) + Bottom Nav (mobile)
|   4. Topbar
|   5. Cards & Components
|   6. Tabel → Card list di mobile
|   7. Form & Input
|   8. Tombol
|   9. Badge & Status
|  10. Dashboard khusus
|  11. Form Presensi khusus
|  12. Utility
|  13. Media queries (tablet & desktop)
|
|==========================================================================
*/

/* ============================================================
   1. CSS VARIABLES
   ============================================================ */
:root {
    /* Warna utama */
    --color-primary:       #2563eb;
    --color-primary-dark:  #1d4ed8;
    --color-primary-light: #eff6ff;

    /* Warna background */
    --bg-page:    #f5f7fa;
    --bg-card:    #ffffff;
    --bg-sidebar: #1e293b;

    /* Warna teks */
    --text-primary:   #1e293b;
    --text-secondary: #64748b;
    --text-muted:     #94a3b8;

    /* Border */
    --border-color: #e2e8f0;
    --border-radius-sm: 10px;
    --border-radius-md: 14px;
    --border-radius-lg: 20px;

    /* Status */
    --color-hadir:  #166534;
    --bg-hadir:     #f0fdf4;
    --color-izin:   #854d0e;
    --bg-izin:      #fefce8;
    --color-sakit:  #1d4ed8;
    --bg-sakit:     #eff6ff;
    --color-alpha:  #991b1b;
    --bg-alpha:     #fef2f2;

    /* Sidebar */
    --sidebar-width: 200px;

    /* Bottom nav height (mobile) */
    --bottom-nav-height: 64px;

    /* Touch target minimum */
    --touch-min: 44px;

    /* Shadow */
    --shadow-sm: 0 1px 4px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
}

/* ============================================================
   2. RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-page);

    /* Ruang untuk bottom nav di mobile */
    padding-bottom: var(--bottom-nav-height);
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; }

/* ============================================================
   3. LAYOUT — SIDEBAR (hidden di mobile, tampil di desktop)
   ============================================================ */
.sidebar {
    display: none; /* hidden di mobile */
}

.main-content {
    margin-left: var(--sidebar-width);
    padding: 2rem;
    width: calc(100% - var(--sidebar-width));
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* ============================================================
   4. BOTTOM NAVIGATION (mobile only)
   ============================================================ */
.bottom-nav {
    position: fixed;
    bottom: 0; left: 0; right: 0;
    height: var(--bottom-nav-height);
    background: #fff;
    border-top: 4px solid #1e293b;
    display: flex;
    align-items: center;
    justify-content: space-around;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.06);
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    height: 100%;
    font-size: 11px;
    color: var(--text-muted);
    gap: 3px;
    min-width: var(--touch-min);
    transition: color 0.15s;
    cursor: pointer;
    border: none;
    background: none;
    padding: 0;
}

.bottom-nav-item .nav-icon {
    font-size: 1.3rem;
    line-height: 1;
}

.bottom-nav-item.active {
    color: var(--color-primary);
}

.bottom-nav-item.active .nav-icon {
    transform: scale(1.1);
}

/* ============================================================
   5. TOPBAR (mobile: compact; desktop: full)
   ============================================================ */
.topbar {
    background: var(--bg-card);
    border-radius: var(--border-radius-md);
    border: 2px solid #1e293b;
    padding: 19px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-sm);
}

.topbar .page-title {
    font-weight: 600;
    font-size: 1.25rem;
}

.topbar .topbar-right {
    font-size: 17px;
    color: var(--text-secondary);
}

/* ============================================================
   6. CARD BASE
   ============================================================ */
.card {
    background: var(--bg-card);
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.card-header {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 12px 16px;
    font-weight: 600;
    font-size: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

/* Header halaman data master — tombol tambah tidak terpotong di HP */
.page-card-header {
    flex-direction: column;
    align-items: stretch;
}

.page-card-title {
    font-weight: 600;
    font-size: 15px;
}

.page-card-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.page-card-actions .btn {
    flex: 1 1 auto;
    min-height: var(--touch-min);
    white-space: nowrap;
}

.card-body {
    padding: 16px;
}

/* ============================================================
   7. TABEL → CARD LIST DI MOBILE
   ============================================================
   Teknik: sembunyikan thead, ubah setiap <td> jadi blok
   dengan label dari data-label attribute.

   Cara pakai di Blade:
   <td data-label="Nama">{{ $guru->nama }}</td>
   ============================================================ */
/* Wrapper tabel — jangan pakai overflow-x di mobile jika sudah pakai table-mobile-card */
.table-list-wrap {
    width: 100%;
}

/* Mobile: ubah tabel jadi card list (tanpa scroll horizontal) */
@media (max-width: 767px) {
    .card-body.p-0.table-list-body {
        padding: 12px !important;
    }

    .table-mobile-card {
        width: 100%;
        min-width: 0 !important;
    }

    .table-mobile-card thead {
        display: none;
    }

    .table-mobile-card tbody tr {
        display: block;
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius-md);
        margin-bottom: 10px;
        padding: 12px 14px;
        box-shadow: var(--shadow-sm);
    }

    .table-mobile-card tbody td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 10px;
        padding: 6px 0;
        border: none;
        font-size: 13px;
        text-align: right;
        word-break: break-word;
    }

    .table-mobile-card tbody td.col-no {
        display: none;
    }

    .table-mobile-card tbody td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 11px;
        color: var(--text-muted);
        text-transform: uppercase;
        letter-spacing: 0.04em;
        flex-shrink: 0;
        text-align: left;
        max-width: 42%;
    }

    .table-mobile-card tbody td.aksi {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
        padding-top: 12px;
        margin-top: 6px;
        border-top: 1px solid var(--border-color);
        text-align: center;
    }

    .table-mobile-card tbody td.aksi::before {
        content: 'Aksi';
        display: block;
        text-align: left;
        margin-bottom: 4px;
    }

    .table-mobile-card tbody td.aksi .btn {
        width: 100%;
        min-height: 42px;
        margin: 0 !important;
    }

    .table-mobile-card tbody td.aksi form {
        display: block;
        width: 100%;
    }

    .table-mobile-card tbody td.text-center {
        text-align: right;
    }

    /* Filter rekap & form admin */
    .filter-bar-form .row > [class*="col-"] {
        flex: 0 0 100%;
        max-width: 100%;
    }

    .filter-bar-form .d-flex.gap-2 {
        flex-direction: column;
    }

    .filter-bar-form .d-flex.gap-2 .btn,
    .filter-bar-form .d-flex.gap-2 a.btn {
        width: 100%;
        min-height: var(--touch-min);
    }

    .export-buttons-group {
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }

    .export-buttons-group .btn {
        width: 100%;
    }
}

/* ============================================================
   8. FORM & INPUT
   ============================================================ */
.form-control, .form-select {
    border: 1.5px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-size: 14px;
    padding: 10px 14px;
    height: auto;
    min-height: var(--touch-min); /* touch target */
    width: 100%;
    transition: border-color 0.15s;
    background: var(--bg-card);
    color: var(--text-primary);
}

.form-control:focus, .form-select:focus {
    border-color: var(--color-primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.form-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: block;
}

.form-text { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

.input-group { display: flex; }
.input-group .form-control { border-radius: var(--border-radius-sm) 0 0 var(--border-radius-sm); }
.input-group .input-group-text {
    border: 1.5px solid var(--border-color);
    border-left: none;
    border-radius: 0 var(--border-radius-sm) var(--border-radius-sm) 0;
    padding: 0 14px;
    background: #f8fafc;
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
}

/* ============================================================
   9. TOMBOL
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border-radius: var(--border-radius-sm);
    border: none;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    min-height: var(--touch-min);
    padding: 0 18px;
    transition: all 0.15s;
    text-decoration: none;
}

.btn-primary {
    background: var(--color-primary);
    color: #fff;
}
.btn-primary:hover { background: var(--color-primary-dark); color: #fff; }

.btn-outline-primary {
    background: transparent;
    border: 1.5px solid var(--color-primary);
    color: var(--color-primary);
}
.btn-outline-primary:hover { background: var(--color-primary-light); }

.btn-outline-secondary {
    background: transparent;
    border: 1.5px solid var(--border-color);
    color: var(--text-secondary);
}
.btn-outline-secondary:hover { background: #f8fafc; }

.btn-outline-danger {
    background: transparent;
    border: 1.5px solid #fca5a5;
    color: #991b1b;
}
.btn-outline-danger:hover { background: var(--bg-alpha); }

.btn-outline-success {
    background: transparent;
    border: 1.5px solid #86efac;
    color: var(--color-hadir);
}
.btn-outline-success:hover { background: var(--bg-hadir); }

.btn-sm {
    font-size: 12px;
    min-height: 34px;
    padding: 0 12px;
}

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

/* Tombol full width di mobile */
.btn-mobile-full { width: 100%; }

/* ============================================================
   10. BADGE & STATUS
   ============================================================ */
.badge-status {
    display: inline-block;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 12px;
    border-radius: 20px;
}

.badge-hadir { background: var(--bg-hadir); color: var(--color-hadir); }
.badge-izin  { background: var(--bg-izin);  color: var(--color-izin);  }
.badge-sakit { background: var(--bg-sakit); color: var(--color-sakit); }
.badge-alpha { background: var(--bg-alpha); color: var(--color-alpha); }

/* ============================================================
   11. DASHBOARD — KARTU STATISTIK
   ============================================================ */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit,minmax(140px,1fr));
    gap: 14px;
}

.stat-card{
    border-top: 4px solid #1e293b;
    background: #ffffff;
    border-radius: 18px;
    padding: 20px;
    text-align: center;

    box-shadow: 0 4px 12px rgba(0,0,0,0.05);

    transition: all 0.2s ease;
}

.stat-card:hover{
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}

.stat-card .stat-icon  {
    font-size: 28px;
    display: block;
    margin-bottom: 10px;
}
.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    display: block;
}
.stat-card .stat-label {
    color: #64748b;
    font-size: 13px;
}

/* Header dashboard (nama + tanggal) */
.dashboard-header{
    background: #1e293b;
    color: white;
    padding: 32px 24px;
    border-radius: 0 0 28px 28px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.08);
}

.dashboard-header .user-name{
    font-size: 2rem;
    font-weight: 700;
}

.dashboard-header .user-role{
    font-size: 15px;
    color: #cbd5e1;
    margin-top: 4px;
}

/* Status presensi hari ini (banner besar) */
.presensi-banner {
    border-radius: var(--border-radius-md);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1rem;
}
.presensi-banner.belum { background: var(--bg-alpha); border: 1.5px solid #fca5a5; }
.presensi-banner.sudah { background: var(--bg-hadir); border: 1.5px solid #86efac; }
.presensi-banner .banner-icon  { font-size: 1.8rem; }
.presensi-banner .banner-title { font-weight: 700; font-size: 14px; }
.presensi-banner .banner-sub   { font-size: 12px; color: var(--text-secondary); }

/* Section title */
.section-title {
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 8px;
}

/* Jadwal list */
/* ===== Jadwal ===== */

.jadwal-list{
    border-top: 4px solid #2563eb;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.jadwal-item{
    background: #ffffff;
    border-radius: 18px;
    padding: 18px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    border-left: 5px solid #1e293b;
    transition: all 0.2s ease;
}

.jadwal-item:hover{
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
}

.jadwal-header{
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.jadwal-waktu{
    font-size: 13px;
    color: #64748b;
    font-weight: 600;
}

.jadwal-icon{
    font-size: 20px;
}

.jadwal-mapel{
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 6px;
}

.jadwal-guru{
    font-size: 14px;
    color: #64748b;
}

/* Saat tidak ada jadwal */

.jadwal-kosong{
    border-top: 4px solid #1e293b;
    background: #ffffff;
    border-radius: 18px;
    padding: 28px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.jadwal-kosong-icon{
    font-size: 42px;
    margin-bottom: 10px;
}

.jadwal-kosong-title{
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
}

.jadwal-kosong-subtitle{
    color: #64748b;
    font-size: 14px;
    margin-top: 4px;
}

/* ============================================================
   12. FORM PRESENSI
   ============================================================ */
.presensi-page {
    background: var(--bg-page);
    min-height: 100vh;
    padding-bottom: calc(var(--bottom-nav-height) + 1rem);
}

/* Header presensi */
.presensi-header {
    background: var(--bg-sidebar);
    color: #fff;
    padding: 1rem;
    border-radius: 0 0 var(--border-radius-lg) var(--border-radius-lg);
    margin-bottom: 1rem;
}

/* Pilihan status (pill) */
.status-pills {
    display: flex;
    gap: 8px;
    margin-bottom: 1rem;
}

.status-pill {
    flex: 1;
    text-align: center;
    padding: 10px 8px;
    border-radius: var(--border-radius-sm);
    border: 1.5px solid var(--border-color);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.15s;
    min-height: var(--touch-min);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
}

.status-pill:hover { background: #f8fafc; }
.status-pill.selected-hadir { background: var(--bg-hadir); border-color: #86efac; color: var(--color-hadir); }
.status-pill.selected-izin  { background: var(--bg-izin);  border-color: #fde68a; color: var(--color-izin);  }
.status-pill.selected-sakit { background: var(--bg-sakit); border-color: #93c5fd; color: var(--color-sakit); }

/* Kamera area */
.kamera-wrap {
    position: relative;
    background: #000;
    border-radius: var(--border-radius-md);
    overflow: hidden;
    margin-bottom: 12px;
    aspect-ratio: 4/3;
}

.kamera-wrap video,
.kamera-wrap img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.kamera-btn-capture {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px; height: 60px;
    border-radius: 50%;
    background: #fff;
    border: none;
    font-size: 1.6rem;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    display: flex; align-items: center; justify-content: center;
}

.kamera-btn-retry {
    position: absolute;
    top: 10px; right: 10px;
    background: rgba(0,0,0,0.5);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 4px 10px;
    font-size: 12px;
    cursor: pointer;
}

/* Tombol submit presensi */
.btn-submit-presensi {
    width: 100%;
    padding: 16px;
    border-radius: var(--border-radius-md);
    background-color: #1e293b;
    color: #fff;
    border: none;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s;
    min-height: 54px;
}
.btn-submit-presensi:hover:not(:disabled) { background: var(--color-primary-dark); }
.btn-submit-presensi:disabled { background: var(--text-muted); cursor: not-allowed; }

/* ============================================================
   13. UTILITY
   ============================================================ */
.mt-1 { margin-top: 4px; }
.mt-2 { margin-top: 8px; }
.mt-3 { margin-top: 16px; }
.mt-4 { margin-top: 24px; }
.mb-1 { margin-bottom: 4px; }
.mb-2 { margin-bottom: 8px; }
.mb-3 { margin-bottom: 16px; }
.mb-4 { margin-bottom: 24px; }
.gap-2 { gap: 8px; }
.gap-3 { gap: 16px; }
.d-flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.align-items-center { align-items: center; }
.justify-content-between { justify-content: space-between; }
.justify-content-end { justify-content: flex-end; }
.text-center { text-align: center; }
.text-end { text-align: right; }
.text-muted { color: var(--text-muted); }
.fw-semibold { font-weight: 600; }
.fw-bold { font-weight: 700; }
.w-100 { width: 100%; }
.d-none { display: none; }

.alert {
    border-radius: var(--border-radius-sm);
    padding: 10px 14px;
    font-size: 13px;
    margin-bottom: 12px;
}
.alert-danger  { background: var(--bg-alpha); color: var(--color-alpha); border: 1px solid #fca5a5; }
.alert-success { background: var(--bg-hadir); color: var(--color-hadir); border: 1px solid #86efac; }
.alert-warning { background: var(--bg-izin);  color: var(--color-izin);  border: 1px solid #fde68a; }
.alert-info    { background: var(--bg-sakit); color: var(--color-sakit); border: 1px solid #93c5fd; }

/* ============================================================
   13. MEDIA QUERIES — TABLET (768px+)
   ============================================================ */
@media (min-width: 768px) {
    .stat-grid {
        grid-template-columns: repeat(3, 1fr); /* 3 kolom di tablet */
    }
}

/* ============================================================
   14. MEDIA QUERIES — DESKTOP (1024px+)
   ============================================================
   Di desktop: tampilkan sidebar, sembunyikan bottom nav
   ============================================================ */
@media (min-width: 1024px) {
    body {
        padding-bottom: 0; /* tidak perlu ruang bottom nav */
    }

    /* Tampilkan sidebar */
    .sidebar {
        display: flex;
        flex-direction: column;
        width: var(--sidebar-width);
        height: 100vh;
        overflow-y: auto;
        background: var(--bg-sidebar);
        position: fixed;
        top: 0;
        left: 0;
        padding: 1.5rem 1rem;
        z-index: 100;
    }


    /* Konten geser ke kanan */
    .main-content {
        margin-left: var(--sidebar-width);
        padding: 1.5rem;
    }

    /* Sembunyikan bottom nav */
    .bottom-nav { display: none; }

    /* Dashboard header: tidak perlu meluber */
    .dashboard-header {
        margin: 0 0 1rem;
        border-radius: var(--border-radius-lg);
    }

    /* Stat grid: 5 kolom di desktop (sesuai jumlah kartu) */
    .stat-grid {
        grid-template-columns: repeat(5, 1fr);
    }

    /* Tabel normal kembali di desktop */
    .table-mobile-card thead { display: table-header-group; }
    .table-mobile-card tbody tr {
        display: table-row;
        background: transparent;
        border: none;
        border-radius: 0;
        margin-bottom: 0;
        padding: 0;
    }
    .table-mobile-card tbody td {
        display: table-cell;
        padding: 10px 16px;
        border-bottom: 1px solid var(--border-color);
        font-size: 14px;
    }
    .table-mobile-card tbody td::before { display: none; }
    .table-mobile-card tbody td.aksi {
        border-top: none;
        padding-top: 10px;
        margin-top: 0;
        text-align: right;
    }

    .table-mobile-card tbody td.aksi::before {
        display: none;
    }

    .table-mobile-card tbody td.aksi .btn {
        width: auto;
        min-height: auto;
    }

    .table-mobile-card tbody td.aksi form {
        display: inline;
    }

    .page-card-header {
        flex-direction: row;
        align-items: center;
    }

    .page-card-actions {
        flex-wrap: nowrap;
        margin-left: auto;
    }

    .page-card-actions .btn {
        flex: 0 0 auto;
    }

    .card-body.p-0.table-list-body {
        padding: 0 !important;
    }

    /* Presensi page tidak pakai padding bottom tambahan */
    .presensi-page {
        padding-bottom: 1rem;
    }
}
