/* ==========================================================
   GLOBAL RESPONSIVE DESIGN SYSTEM (MOBILE-FIRST)
   SMP Tamansari Semanggi Apartment
   ========================================================== */

/* 1. ROOT & GLOBAL RESET RULES */
:root {
    --touch-target-min: 44px;
    --touch-target-lg: 48px;
    --font-heading-mobile: 20px;
    --font-heading-tablet: 24px;
    --font-heading-desktop: 28px;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    max-width: 100vw;
    overflow-x: hidden;
    position: relative;
    -webkit-text-size-adjust: 100%;
}

img, video, canvas, svg {
    max-width: 100%;
    height: auto;
}

button, 
.btn, 
.btn-primary, 
.btn-secondary, 
.btn-action, 
.btn-search, 
.btn-submit, 
.btn-save, 
.btn-filter, 
.btn-export, 
.icon-btn, 
.back-btn, 
.header-toggle-btn, 
.sidebar-toggle-btn {
    min-height: var(--touch-target-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation;
}

.menu-item {
    min-height: var(--touch-target-min);
    display: flex;
    align-items: center;
    justify-content: flex-start;
    text-align: left;
    gap: 14px;
    padding-left: 16px;
    padding-right: 16px;
    touch-action: manipulation;
}

.form-input, 
.form-select, 
.search-input, 
.filter-select,
input[type="text"], 
input[type="email"], 
input[type="password"], 
input[type="search"], 
input[type="tel"], 
input[type="number"], 
input[type="date"], 
select {
    min-height: var(--touch-target-min);
    font-size: 15px; /* Prevents auto-zoom on iOS */
    touch-action: manipulation;
}

.action-btn, 
.btn-action, 
.btn-edit-action, 
.btn-del-action {
    min-width: 40px;
    min-height: 40px;
    padding: 8px 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* 3. TABLE RESPONSIVE WRAPPER & STYLING */
.table-wrapper, 
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin-bottom: 12px;
    border-radius: 12px;
    position: relative;
}

.table-wrapper::-webkit-scrollbar,
.table-responsive::-webkit-scrollbar {
    height: 6px;
}

.table-wrapper::-webkit-scrollbar-thumb,
.table-responsive::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 6px;
}

.table-wrapper table,
.table-responsive table {
    width: 100%;
    min-width: 600px; /* Ensures columns maintain readable layout on scroll */
    border-collapse: collapse;
}

/* 4. MODAL RESPONSIVE BASE */
.modal-overlay {
    padding: 16px;
}

.modal-content, 
.user-modal-card {
    max-width: 520px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    box-sizing: border-box;
}

/* ==========================================================
   BREAKPOINTS:
   1. MOBILE:  < 768px
   2. TABLET:  768px – 1279px
   3. DESKTOP: >= 1280px
   ========================================================== */

/* ----------------------------------------------------------
   A. MOBILE (< 768px)
   ---------------------------------------------------------- */
