/**
 * Responsive Layout System
 * Dashboard layout, grid systems, and card layouts
 * Mobile-first: Single column → Multi-column
 */

/* ============================================
   Dashboard Layout
   ============================================ */

/* Mobile: Single column, sidebar hidden off-screen */
.dashboard-layout {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: 100%;
}

/* Main content area */
.main-content {
    margin-top: 0; /* No margin on mobile */
    padding: 0;
    width: 100%;
    min-height: auto;
}

/* Desktop (1024px+): Side-by-side layout */
@media (min-width: 1024px) {
    .dashboard-layout {
        flex-direction: row;
    }
    
    .main-content {
        
        margin-top: -16px;
        margin-left:-14px;
        width: 100%;
    }
}

/* ============================================
   Card Grid System
   ============================================ */

/* Mobile: Single column */
.card-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
    width: 100%;
}

/* Tablet (768px+): 2 columns */
@media (min-width: 768px) {
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1.5rem;
    }
}

/* Desktop (1024px+): 3 columns */
@media (min-width: 1024px) {
    .card-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Large Desktop (1280px+): 4 columns for specific grids */
@media (min-width: 1280px) {
    .card-grid.four-columns {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Card component */
.card {
    background: var(--white, #ffffff);
    border-radius: 12px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid var(--gray-200, #e5e7eb);
}

/* ============================================
   Flexible Grid System
   ============================================ */

/* Flexbox-based grid for older browser support */
.flex-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    margin: -0.5rem;
}

.flex-grid > * {
    flex: 1 1 100%; /* Mobile: Full width */
    margin: 0.5rem;
}

@media (min-width: 768px) {
    .flex-grid > * {
        flex: 1 1 calc(50% - 1rem); /* Tablet: 2 columns */
    }
}

@media (min-width: 1024px) {
    .flex-grid > * {
        flex: 1 1 calc(33.333% - 1rem); /* Desktop: 3 columns */
    }
}

/* ============================================
   Content Width Constraints
   ============================================ */

/* Prevent content from becoming too wide on large screens */
.content-wrapper {
    max-width: 100%;
    margin: 0 auto;
}

@media (min-width: 1280px) {
    .content-wrapper {
        max-width: 1200px;
    }
}

/* ============================================
   Responsive Spacing
   ============================================ */

/* Section spacing */
.section {
    padding: 1rem 0;
}

@media (min-width: 768px) {
    .section {
        padding: 1.5rem 0;
    }
}

@media (min-width: 1024px) {
    .section {
        padding: 2rem 0;
    }
}

/* ============================================
   Dashboard Widgets
   ============================================ */

/* Stats cards grid */
.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

@media (min-width: 640px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (min-width: 1024px) {
    .stats-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Chart containers */
.chart-container {
    position: relative;
    width: 100%;
    height: 250px;
}

@media (min-width: 768px) {
    .chart-container {
        height: 300px;
    }
}

@media (min-width: 1024px) {
    .chart-container {
        height: 350px;
    }
}

/* Ensure charts scale proportionally */
.chart-container canvas {
    max-width: 100%;
    height: auto !important;
}

/* ============================================
   List and Detail Views
   ============================================ */

/* List view: Stack on mobile, side-by-side on desktop */
.list-detail-layout {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

@media (min-width: 1024px) {
    .list-detail-layout {
        flex-direction: row;
    }
    
    .list-detail-layout .list-panel {
        flex: 0 0 300px;
    }
    
    .list-detail-layout .detail-panel {
        flex: 1;
    }
}

/* ============================================
   Responsive Containers
   ============================================ */

/* Full-width container on mobile, constrained on desktop */
.responsive-container {
    width: 100%;
    padding: 0;
}

@media (min-width: 768px) {
    .responsive-container {
        padding: 0 1rem;
    }
}

@media (min-width: 1024px) {
    .responsive-container {
        padding: 0 2rem;
    }
}

/* ============================================
   Orientation Support
   ============================================ */

/* Landscape optimizations for mobile devices */
@media (max-width: 1023px) and (orientation: landscape) {
    .main-content {
        padding: 0.75rem;
    }
    
    .card-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.75rem;
    }
    
    .chart-container {
        height: 200px;
    }
}
