/* ========================================
   COMPREHENSIVE RESPONSIVE DESIGN SYSTEM
   Supports: Smartwatches to 4K Displays
   ======================================== */

/* ========== BREAKPOINT REFERENCE ==========
   Smartwatch:  ≤320px
   Mobile S:    321px - 375px
   Mobile M:    376px - 425px
   Mobile L:    426px - 768px
   Tablet:      769px - 1024px
   Laptop:      1025px - 1440px
   Desktop:     1441px - 1920px
   4K:          1921px+
   ========================================== */

/* ========== BASE RESPONSIVE UTILITIES ========== */
* {
    box-sizing: border-box;
}

html {
    font-size: 16px; /* Base font size */
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
}

body {
    overflow-x: hidden;
    min-width: 280px; /* Minimum supported width */
}

img, video, iframe {
    max-width: 100%;
    height: auto;
}

/* Responsive containers */
.container-responsive {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: 1rem;
    padding-right: 1rem;
}

/* ========== SMARTWATCH (≤320px) ========== */
@media (max-width: 320px) {
    html {
        font-size: 12px; /* Smaller base font */
    }
    
    .container-responsive {
        padding-left: 0.5rem;
        padding-right: 0.5rem;
    }
    
    /* Hide non-essential elements */
    .hide-smartwatch {
        display: none !important;
    }
    
    /* Stack everything vertically */
    .grid, .flex {
        display: block !important;
    }
    
    /* Reduce spacing */
    .p-4, .p-6, .p-8 {
        padding: 0.5rem !important;
    }
    
    .m-4, .m-6, .m-8 {
        margin: 0.5rem !important;
    }
    
    /* Smaller text */
    h1 { font-size: 1.25rem !important; }
    h2 { font-size: 1.1rem !important; }
    h3 { font-size: 1rem !important; }
    h4, h5, h6 { font-size: 0.9rem !important; }
    
    /* Buttons full width */
    button, .btn, a.btn {
        width: 100% !important;
        padding: 0.5rem !important;
        font-size: 0.875rem !important;
    }
    
    /* Forms */
    input, select, textarea {
        font-size: 14px !important;
        padding: 0.5rem !important;
    }
    
    /* Cards */
    .card, .glass-card {
        padding: 0.75rem !important;
        margin-bottom: 0.5rem !important;
    }
    
    /* Navigation */
    nav {
        font-size: 0.75rem !important;
    }
    
    /* Tables - scroll horizontally */
    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }
}

