/* ===========================================
   GetMetrix Mobile Responsive Styles
   =========================================== */

/* Mobile Header - Only visible on small screens */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 56px;
    background-color: var(--bs-body-bg);
    border-bottom: 1px solid var(--bs-border-color);
    z-index: 1030;
    padding: 0 1rem;
    align-items: center;
    justify-content: space-between;
}

.mobile-header .logo {
    height: 40px;
    width: auto;
}

.mobile-header .menu-btn {
    border: none;
    background: none;
    font-size: 1.5rem;
    padding: 0.5rem;
    color: var(--bs-body-color);
}

/* Offcanvas Sidebar adjustments */
.offcanvas-sidebar {
    max-width: 280px;
}

.offcanvas-sidebar .sidebar-link {
    padding: 14px 20px;
    font-size: 1rem;
}

/* =========================================== 
   MOBILE BREAKPOINT (768px and below)
   =========================================== */
@media (max-width: 767.98px) {
    /* Show mobile header */
    .mobile-header {
        display: flex;
    }
    
    /* Hide desktop sidebar */
    .desktop-sidebar {
        display: none !important;
    }
    
    /* CRITICAL: Enable scrolling on mobile */
    html {
        height: auto !important;
        overflow-y: auto !important;
    }
    
    body {
        height: auto !important;
        min-height: 100vh !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
    }
    
    .main-wrapper {
        flex-direction: column;
        height: auto !important;
        min-height: calc(100vh - 56px);
        overflow: visible !important;
    }
    
    /* Content area adjustments */
    .content-area {
        height: auto !important;
        min-height: calc(100vh - 56px);
        margin-top: 56px;
        padding-top: 0;
        overflow: visible !important;
    }
    
    .view-section {
        padding: 1rem !important;
        height: auto !important;
        min-height: auto !important;
        overflow: visible !important;
    }
    
    .view-section.active {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
    }
    
    /* GIS Section - Stack sidebar below map on mobile */
    #view-gis.active {
        flex-direction: column !important;
        height: auto !important;
        overflow: visible !important;
    }
    .stats-row .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    /* Make tables responsive */
    .table-responsive-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Adjust table for mobile */
    .table th,
    .table td {
        white-space: nowrap;
        font-size: 0.875rem;
    }
    
    /* Search/filter controls stack on mobile */
    .controls-row {
        flex-direction: column;
        gap: 0.5rem !important;
    }
    
    .controls-row > * {
        width: 100% !important;
    }
    
    /* Cards adjustments */
    .card-body {
        padding: 1rem;
    }
    
    /* Welcome banner adjustments */
    .welcome-banner .d-flex {
        flex-direction: column;
        text-align: center;
    }
    
    .welcome-banner .me-4 {
        margin-right: 0 !important;
        margin-bottom: 1rem;
    }
    
    /* GIS Section - Stack sidebar below map */
    #view-gis.active {
        flex-direction: column !important;
    }
    
    .gis-sidebar {
        width: 100% !important;
        height: auto !important;
        max-height: 50vh;
        border-left: none !important;
        border-top: 1px solid var(--bs-border-color);
    }
    
    #map {
        height: 50vh !important;
        min-height: 300px;
    }
    
    /* Dashboard map height */
    #dashboardMap {
        height: 250px !important;
    }
    
    /* Modal adjustments */
    .modal-dialog {
        margin: 0.5rem;
    }
    
    .modal-lg {
        max-width: calc(100% - 1rem);
    }
    
    /* Form controls in modals */
    .modal .row > [class*="col-md-"] {
        margin-bottom: 0.5rem;
    }
    
    /* Pagination adjustments */
    .pagination {
        flex-wrap: wrap;
        justify-content: center;
    }
    
    /* Event/News cards - full width */
    .card-grid .col-md-4,
    .card-grid .col-md-6 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    /* Profile section adjustments */
    .profile-header {
        flex-direction: column;
        text-align: center;
    }
    
    .profile-header .me-4 {
        margin-right: 0 !important;
        margin-bottom: 1rem;
    }
    
    /* Hide long text, show abbreviated */
    .hide-mobile {
        display: none !important;
    }
    
    .show-mobile {
        display: inline !important;
    }
    
    /* Calendar adjustments */
    .calendar-table {
        font-size: 0.75rem;
    }
    
    .calendar-table th,
    .calendar-table td {
        padding: 0.25rem;
    }
    
    /* Payment cards */
    .payment-summary .col-md-4 {
        flex: 0 0 100%;
        max-width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Charts */
    .chart-container {
        min-height: 250px;
    }
}

/* =========================================== 
   SMALL MOBILE (576px and below)
   =========================================== */
@media (max-width: 575.98px) {
    /* Stats cards - 1 per row on very small screens */
    .stats-row .col-md-3 {
        flex: 0 0 100%;
        max-width: 100%;
    }
    
    /* Smaller font for compact display */
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
    
    /* Reduce padding further */
    .view-section {
        padding: 0.75rem !important;
    }
    
    .card-body {
        padding: 0.75rem;
    }
    
    /* Action buttons wrap */
    .action-buttons {
        display: flex;
        flex-wrap: wrap;
        gap: 0.25rem;
    }
    
    .action-buttons .btn {
        padding: 0.25rem 0.5rem;
        font-size: 0.75rem;
    }
}

/* =========================================== 
   TABLET (768px - 991px)
   =========================================== */
@media (min-width: 768px) and (max-width: 991.98px) {
    /* Narrower sidebar on tablet */
    .desktop-sidebar {
        width: 200px !important;
    }
    
    .sidebar-link span {
        font-size: 0.9rem;
    }
    
    /* Stats cards - 2 per row */
    .stats-row .col-md-3 {
        flex: 0 0 50%;
        max-width: 50%;
    }
    
    /* GIS sidebar narrower */
    .gis-sidebar {
        width: 280px !important;
    }
}

/* =========================================== 
   UTILITY CLASSES
   =========================================== */
.show-mobile {
    display: none !important;
}

/* Touch-friendly tap targets */
@media (hover: none) and (pointer: coarse) {
    .btn {
        min-height: 44px;
        min-width: 44px;
    }
    
    .form-control,
    .form-select {
        min-height: 44px;
    }
    
    .sidebar-link {
        min-height: 48px;
    }
    
    .dropdown-item {
        padding: 0.75rem 1rem;
    }
}
