/* ============================================================
   E-KEPEGAWAIAN - MOBILE & RESPONSIVE STYLESHEET (HP & TABLET)
   SD Muhammadiyah Serut
   - Dioptimalkan khusus untuk layar HP, Tablet, & Touch Interface
   - Drawer Sidebar Off-Canvas & Hamburger Toggle
   - Halaman form penuh (pengganti modal)
   - Tampilan Tabel, Form, & Tombol Responsif
   ============================================================ */

/* ===== 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);
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

/* ===== 2. 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 {
        text-align: right;
    }

    .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 */
    .content-area {
        padding: 14px;
    }

    /* Grid Statistik 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;
    }

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

    .card-header {
        padding: 12px 14px;
        align-items: flex-start;
        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;
    }

    .search-wrapper {
        width: 100%;
    }

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

    /* Grid & Input Menjadi 1 Kolom */
    .grid-2 {
        grid-template-columns: 1fr;
        gap: 10px;
    }

    .form-row {
        gap: 10px;
    }

    .input-control {
        padding: 9px 10px;
        font-size: 12px;
    }

    /* Tabel Data HP */
    .table-wrapper {
        -webkit-overflow-scrolling: touch;
    }

    table {
        font-size: 11px;
    }

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

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

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

    /* Dropdown Menu HP */
    .dropdown-menu {
        left: 0;
        right: auto;
        min-width: 0;
        width: min(260px, calc(100vw - 32px));
    }

    /* HALAMAN FORM (pengganti modal) */
    .form-page-header {
        padding: 12px 14px;
    }

    .form-page-body {
        padding: 14px;
        gap: 12px;
    }

    .form-page-footer {
        padding: 12px 14px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    }

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

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

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

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