/* ========== MOBILE SMALL (321px - 375px) ========== */
@media (min-width: 321px) and (max-width: 375px) {
    html {
        font-size: 14px;
    }
    
    .container-responsive {
        max-width: 100%;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    
    .hide-mobile-s {
        display: none !important;
    }
    
    h1 { font-size: 1.5rem !important; }
    h2 { font-size: 1.25rem !important; }
    h3 { font-size: 1.1rem !important; }
    
    /* Grid adjustments */
    .grid-cols-2, .grid-cols-3, .grid-cols-4 {
        grid-template-columns: repeat(1, 1fr) !important;
    }
    
    /* Buttons */
    button, .btn {
        padding: 0.625rem 1rem !important;
        font-size: 0.875rem !important;
    }
}

/* ========== MOBILE MEDIUM (376px - 425px) ========== */
@media (min-width: 376px) and (max-width: 425px) {
    .container-responsive {
        max-width: 100%;
        padding-left: 1rem;
        padding-right: 1rem;
    }
    
    .hide-mobile-m {
        display: none !important;
    }
    
    /* Allow 2 columns for some grids */
    .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    h1 { font-size: 1.75rem !important; }
    h2 { font-size: 1.5rem !important; }
}

/* ========== MOBILE LARGE (426px - 768px) ========== */
@media (min-width: 426px) and (max-width: 768px) {
    .container-responsive {
        max-width: 100%;
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
    
    .hide-mobile-l {
        display: none !important;
    }
    
    /* 2-column layouts */
    .grid-cols-3, .grid-cols-4 {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    h1 { font-size: 2rem !important; }
    h2 { font-size: 1.75rem !important; }
    
    /* Side-by-side buttons */
    .btn-group {
        display: flex;
        gap: 0.5rem;
    }
}

/* ========== TABLET (769px - 1024px) ========== */
@media (min-width: 769px) and (max-width: 1024px) {
    .container-responsive {
        max-width: 720px;
    }
    
    .hide-tablet {
        display: none !important;
    }
    
    /* 3-column layouts */
    .grid-cols-4 {
        grid-template-columns: repeat(3, 1fr) !important;
    }
    
    /* Sidebar layouts */
    .sidebar-layout {
        display: grid;
        grid-template-columns: 250px 1fr;
        gap: 1.5rem;
    }
}

/* ========== LAPTOP (1025px - 1440px) ========== */
@media (min-width: 1025px) and (max-width: 1440px) {
    .container-responsive {
        max-width: 960px;
    }
    
    .hide-laptop {
        display: none !important;
    }
    
    /* Full grid layouts */
    .grid-cols-4 {
        grid-template-columns: repeat(4, 1fr) !important;
    }
    
    /* Wider sidebar */
    .sidebar-layout {
        grid-template-columns: 280px 1fr;
    }
}

/* ========== DESKTOP (1441px - 1920px) ========== */
@media (min-width: 1441px) and (max-width: 1920px) {
    .container-responsive {
        max-width: 1200px;
    }
    
    .hide-desktop {
        display: none !important;
    }
}

/* ========== 4K & ULTRA-WIDE (1921px+) ========== */
@media (min-width: 1921px) {
    .container-responsive {
        max-width: 1400px;
    }
    
    html {
        font-size: 18px; /* Larger base font for 4K */
    }
    
    .hide-4k {
        display: none !important;
    }
}

/* ========== ORIENTATION-SPECIFIC ========== */
@media (orientation: landscape) and (max-height: 500px) {
    /* Reduce vertical spacing in landscape mode */
    .hero-section {
        min-height: 60vh !important;
        padding: 2rem 0 !important;
    }
    
    .py-8, .py-12, .py-16 {
        padding-top: 2rem !important;
        padding-bottom: 2rem !important;
    }
}

/* ========== TOUCH DEVICE OPTIMIZATIONS ========== */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    button, a, input[type="button"], input[type="submit"] {
        min-height: 44px;
        min-width: 44px;
    }
    
    /* Remove hover effects on touch devices */
    .hover\:scale-105:hover {
        transform: none !important;
    }
    
    /* Larger form inputs */
    input, select, textarea {
        font-size: 16px !important; /* Prevents zoom on iOS */
        padding: 0.75rem !important;
    }
}

/* ========== PRINT STYLES ========== */
@media print {
    .no-print {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        color: #000;
        background: #fff;
    }
    
    a {
        text-decoration: underline;
    }
    
    a[href]:after {
        content: " (" attr(href) ")";
    }
}

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

@media (prefers-color-scheme: dark) {
    /* Optional: Add dark mode support */
    .auto-dark {
        background-color: #1a1a1a;
        color: #f0f0f0;
    }
}

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

@media (max-width: 768px) {
    .show-mobile { display: block !important; }
    .hide-mobile { display: none !important; }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .show-tablet { display: block !important; }
    .hide-tablet { display: none !important; }
}

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

/* ========== RESPONSIVE TEXT SIZES ========== */
.text-responsive {
    font-size: clamp(0.875rem, 2vw, 1rem);
}

.heading-responsive {
    font-size: clamp(1.5rem, 5vw, 3rem);
}

/* ========== RESPONSIVE SPACING ========== */
.gap-responsive {
    gap: clamp(0.5rem, 2vw, 2rem);
}

.padding-responsive {
    padding: clamp(1rem, 3vw, 3rem);
}