@media (max-width: 767.98px) {
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        padding: 16px 12px !important;
    }

    /* Top Bar & Header */
    .header {
        flex-direction: column;
        align-items: stretch;
        gap: 14px;
        margin-bottom: 20px !important;
    }

    .header-left-group {
        display: flex;
        align-items: center;
        width: 100%;
        gap: 10px;
    }

    .header h1 {
        font-size: var(--font-heading-mobile) !important;
        line-height: 1.25;
    }

    .header p {
        font-size: 12.5px !important;
    }

    .top-bar {
        padding: 12px 14px !important;
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .top-bar-left {
        width: 100%;
        justify-content: flex-start;
    }

    .top-bar-right {
        width: 100%;
        justify-content: space-between;
    }

    .user-profile {
        width: 100%;
        justify-content: space-between;
        padding-top: 10px;
        border-top: 1px solid #E2E8F0;
    }

    .profile-area {
        width: 100%;
        justify-content: space-between;
    }

    .notif-dropdown {
        width: calc(100vw - 28px) !important;
        right: -8px !important;
        left: auto !important;
    }

    /* Layout Grids -> 100% Full Width Vertical Stack */
    .stats-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
        margin-bottom: 20px !important;
    }

    .stat-card {
        padding: 16px !important;
    }

    .stat-card-info h3 {
        font-size: 24px !important;
    }

    .content-grid {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .container {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .card {
        padding: 16px !important;
        margin-bottom: 16px !important;
        border-radius: 12px !important;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
        margin-bottom: 16px !important;
    }

    .row-2 {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    /* Check-In / Out Form & Search Group */
    .search-card {
        padding: 18px 14px !important;
        margin-bottom: 16px !important;
    }

    .search-input-group {
        flex-direction: column;
        gap: 10px !important;
    }

    .search-input-group .btn-search {
        width: 100% !important;
        justify-content: center;
    }

    .paket-card {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 14px !important;
        padding: 16px !important;
    }

    .paket-card-actions {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .paket-card-actions button,
    .paket-card-actions a {
        width: 100% !important;
        justify-content: center;
    }

    /* Data Penghuni Toolbar & Stats Strip */
    .toolbar {
        padding: 14px !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 12px !important;
    }

    .search-filter-group {
        flex-direction: column !important;
        width: 100% !important;
        gap: 10px !important;
    }

    .search-filter-group input,
    .search-filter-group select {
        width: 100% !important;
    }

    .btn-group {
        flex-direction: column !important;
        width: 100% !important;
        gap: 8px !important;
    }

    .btn-group button,
    .btn-group a {
        width: 100% !important;
        justify-content: center;
    }

    .stats-strip {
        flex-direction: column !important;
        gap: 10px !important;
        width: 100% !important;
    }

    .stat-badge {
        width: 100% !important;
        justify-content: space-between !important;
        padding: 12px 14px !important;
    }

    /* Laporan Filter Grid */
    .filter-card {
        padding: 16px !important;
    }

    .filter-grid {
        grid-template-columns: 1fr !important;
        gap: 12px !important;
    }

    .filter-actions {
        display: flex;
        flex-direction: column;
        gap: 8px;
        width: 100%;
    }

    .filter-actions button,
    .filter-actions a {
        width: 100% !important;
        justify-content: center;
    }

    /* Settings Page Layout */
    .settings-container {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
    }

    .settings-nav {
        display: flex;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        gap: 8px;
        padding: 10px !important;
        white-space: nowrap;
    }

    .settings-nav .nav-item {
        flex-shrink: 0;
        margin-bottom: 0 !important;
        font-size: 13px !important;
        padding: 8px 14px !important;
    }

    .settings-content {
        padding: 18px 14px !important;
    }

    /* Modal dialog */
    .modal-content, 
    .user-modal-card {
        padding: 20px 16px !important;
        border-radius: 16px !important;
    }

    .modal-footer {
        flex-direction: column-reverse;
        gap: 8px !important;
    }

    .modal-footer button {
        width: 100% !important;
    }

    /* Login Page */
    .login-wrapper {
        flex-direction: column;
    }

    .left-panel {
        display: none !important;
    }

    .right-panel {
        padding: 32px 16px !important;
    }

    .mobile-logo {
        display: flex !important;
    }
}

/* ----------------------------------------------------------
   B. TABLET (768px – 1279.98px)
   ---------------------------------------------------------- */
@media (min-width: 768px) and (max-width: 1279.98px) {
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
        padding: 24px 20px !important;
    }

    .header h1 {
        font-size: var(--font-heading-tablet) !important;
    }

    /* Stats Grid -> 2 columns */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 16px !important;
    }

    /* Content & Container Grids -> 1 column stack on Tablet */
    .content-grid {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    .container {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    /* Settings Page on Tablet -> Horizontal Pills or 200px column */
    .settings-container {
        grid-template-columns: 200px 1fr !important;
        gap: 20px !important;
    }

    /* Laporan Filter Grid -> 2 columns */
    .filter-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 14px !important;
    }

    .filter-actions {
        grid-column: span 2;
        display: flex;
        gap: 10px;
    }

    .toolbar {
        flex-direction: row;
        flex-wrap: wrap;
    }

    .search-filter-group {
        flex: 1 1 300px;
    }
}

/* ----------------------------------------------------------
   C. DESKTOP (>= 1280px)
   ---------------------------------------------------------- */
@media (min-width: 1280px) {
    .main-content {
        margin-left: 260px;
        width: calc(100% - 260px);
        padding: 32px;
    }

    body.sidebar-collapsed .main-content,
    html.sidebar-collapsed .main-content {
        margin-left: 80px;
        width: calc(100% - 80px);
    }

    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 24px;
    }

    .content-grid {
        grid-template-columns: 2fr 1fr;
        gap: 24px;
    }

    .container {
        grid-template-columns: 1.2fr 0.8fr;
        gap: 24px;
    }

    .settings-container {
        grid-template-columns: 250px 1fr;
        gap: 24px;
    }

    .filter-grid {
        grid-template-columns: 1.5fr 1.5fr 1fr 1fr auto;
        gap: 16px;
    }

    .row-2 {
        grid-template-columns: 1fr 1fr;
        gap: 16px;
    }
}
