/* =========================================================
   RESPONSIVE DESIGN SYSTEM - MULTI-DEVICE OPTIMIZATION
   ========================================================= */

/* Ultrawide Screens (> 1440px) */
@media (min-width: 1441px) {
    .content {
        max-width: 1600px;
        margin: 0 auto;
        width: 100%;
    }
}

/* Laptops & Standard Desktop (1025px - 1440px) */
@media (max-width: 1280px) {
    .content {
        padding: 22px 24px;
        gap: 20px;
    }
    .topbar {
        padding: 12px 24px;
    }
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    }
}

/* Tablets & Small Laptops (769px - 1024px) */
@media (max-width: 1024px) {
    .sidebar {
        width: 250px;
    }
    .main {
        margin-left: 250px;
        width: calc(100% - 250px);
    }
    .charts-grid {
        grid-template-columns: 1fr;
    }
    .chart-body {
        height: 280px;
    }
    .hero-banner {
        padding: 24px 28px;
    }
    .hero-banner::after {
        font-size: 100px;
    }
}

/* Mobile & Small Tablets (< 768px) */
@media (max-width: 768px) {
    /* Off-Canvas Sidebar */
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        box-shadow: 20px 0 50px rgba(0, 0, 0, 0.4);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-overlay.show {
        display: block;
    }
    
    /* Full Width Main Canvas */
    .main {
        margin-left: 0;
        width: 100%;
    }
    .mobile-toggle {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Touch-friendly Topbar */
    .topbar {
        padding: 12px 16px;
    }
    .top-title {
        font-size: 17px;
    }
    .breadcrumb {
        font-size: 10px;
    }
    .status-pill {
        display: none; /* Hide on small screens to save header space */
    }
    .topbar-right .btn-action span {
        display: none; /* Icon-only on mobile */
    }
    .topbar-right .btn-action {
        padding: 8px 12px;
        min-height: 40px;
        min-width: 40px;
        justify-content: center;
    }

    /* Content Spacing */
    .content {
        padding: 16px;
        gap: 16px;
    }

    /* Hero Banner Mobile */
    .hero-banner {
        padding: 20px 18px;
        border-radius: var(--radius-md);
    }
    .hero-banner::after {
        display: none;
    }
    .hero-title {
        font-size: 19px;
    }
    .hero-desc {
        font-size: 12px;
        margin-bottom: 16px;
    }

    /* Horizontal Swipeable Regional Filter */
    .region-filter-bar {
        overflow-x: auto;
        white-space: nowrap;
        flex-wrap: nowrap;
        padding-bottom: 6px;
        scrollbar-width: none;
        -webkit-overflow-scrolling: touch;
    }
    .region-filter-bar::-webkit-scrollbar {
        display: none;
    }
    .region-pill {
        flex: 0 0 auto;
        padding: 6px 12px;
        font-size: 11px;
    }

    /* KPI Grid Mobile: 2 Columns */
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
    }
    .stat-card {
        padding: 14px 12px;
        gap: 10px;
    }
    .stat-icon {
        width: 38px;
        height: 38px;
        font-size: 16px;
        border-radius: 10px;
    }
    .stat-meta small {
        font-size: 9.5px;
    }
    .stat-meta strong {
        font-size: 16px;
    }
    .stat-meta span {
        font-size: 9.5px;
    }
    /* Let 5th card span 2 cols */
    .stats-grid .stat-card:last-child {
        grid-column: span 2;
    }

    /* Commodity Grid Mobile: 4 Columns compact */
    .commodity-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
    }
    .commodity-card {
        padding: 8px 6px;
    }
    .commodity-icon {
        font-size: 18px;
    }
    .commodity-name {
        font-size: 10px;
    }
    .commodity-count {
        font-size: 10.5px;
    }

    /* Charts Mobile */
    .chart-card {
        padding: 16px;
        border-radius: var(--radius-md);
    }
    .chart-body {
        height: 250px;
    }
    .chart-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 6px;
    }

    /* Table Toolbar */
    .table-card {
        padding: 16px;
    }
    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    .search-box input {
        width: 100% !important;
    }

    /* Detail Modal Mobile */
    .modal-box {
        border-radius: var(--radius-md);
        max-height: 94vh;
    }
    .modal-header {
        padding: 16px;
        border-radius: var(--radius-md) var(--radius-md) 0 0;
    }
    .modal-body {
        padding: 16px;
        gap: 14px;
    }
    .modal-stat-row {
        grid-template-columns: 1fr;
    }
}

/* Extra Small Phones (< 380px) */
@media (max-width: 380px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    .stats-grid .stat-card:last-child {
        grid-column: span 1;
    }
    .commodity-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}
