/* ============================================
   RESPONSIVE DESIGN
   Mobile-First Approach
   ============================================ */

/* Tablets (640px and up) */
@media (min-width: 640px) {
    .container {
        padding: 0 var(--spacing-xl);
    }
    
    .grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Tablets & Desktops (768px and up) */
@media (min-width: 768px) {
    .nav-hub__grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .modal__content {
        max-width: 600px;
    }
    
    .page-header {
        flex-direction: row;
    }
}

/* Desktops (1024px and up) */
@media (min-width: 1024px) {
    .nav-hub__grid {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .grid-2 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-3 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .grid-4 {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Large Desktops (1280px and up) */
@media (min-width: 1280px) {
    .nav-hub {
        padding: var(--spacing-2xl) var(--spacing-2xl);
    }
}

/* Mobile Adjustments */
@media (max-width: 767px) {
    html {
        font-size: 15px;
    }
    
    h1 { font-size: var(--font-size-2xl); }
    h2 { font-size: var(--font-size-xl); }
    h3 { font-size: var(--font-size-lg); }
    
    .nav-hub {
        padding: var(--spacing-lg);
        min-height: auto;
    }
    
    .nav-hub__grid {
        grid-template-columns: 1fr;
    }
    
    .nav-card {
        padding: var(--spacing-md);
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .page-header__title {
        margin-bottom: var(--spacing-md);
    }
    
    .page {
        padding: var(--spacing-lg) var(--spacing-md);
    }
    
    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }
    
    .modal__content {
        width: 95%;
        padding: var(--spacing-lg);
    }
    
    .modal__footer {
        flex-direction: column;
    }
    
    .modal__footer .btn {
        width: 100%;
    }
    
    .nav-hub__controls {
        width: 100%;
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .form-group__input,
    .form-group__select,
    .form-group__textarea {
        font-size: 16px; /* Prevent iOS zoom */
    }
    
    table {
        font-size: var(--font-size-sm);
    }
    
    .table-responsive {
        overflow-x: auto;
    }
}

/* Tablet Adjustments */
@media (min-width: 768px) and (max-width: 1023px) {
    .nav-hub__grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .grid-3,
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Touch Devices */
@media (hover: none) and (pointer: coarse) {
    .btn {
        padding: var(--spacing-md) var(--spacing-xl);
    }
    
    .nav-card {
        padding: var(--spacing-lg);
    }
    
    .list__item {
        padding: var(--spacing-lg) 0;
    }
}

/* High Resolution Displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .shadow-sm,
    .shadow-md,
    .shadow-lg,
    .shadow-xl {
        filter: drop-shadow(0 0 1px rgba(0, 0, 0, 0.1));
    }
}

/* Dark Mode Specific Adjustments */
@media (prefers-color-scheme: dark) {
    :root {
        --color-bg-primary: #0F0F0F;
        --color-bg-secondary: #1A1A1A;
        --color-bg-tertiary: #2D2D2D;
        
        --color-text-primary: #FFFFFF;
        --color-text-secondary: #CCCCCC;
        --color-text-tertiary: #999999;
        
        --color-border: #333333;
    }
}

/* Print Media */
@media print {
    body {
        background: white;
        color: black;
    }
    
    a {
        text-decoration: underline;
    }
    
    .no-print {
        display: none;
    }
    
    .page {
        page-break-after: always;
        box-shadow: none;
        border: none;
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: more) {
    .btn-primary {
        border: 3px solid var(--color-primary);
    }
    
    .card {
        border-width: 2px;
    }
    
    .form-group__input:focus {
        border-width: 2px;
    }
}

/* Landscape Orientation */
@media (orientation: landscape) and (max-height: 600px) {
    .nav-hub {
        min-height: auto;
        padding: var(--spacing-lg);
    }
    
    h1, h2 {
        margin-bottom: var(--spacing-sm);
    }
    
    .card {
        margin-bottom: var(--spacing-md);
    }
}

/* Specific Breakpoints */

/* Extra Small (mobile) */
@media (max-width: 479px) {
    .nav-hub__grid {
        grid-template-columns: 1fr;
    }
    
    .btn-group {
        flex-direction: column;
    }
    
    .btn-group .btn {
        width: 100%;
    }
}

/* Small (mobile landscape) */
@media (min-width: 480px) and (max-width: 639px) {
    .nav-hub__grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Medium (tablet) */
@media (min-width: 640px) and (max-width: 767px) {
    .nav-hub__grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Large (tablet landscape) */
@media (min-width: 768px) and (max-width: 1023px) {
    .nav-hub__grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* Extra Large (desktop) */
@media (min-width: 1024px) and (max-width: 1279px) {
    .nav-hub__grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* 2XL (large desktop) */
@media (min-width: 1280px) {
    .nav-hub__grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* Accessibility */
@media (prefers-reduced-motion: no-preference) {
    .smooth-scroll {
        scroll-behavior: smooth;
    }
}

/* Focus Visible for Keyboard Navigation */
.btn:focus-visible,
.form-group__input:focus-visible,
.nav-card:focus-visible {
    outline: 3px solid var(--color-primary);
    outline-offset: 2px;
}

/* Utility Classes for Responsive */
.hidden-mobile {
    display: none;
}

.hidden-tablet {
    display: none;
}

.hidden-desktop {
    display: block;
}

@media (min-width: 768px) {
    .hidden-mobile {
        display: block;
    }
    
    .hidden-tablet {
        display: none;
    }
}

@media (min-width: 1024px) {
    .hidden-tablet {
        display: block;
    }
    
    .hidden-desktop {
        display: none;
    }
}

/* Flex Responsive */
.flex-responsive {
    flex-direction: column;
}

@media (min-width: 768px) {
    .flex-responsive {
        flex-direction: row;
    }
}

/* Columns Responsive */
.col-1-mobile { width: 100%; }
.col-2-mobile { width: 50%; }

@media (min-width: 768px) {
    .col-1-tablet { width: 100%; }
    .col-2-tablet { width: 50%; }
    .col-3-tablet { width: 33.333%; }
}

@media (min-width: 1024px) {
    .col-1 { width: 100%; }
    .col-2 { width: 50%; }
    .col-3 { width: 33.333%; }
    .col-4 { width: 25%; }
    .col-6 { width: 16.666%; }
}
