/**
 * Responsive Modern CSS
 * Enhanced responsive design for all devices
 */

/* ==================== Breakpoints ==================== */
/* 
 * Mobile First Approach
 * xs: 0-576px (Mobile)
 * sm: 576px+ (Large Mobile)
 * md: 768px+ (Tablet)
 * lg: 992px+ (Desktop)
 * xl: 1200px+ (Large Desktop)
 * xxl: 1400px+ (Extra Large)
 */

/* ==================== Mobile First Base (0-576px) ==================== */
@media (max-width: 575.98px) {
    /* Typography */
    html {
        font-size: 14px;
    }
    
    h1 { font-size: 1.75rem; }
    h2 { font-size: 1.5rem; }
    h3 { font-size: 1.25rem; }
    h4 { font-size: 1.1rem; }
    
    .display-1 { font-size: 3rem; }
    .display-2 { font-size: 2.5rem; }
    .display-3 { font-size: 2rem; }
    .display-4 { font-size: 1.75rem; }
    
    /* Layout */
    .container, .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    /* Navigation */
    .navbar-modern {
        padding: 0.5rem 0;
    }
    
    .navbar-brand {
        font-size: 1.25rem;
    }
    
    #darkModeToggle {
        top: 10px !important;
        right: 60px !important;
        padding: 0.25rem 0.5rem;
        font-size: 0.875rem;
    }
    
    /* Cards */
    .card-modern {
        padding: 1rem;
        margin-bottom: 1rem;
    }
    
    .stat-card {
        padding: 1rem;
        margin-bottom: 0.5rem;
    }
    
    .stat-value {
        font-size: 1.5rem;
    }
    
    /* Banners */
    .banner-modern {
        min-height: 150px;
    }
    
    .banner-premium {
        min-height: 200px;
    }
    
    .banner-overlay {
        padding: 0.5rem;
        font-size: 0.875rem;
    }
    
    /* Hero Section */
    .hero-section {
        padding: 2rem 0;
    }
    
    .hero-section .display-4 {
        font-size: 1.75rem;
        margin-bottom: 1rem;
    }
    
    .hero-section .lead {
        font-size: 1rem;
    }
    
    /* Buttons */
    .btn-modern {
        padding: 0.375rem 1rem;
        font-size: 0.875rem;
    }
    
    .btn-lg {
        padding: 0.5rem 1.25rem;
        font-size: 1rem;
    }
    
    /* Stack buttons on mobile */
    .btn-group-mobile {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group-mobile .btn {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    
    /* Forms */
    .form-control-modern {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 0.5rem 0.75rem;
    }
    
    /* Tables - Make responsive */
    .table-responsive-mobile {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Footer */
    footer .row > div {
        margin-bottom: 2rem;
    }
    
    /* Toast */
    .toast-container {
        left: 1rem;
        right: 1rem;
        top: auto;
        bottom: 1rem;
    }
    
    .toast-modern {
        width: 100%;
        margin: 0 auto;
    }
    
    /* Modal */
    .modal-modern {
        width: 95%;
        margin: 1rem;
        padding: 1rem;
    }
}

/* ==================== Large Mobile (576px - 768px) ==================== */
@media (min-width: 576px) and (max-width: 767.98px) {
    /* Typography */
    html {
        font-size: 15px;
    }
    
    h1 { font-size: 2rem; }
    h2 { font-size: 1.75rem; }
    h3 { font-size: 1.5rem; }
    
    /* Layout */
    .container {
        max-width: 540px;
    }
    
    /* Cards Grid */
    .card-grid-sm {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    /* Banners */
    .banner-grid-sm {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }
    
    /* Stat Cards */
    .stat-value {
        font-size: 1.75rem;
    }
}

/* ==================== Tablet (768px - 992px) ==================== */
@media (min-width: 768px) and (max-width: 991.98px) {
    /* Typography */
    html {
        font-size: 16px;
    }
    
    /* Layout */
    .container {
        max-width: 720px;
    }
    
    /* Navigation */
    #darkModeToggle {
        top: 20px !important;
        right: 20px !important;
    }
    
    /* Cards Grid */
    .card-grid-md {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
    }
    
    /* Banners */
    .banner-grid-md {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 1rem;
    }
    
    .banner-premium {
        min-height: 250px;
    }
    
    /* Hero Section */
    .hero-section {
        padding: 3rem 0;
    }
}

/* ==================== Desktop (992px - 1200px) ==================== */
@media (min-width: 992px) and (max-width: 1199.98px) {
    /* Layout */
    .container {
        max-width: 960px;
    }
    
    /* Cards Grid */
    .card-grid-lg {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 1.5rem;
    }
}

/* ==================== Large Desktop (1200px+) ==================== */
@media (min-width: 1200px) {
    /* Layout */
    .container {
        max-width: 1140px;
    }
    
    /* Hero Section */
    .hero-section {
        padding: 4rem 0;
        min-height: 60vh;
    }
    
    /* Banners */
    .banner-premium {
        min-height: 300px;
    }
}

/* ==================== Extra Large (1400px+) ==================== */
@media (min-width: 1400px) {
    /* Layout */
    .container {
        max-width: 1320px;
    }
    
    /* Wide layouts */
    .container-xxl {
        max-width: 1620px;
    }
}

/* ==================== Utility Classes ==================== */

/* Hide/Show based on breakpoint */
@media (max-width: 575.98px) {
    .hide-mobile { display: none !important; }
    .show-mobile { display: block !important; }
}

@media (min-width: 576px) {
    .hide-desktop { display: none !important; }
    .show-desktop { display: block !important; }
}

/* Spacing utilities */
@media (max-width: 767.98px) {
    .py-mobile-3 { padding-top: 1rem !important; padding-bottom: 1rem !important; }
    .px-mobile-3 { padding-left: 1rem !important; padding-right: 1rem !important; }
    .my-mobile-3 { margin-top: 1rem !important; margin-bottom: 1rem !important; }
    .mx-mobile-3 { margin-left: 1rem !important; margin-right: 1rem !important; }
}

/* Text alignment */
@media (max-width: 767.98px) {
    .text-mobile-center { text-align: center !important; }
    .text-mobile-left { text-align: left !important; }
    .text-mobile-right { text-align: right !important; }
}

/* Flexbox utilities */
@media (max-width: 767.98px) {
    .flex-mobile-column { flex-direction: column !important; }
    .flex-mobile-wrap { flex-wrap: wrap !important; }
}

/* ==================== Touch & Gesture Support ==================== */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    .btn-modern,
    .nav-link-modern,
    .form-control-modern,
    .tag-modern {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover effects on touch devices */
    .hover-scale:hover {
        transform: none;
    }
    
    .card-modern:hover {
        transform: none;
        box-shadow: var(--shadow-md);
    }
    
    /* Add active states for feedback */
    .btn-modern:active,
    .card-modern:active {
        transform: scale(0.98);
        transition: transform 0.1s;
    }
}

/* ==================== Orientation Support ==================== */
@media (orientation: landscape) and (max-height: 500px) {
    /* Reduce vertical spacing in landscape mobile */
    .navbar-modern {
        padding: 0.25rem 0;
    }
    
    .hero-section {
        padding: 1rem 0;
        min-height: auto;
    }
    
    .py-5 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
}

/* ==================== Print Styles ==================== */
@media print {
    /* Hide non-essential elements */
    .navbar-modern,
    #darkModeToggle,
    .btn-modern,
    footer,
    .toast-container {
        display: none !important;
    }
    
    /* Reset colors for print */
    body {
        background: white;
        color: black;
    }
    
    .card-modern {
        border: 1px solid #ddd;
        box-shadow: none;
    }
    
    /* Ensure links are visible */
    a {
        color: black;
        text-decoration: underline;
    }
    
    /* Page breaks */
    .page-break-before {
        page-break-before: always;
    }
    
    .page-break-after {
        page-break-after: always;
    }
    
    .avoid-break {
        page-break-inside: avoid;
    }
}

/* ==================== High Contrast Mode ==================== */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #ffed4e;
        --text-primary: #ffffff;
        --text-secondary: #e0e0e0;
        --dark-bg: #000000;
        --dark-bg-secondary: #1a1a1a;
    }
    
    .btn-modern,
    .card-modern {
        border: 2px solid var(--primary-color);
    }
}

