/* ============================================================
   E-KESISWAAN - MOBILE & RESPONSIVE STYLESHEET (HP & TABLET)
   SD Muhammadiyah Serut
   - Dioptimalkan khusus untuk layar HP, Tablet, & Touch Interface
   - Drawer Sidebar Off-Canvas & Hamburger Toggle
   - Modal Bottom Sheet (Buka dari bawah layar HP)
   - Layout 1 Kolom & Tombol Ramah Sentuhan Jempol
   ============================================================ */

/* ===== 1. TABLET BREAKPOINT (<= 1024px) ===== */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        width: min(var(--sidebar-width), 84vw);
        box-shadow: none;
        z-index: 9999;
    }

    .sidebar.open {
        transform: translateX(0);
        box-shadow: 0 0 50px rgba(0, 0, 0, 0.5);
    }

    #sidebarOverlay {
        z-index: 9998;
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    #sidebarOverlay.open {
        display: block;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
    }

    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
    }

    .detail-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* ===== 2. TABLET SEDANG / LARGE PHONE BREAKPOINT (<= 768px) ===== */
@media (max-width: 768px) {
    .detail-parents-grid {
        grid-template-columns: 1fr;
    }
}

/* ===== 3. HANDPHONE / HP BREAKPOINT (<= 640px) ===== */
@media (max-width: 640px) {
    /* Skala Font & Reset Spacing Layar Kecil */
    body {
        font-size: 12px;
    }

    /* Header Ringkas di HP dengan Safe-Area (Poni / Notch / Status Bar APK) */
    header {
        height: auto;
        min-height: calc(54px + env(safe-area-inset-top, 0px));
        padding-top: max(env(safe-area-inset-top, 0px), 10px);
        padding-bottom: 10px;
        padding-left: max(12px, env(safe-area-inset-left, 0px));
        padding-right: max(12px, env(safe-area-inset-right, 0px));
        gap: 8px;
    }

    .header-left {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
    }

    .header-title {
        display: flex;
        align-items: center;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .title-full {
        display: none !important;
    }

    .title-mobile {
        display: inline-block !important;
        font-weight: 800;
        font-size: 15px;
        color: var(--text-primary);
        letter-spacing: -0.2px;
    }

    .header-logout-btn {
        padding: 5px 8px !important;
    }

    .header-logout-btn .btn-text {
        display: none !important;
    }

    .header-actions {
        gap: 6px;
    }

    .datetime-container div:first-child {
        display: none;
    }

    .live-time {
        font-size: 13px;
    }

    .theme-switch {
        width: 32px;
        height: 32px;
    }

    .theme-switch::after {
        font-size: 14px;
    }

    /* Area Konten Hemat Ruang */
    .content-area {
        padding: 14px;
    }

    /* Grid Statistik Compact (2 Kolom di HP) */
    .stat-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        margin-bottom: 14px;
    }

    .stat-card {
        padding: 12px;
        gap: 10px;
        border-radius: var(--radius-sm);
    }

    .stat-icon {
        width: 36px;
        height: 36px;
    }

    .stat-icon .material-icons-round {
        font-size: 18px;
    }

    .stat-info h3 {
        font-size: 17px;
    }

    .stat-info p {
        font-size: 9px;
    }

    /* Tombol Aksi Cepat Vertikal di HP */
    .quick-actions {
        flex-direction: column;
        gap: 8px;
    }

    .quick-btn {
        min-width: 0;
        width: 100%;
        padding: 10px 12px;
    }

    /* Card & Search Bar Responsif */
    .card {
        border-radius: var(--radius-sm);
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        padding: 12px 14px;
        gap: 10px;
    }

    .card-title {
        font-size: 13px;
    }

    .card-header-actions {
        width: 100%;
        gap: 6px;
    }

    .card-header-actions .btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    .card-header-actions .search-wrapper {
        width: 100%;
        order: -1;
    }

    .search-input-mini {
        width: 100%;
        min-width: 0;
    }

    /* Input & Grid Jadi 1 Kolom */
    .input-control {
        padding: 9px 10px;
        font-size: 12px;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .grid-2,
    [style*="grid-template-columns:1fr 1fr"],
    [style*="grid-template-columns: 1fr 1fr"] {
        grid-template-columns: 1fr !important;
    }

    .ekstra-grid {
        grid-template-columns: 1fr;
    }

    /* Tabel Data HP */
    table {
        font-size: 11px;
    }

    th, td {
        padding: 8px 10px;
    }

    /* Ukuran Tombol Sentuh HP */
    .btn {
        padding: 8px 12px;
        font-size: 11px;
    }

    .btn-sm {
        padding: 5px 9px;
        font-size: 10.5px;
    }

    /* MODAL BOTTOM SHEET (Gaya HP / Native Sheet dari Bawah) */
    .modal-overlay {
        padding: 0;
        align-items: flex-end;
    }

    .modal-card {
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        max-height: 92vh;
        max-width: 100%;
        width: 100%;
        animation: modalInSheet 0.24s var(--ease);
    }

    .modal-header {
        padding: 14px 16px;
    }

    .modal-body {
        padding: 16px;
    }

    .modal-footer {
        padding: 12px 16px;
        flex-wrap: wrap;
    }

    .modal-footer .btn {
        flex: 1 1 auto;
        justify-content: center;
    }

    .modal-detail-actions .btn {
        flex: 1 1 auto;
        justify-content: center;
        min-width: 100px;
    }

    @keyframes modalInSheet {
        from { transform: translateY(24px); opacity: 0; }
        to   { transform: translateY(0);    opacity: 1; }
    }

    /* Toast Notifikasi Melayang di Bawah Layar HP */
    .toast-notif {
        left: 12px;
        right: 12px;
        bottom: 16px;
        top: auto;
        transform: translateY(30px);
        max-width: none;
        text-align: center;
    }

    .toast-notif.show {
        transform: translateY(0);
    }
}

/* ===== 4. SMALL SMARTPHONE BREAKPOINT (<= 380px) ===== */
@media (max-width: 380px) {
    .stat-grid {
        grid-template-columns: 1fr;
    }

    .card-header-actions .btn {
        width: 100%;
    }
}


/* ============================================================
   DAFTAR SISWA & MODAL DETAIL SISWA (Lihat Profil) - MOBILE
   ============================================================ */

/* ===== Tablet (<= 768px) ===== */
@media (max-width: 768px) {
    #modalDetailBody .detail-grid { grid-template-columns: 1fr 1fr; }
}

/* ===== HP (<= 640px) ===== */
@media (max-width: 640px) {
    /* --- Tabel Daftar Siswa: tampilkan kolom penting saja, tanpa geser samping ---
       Kolom: 1 No | 2 NIS/NIPD | 3 Nama | 4 NISN | 5 JK | 6 Kelas | 7 Tempat, Tgl Lahir | 8 HP/WA | 9 Aksi
       (data lengkap tetap ada di Lihat Profil) */
    #daftar table thead th:nth-child(2), #siswaBody td:nth-child(2),
    #daftar table thead th:nth-child(4), #siswaBody td:nth-child(4),
    #daftar table thead th:nth-child(7), #siswaBody td:nth-child(7),
    #daftar table thead th:nth-child(8), #siswaBody td:nth-child(8) {
        display: none;
    }
    #daftar table thead th:nth-child(1), #siswaBody td:nth-child(1) { width: 28px; padding-left: 8px; padding-right: 4px; }
    #siswaBody td { padding: 8px 6px; }
    #siswaBody .nama-siswa-link { display: inline-block; line-height: 1.3; word-break: break-word; }
    #siswaBody .btn-aksi-ikon { width: 34px; height: 34px; }
    #siswaBody td:last-child { white-space: nowrap; }

    /* --- Modal Detail (bottom sheet) --- */
    #modalDetailSiswa .modal-card { max-height: 94vh; display: flex; flex-direction: column; }
    #modalDetailSiswa .modal-body { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 14px; }
    #modalDetailBody .detail-hero { flex-direction: column; align-items: center; text-align: center; padding: 14px; gap: 10px; }
    #modalDetailBody .detail-avatar { width: 56px; height: 56px; }
    #modalDetailBody .detail-avatar .material-icons-round { font-size: 32px; }
    #modalDetailBody .detail-hero-info h2 { font-size: 16px; margin-bottom: 6px; }
    #modalDetailBody .detail-badges { justify-content: center; }
    #modalDetailBody .detail-grid { grid-template-columns: 1fr; gap: 8px; }
    #modalDetailBody .detail-item { padding: 9px 12px; }
    #modalDetailBody .detail-item span { font-size: 12.5px; }
    #modalDetailBody .detail-block { margin-bottom: 14px; }
    #modalDetailBody .detail-block-title { font-size: 10.5px; }
}
