/* ============================================================================
   RESPONSIVE & CROSS-BROWSER UPDATES
   Ensures compatibility with all browsers and devices (mobile, tablet, desktop)
   ============================================================================= */

/* ── Vendor Prefixes & Mobile Optimizations ── */
*, *::before, *::after {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
}

html {
    -webkit-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    scroll-behavior: smooth;
}

body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    -webkit-tap-highlight-color: transparent;
}

/* ── MOBILE FIRST: Default for small screens ── */

/* Mobile Header */
@media (max-width: 768px) {
    header {
        padding: 0 16px !important;
        height: 56px !important;
        gap: 8px !important;
    }

    header h1 {
        font-size: 1.1rem !important;
    }

    .logo {
        height: 28px !important;
    }

    /* Mobile Navigation */
    nav {
        display: none;
        position: fixed;
        top: 56px;
        left: 0;
        right: 0;
        flex-direction: column;
        background: rgba(13, 15, 20, 0.95);
        border-bottom: 1px solid var(--border);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        z-index: 999;
        max-height: calc(100vh - 56px);
        overflow-y: auto;
        padding: 8px;
        gap: 2px;
    }

    nav.active {
        display: flex;
    }

    nav a {
        padding: 12px 16px;
        border-radius: var(--radius);
        font-size: 0.95rem;
        width: 100%;
        text-align: left;
        border-radius: 8px;
        transition: all 0.2s ease;
    }

    nav a:hover {
        background: var(--surface);
        padding-left: 20px;
    }

    /* Hamburger Menu Button */
    .menu-toggle {
        display: flex;
        flex-direction: column;
        background: transparent;
        border: none;
        cursor: pointer;
        gap: 5px;
        padding: 8px;
        margin-left: auto;
        order: 10;
    }

    .menu-toggle span {
        width: 24px;
        height: 2px;
        background: var(--text-muted);
        border-radius: 2px;
        transition: all 0.3s ease;
        display: block;
    }

    .menu-toggle.active span:nth-child(1) {
        transform: rotate(45deg) translateY(10px);
    }

    .menu-toggle.active span:nth-child(2) {
        opacity: 0;
    }

    .menu-toggle.active span:nth-child(3) {
        transform: rotate(-45deg) translateY(-10px);
    }

    /* Mobile Hero Section */
    .hero {
        grid-template-columns: 1fr !important;
        gap: 30px !important;
        padding: 40px 16px !important;
        max-width: 100% !important;
    }

    .hero-content h2 {
        font-size: clamp(1.5rem, 4vw, 2.5rem) !important;
    }

    .hero-buttons {
        flex-direction: column;
        width: 100%;
    }

    .hero-buttons a,
    .hero-buttons button {
        width: 100%;
        min-height: 48px;
    }

    /* Mobile Grid */
    .sf-hero {
        grid-template-columns: 1fr !important;
        gap: 16px !important;
        padding: 20px !important;
        min-height: auto !important;
    }

    .sf-metrics-grid,
    .sf-stats-grid {
        grid-template-columns: 1fr !important;
    }

    .sf-products-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)) !important;
    }

    .sf-values-grid,
    .sf-cards-grid {
        grid-template-columns: 1fr !important;
    }

    /* Mobile Card Padding */
    .sf-metric,
    .sf-card,
    .sf-section,
    .sf-empty {
        padding: 16px !important;
    }

    /* Mobile Text */
    h1 {
        font-size: clamp(1.75rem, 5vw, 2.5rem) !important;
    }

    h2 {
        font-size: clamp(1.25rem, 4vw, 1.75rem) !important;
    }

    h3 {
        font-size: 1rem !important;
    }

    /* Mobile Buttons */
    button, .btn, .sf-button, .sf-button-secondary {
        min-height: 44px !important;
        padding: 10px 16px !important;
        font-size: 0.9rem !important;
    }

    /* Mobile Search */
    .header-search {
        display: none;
    }

    .header-search.mobile-search {
        display: flex;
        position: absolute;
        top: 56px;
        left: 0;
        right: 0;
        width: 100%;
        border-radius: 0;
        z-index: 998;
    }

    /* Mobile Main Container */
    .storefront-main {
        padding: 16px 12px 30px !important;
        width: 100% !important;
    }

    /* Mobile Section Head */
    .sf-section-head {
        flex-direction: column;
        gap: 8px;
    }
}

/* ── TABLET: 769px - 1024px ── */
@media (min-width: 769px) and (max-width: 1024px) {
    .menu-toggle {
        display: none;
    }

    nav {
        flex-wrap: wrap;
    }

    nav a {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .hero {
        gap: 40px !important;
        padding: 60px 32px !important;
    }

    .hero-content h2 {
        font-size: clamp(2rem, 4vw, 3rem) !important;
    }

    .sf-metrics-grid,
    .sf-stats-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .sf-products-grid {
        grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)) !important;
    }

    .sf-values-grid,
    .sf-cards-grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    .storefront-main {
        padding: 20px 20px 40px !important;
    }
}