/* ==================== Reduced Motion ==================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
}

/* ==================== Dark Mode Support ==================== */
@media (prefers-color-scheme: dark) {
    /* Automatically apply dark theme if user prefers */
    :root {
        --dark-bg: #0a0a0a;
        --dark-bg-secondary: #141414;
        --dark-bg-tertiary: #1f1f1f;
    }
}

/* ==================== Retina Display Support ==================== */
@media (-webkit-min-device-pixel-ratio: 2),
       (min-resolution: 192dpi) {
    /* Use higher resolution images */
    .logo-image {
        background-image: url('/images/logo@2x.png');
        background-size: contain;
    }
    
    /* Sharper borders */
    .card-modern,
    .btn-modern {
        border-width: 0.5px;
    }
}

/* ==================== Custom Scrollbar ==================== */
@media (min-width: 768px) {
    /* Custom scrollbar for desktop */
    ::-webkit-scrollbar {
        width: 12px;
        height: 12px;
    }
    
    ::-webkit-scrollbar-track {
        background: var(--dark-bg-secondary);
    }
    
    ::-webkit-scrollbar-thumb {
        background: var(--primary-color);
        border-radius: 6px;
    }
    
    ::-webkit-scrollbar-thumb:hover {
        background: var(--secondary-color);
    }
}