/* ── DESKTOP: 1025px and above ── */
@media (min-width: 1025px) {
    .menu-toggle {
        display: none !important;
    }

    nav {
        flex-wrap: nowrap;
    }

    .header-search {
        display: flex;
    }
}

/* ── EXTRA LARGE SCREENS: 1440px+ ── */
@media (min-width: 1440px) {
    .storefront-main {
        max-width: 1360px !important;
    }

    .hero {
        padding: 120px 80px !important;
        gap: 80px !important;
    }

    .sf-products-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }
}

/* ============================================================================
   CROSS-BROWSER COMPATIBILITY
   ============================================================================= */

/* Flexbox fallback for older IE */
.flexbox-fallback {
    display: -webkit-flex;
    display: -moz-flex;
    display: -ms-flexbox;
    display: flex;
}

/* Grid fallback */
.grid-auto-fit {
    display: -ms-grid;
    display: grid;
}

/* Backdrop filter fallback (for browsers without support) */
@supports not (backdrop-filter: blur(20px)) {
    header,
    .sf-panel,
    .sf-card,
    .sf-glass {
        background: rgba(13, 15, 20, 0.9) !important;
    }
}

/* Transform fallback */
@supports not (transform: translateY(0)) {
    .sf-button:hover,
    .sf-button-secondary:hover {
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    }
}

/* Gradient text fallback (for older browsers) */
@supports not (background-clip: text) {
    .sf-gradient-title,
    .hero-content h2 em {
        color: #60a5fa !important;
        background: none !important;
    }
}

/* ============================================================================
   TOUCH OPTIMIZATION
   ============================================================================= */

@media (hover: none) and (pointer: coarse) {
    /* Touch-friendly button sizes */
    button,
    .btn,
    .sf-button,
    a[role="button"],
    [role="button"] {
        min-height: 48px !important;
        min-width: 48px !important;
    }

    /* Remove hover effects on touch devices */
    button:hover,
    .btn:hover,
    .sf-button:hover,
    nav a:hover {
        transform: none;
    }

    /* Add active state instead */
    button:active,
    .btn:active,
    .sf-button:active,
    nav a:active {
        opacity: 0.7;
        transform: scale(0.95);
    }
}

/* ============================================================================
   ACCESSIBILITY & DARK MODE
   ============================================================================= */

/* Reduced motion for users who prefer it */
@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;
    }
}

/* High contrast mode support */
@media (prefers-contrast: more) {
    :root {
        --border: rgba(255, 255, 255, 0.15);
        --text-muted: #a0a0a0;
    }

    button,
    .btn {
        border-width: 2px;
    }
}

/* Light color scheme support (if user prefers light mode) */
@media (prefers-color-scheme: light) {
    /* Website will use dark by default, but browser can override if needed */
    body {
        background: var(--bg);
    }
}

/* ============================================================================
   UTILITY CLASSES FOR RESPONSIVENESS
   ============================================================================= */

.visible-mobile {
    display: none;
}

.visible-tablet {
    display: none;
}

.visible-desktop {
    display: block;
}

@media (max-width: 768px) {
    .visible-mobile {
        display: block;
    }

    .visible-tablet {
        display: block;
    }

    .visible-desktop {
        display: none;
    }

    .hide-mobile {
        display: none !important;
    }
}

@media (min-width: 769px) and (max-width: 1024px) {
    .visible-mobile {
        display: none;
    }

    .visible-tablet {
        display: block;
    }

    .visible-desktop {
        display: none;
    }

    .hide-tablet {
        display: none !important;
    }
}

@media (min-width: 1025px) {
    .visible-mobile {
        display: none;
    }

    .visible-tablet {
        display: none;
    }

    .visible-desktop {
        display: block;
    }

    .hide-desktop {
        display: none !important;
    }
}

/* ============================================================================
   PRINT MEDIA (For printing pages)
   ============================================================================= */
@media print {
    header,
    nav,
    footer,
    .hide-print {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    a {
        color: blue;
        text-decoration: underline;
    }
}

/* ============================================================================
   LANDSCAPE MODE (Mobile landscape)
   ============================================================================= */
@media (max-width: 768px) and (orientation: landscape) {
    header {
        height: 48px !important;
    }

    header h1 {
        font-size: 0.95rem !important;
    }

    .hero {
        grid-template-columns: 1fr 1fr !important;
        gap: 20px !important;
        padding: 20px !important;
    }

    .hero-content h2 {
        font-size: 1.5rem !important;
    }

    .storefront-main {
        padding: 12px !important;
    }
}
