/**
 * Responsive CSS
 * Flavor Theme
 * 
 * Breakpoints:
 * - Mobile: < 768px
 * - Tablet: 768px - 1023px
 * - Desktop: >= 1024px
 * - Wide: >= 1280px
 */

/* ============================================
   Tablet & Below (max-width: 1023px)
   ============================================ */
@media (max-width: 1023px) {
    /* Container */
    .container {
        --container-padding: 1.25rem;
    }
    
    /* Typography Scale Down */
    h1, .hero-title {
        font-size: var(--text-4xl);
    }
    
    h2, .section-header .section-title {
        font-size: var(--text-3xl);
    }
    
    h3 {
        font-size: var(--text-2xl);
    }
    
    /* Header */
    .main-navigation {
        display: none;
    }
    
    .mobile-menu-toggle {
        display: flex;
    }
    
    .header-inner {
        gap: var(--space-4);
    }
    
    /* Navigation Mega Menu - Hide on Tablet */
    .mega-menu,
    .sub-menu {
        display: none !important;
    }
    
    /* Hero */
    .hero {
        min-height: 50vh;
    }
    
    .hero-lg {
        min-height: 70vh;
    }
    
    .hero-title {
        font-size: var(--text-4xl);
    }
    
    .hero-description {
        font-size: var(--text-base);
    }
    
    /* Product Grid */
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-4);
    }
    
    .products-grid.columns-5 {
        grid-template-columns: repeat(3, 1fr);
    }
    
    /* Shop Layout */
    .shop-layout {
        grid-template-columns: 1fr;
    }
    
    .shop-sidebar {
        position: static;
        max-height: none;
        display: none;
    }
    
    .shop-sidebar.is-open {
        display: block;
        position: fixed;
        inset: 0;
        z-index: var(--z-modal);
        background-color: var(--color-white);
        padding: var(--space-6);
        overflow-y: auto;
    }
    
    /* Product Page */
    .product-layout {
        grid-template-columns: 1fr;
        gap: var(--space-8);
    }
    
    .product-gallery {
        position: static;
    }
    
    /* Cart Layout */
    .cart-layout {
        grid-template-columns: 1fr;
    }
    
    .cart-summary {
        position: static;
    }
    
    /* Checkout Layout */
    .checkout-layout {
        grid-template-columns: 1fr;
    }
    
    .order-summary {
        position: static;
        order: -1;
        margin-bottom: var(--space-6);
    }
    
    /* Account Layout */
    .account-layout {
        grid-template-columns: 1fr;
    }
    
    .account-nav {
        position: static;
    }
    
    /* Dashboard Stats */
    .dashboard-stats {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Footer */
    .footer-main {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-8);
    }
    
    .footer-brand {
        grid-column: span 2;
        max-width: none;
    }
    
    /* B2B Benefits */
    .b2b-benefits {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Addresses Grid */
    .addresses-grid {
        grid-template-columns: 1fr;
    }
    
    /* Orders Table */
    .order-row {
        grid-template-columns: 1fr 1fr;
        gap: var(--space-2);
    }
    
    .order-row.header {
        display: none;
    }
    
    .order-row > * {
        padding: var(--space-2) 0;
    }
    
    /* Search Results */
    .search-results-list {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* ============================================
   Mobile (max-width: 767px)
   ============================================ */
@media (max-width: 767px) {
    /* Root Variables Override */
    :root {
        --header-height: 60px;
        --top-bar-height: 32px;
    }
    
    /* Container */
    .container {
        --container-padding: 1rem;
    }
    
    /* Typography Scale Down Further */
    h1, .hero-title {
        font-size: var(--text-3xl);
    }
    
    h2, .section-header .section-title {
        font-size: var(--text-2xl);
    }
    
    h3 {
        font-size: var(--text-xl);
    }
    
    h4 {
        font-size: var(--text-lg);
    }
    
    /* Section Spacing */
    .section {
        padding-top: var(--space-12);
        padding-bottom: var(--space-12);
    }
    
    .section-lg {
        padding-top: var(--space-16);
        padding-bottom: var(--space-16);
    }
    
    .section-header {
        margin-bottom: var(--space-8);
    }
    
    /* Top Bar */
    .top-bar-left {
        display: none;
    }
    
    .top-bar-content {
        justify-content: center;
    }
    
    .top-bar-right {
        gap: var(--space-4);
    }
    
    /* Header */
    .site-branding img {
        max-height: 36px;
    }
    
    .site-title {
        font-size: var(--text-xl);
    }
    
    .header-action-btn {
        width: 36px;
        height: 36px;
    }
    
    .header-action-btn svg {
        width: 20px;
        height: 20px;
    }
    
    .header-actions {
        gap: var(--space-2);
    }
    
    /* Hide wishlist on mobile */
    .wishlist-link {
        display: none;
    }
    
    /* Mini Cart */
    .mini-cart-panel {
        width: 100%;
    }
    
    /* Hero */
    .hero {
        min-height: 60vh;
    }
    
    .hero-content {
        padding: var(--space-8) 0;
    }
    
    .hero-subtitle {
        font-size: 10px;
    }
    
    .hero-buttons {
        flex-direction: column;
    }
    
    .hero-buttons .btn {
        width: 100%;
    }
    
    /* Page Header */
    .page-header {
        padding: var(--space-8) 0;
    }
    
    .page-title {
        font-size: var(--text-3xl);
    }
    
    /* Product Grid */
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-3);
    }
    
    .products-grid.columns-3,
    .products-grid.columns-4,
    .products-grid.columns-5 {
        grid-template-columns: repeat(2, 1fr);
    }
    
    /* Product Card */
    .product-card-info {
        padding: var(--space-3);
    }
    
    .product-card-name {
        font-size: var(--text-base);
    }
    
    .product-card-brand {
        font-size: 10px;
    }
    
    .product-card-actions {
        opacity: 1;
        transform: none;
        flex-direction: row;
        top: auto;
        bottom: var(--space-3);
        right: var(--space-3);
    }
    
    .product-action-btn {
        width: 32px;
        height: 32px;
    }
    
    .quick-add-btn {
        display: none;
    }
    
    /* Shop Toolbar */
    .shop-toolbar {
        flex-direction: column;
        gap: var(--space-4);
        align-items: flex-start;
    }
    
    .shop-actions {
        width: 100%;
        justify-content: space-between;
    }
    
    .shop-sort select {
        min-width: 140px;
    }
    
    /* Filter Toggle Button */
    .filter-toggle-btn {
        display: flex;
    }
    
    /* Product Page */
    .product-title {
        font-size: var(--text-2xl);
    }
    
    .product-gallery-thumbs {
        grid-template-columns: repeat(4, 1fr);
    }
    
    .add-to-cart-form {
        flex-direction: column;
    }
    
    .add-to-cart-form .quantity-selector {
        width: 100%;
        justify-content: center;
    }
    
    .product-meta-actions {
        flex-wrap: wrap;
        gap: var(--space-4);
    }
    
    /* Product Tabs */
    .tabs-list {
        gap: var(--space-4);
        overflow-x: auto;
        padding-bottom: var(--space-2);
    }
    
    .tab-btn {
        white-space: nowrap;
        font-size: var(--text-xs);
    }
    
    .product-tabs .tab-panel {
        padding: var(--space-4);
    }
    
    /* Reviews */
    .reviews-summary {
        flex-direction: column;
        gap: var(--space-6);
    }
    
    /* Cart Page */
    .cart-table th {
        display: none;
    }
    
    .cart-table td {
        display: block;
        padding: var(--space-2) 0;
        text-align: left;
        border: none;
    }
    
    .cart-table tr {
        display: block;
        padding: var(--space-4) 0;
        border-bottom: 1px solid var(--color-border);
    }
    
    .cart-product {
        margin-bottom: var(--space-4);
    }
    
    .cart-actions {
        flex-direction: column;
        gap: var(--space-4);
    }
    
    .cart-coupon {
        width: 100%;
    }
    
    .cart-coupon input {
        flex: 1;
    }
    
    /* Checkout */
    .checkout-steps {
        gap: var(--space-4);
        overflow-x: auto;
        padding-bottom: var(--space-2);
    }
    
    .checkout-step {
        flex-shrink: 0;
    }
    
    .step-number {
        width: 28px;
        height: 28px;
        font-size: var(--text-sm);
    }
    
    .checkout-form {
        padding: var(--space-4);
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    /* Account */
    .account-content {
        padding: var(--space-4);
    }
    
    .dashboard-stats {
        grid-template-columns: 1fr;
    }
    
    .dashboard-stat {
        padding: var(--space-4);
    }
    
    .dashboard-stat-value {
        font-size: var(--text-2xl);
    }
    
    /* B2B */
    .b2b-hero {
        padding: var(--space-12) 0;
    }
    
    .b2b-hero-title {
        font-size: var(--text-3xl);
    }
    
    .b2b-hero-subtitle {
        font-size: var(--text-base);
    }
    
    .b2b-benefits {
        grid-template-columns: 1fr;
        gap: var(--space-6);
    }
    
    .tier-pricing-table {
        display: block;
        overflow-x: auto;
    }
    
    /* Footer */
    .footer-main {
        grid-template-columns: 1fr;
        gap: var(--space-8);
    }
    
    .footer-brand {
        grid-column: 1;
        text-align: center;
    }
    
    .footer-social {
        justify-content: center;
    }
    
    .footer-column h4 {
        margin-bottom: var(--space-4);
    }
    
    .newsletter-form {
        flex-direction: column;
    }
    
    .newsletter-form input,
    .newsletter-form button {
        width: 100%;
    }
    
    .footer-bottom {
        flex-direction: column;
        gap: var(--space-4);
        text-align: center;
    }
    
    /* Buttons */
    .btn-lg {
        padding: var(--space-4) var(--space-8);
    }
    
    /* Forms */
    .form-control {
        padding: var(--space-3);
    }
    
    /* Quantity Selector */
    .quantity-selector {
        width: 100%;
    }
    
    .quantity-btn {
        width: 48px;
    }
    
    .quantity-input {
        flex: 1;
    }
    
    /* Modals */
    .modal-content {
        margin: var(--space-4);
        max-height: calc(100vh - var(--space-8));
    }
    
    .modal-header,
    .modal-body,
    .modal-footer {
        padding: var(--space-4);
    }
    
    /* Toasts */
    .toast-container {
        left: var(--space-4);
        right: var(--space-4);
        bottom: var(--space-4);
    }
    
    .toast {
        min-width: auto;
        max-width: none;
    }
    
    /* Breadcrumbs */
    .breadcrumbs-list {
        flex-wrap: wrap;
    }
    
    /* Pagination */
    .pagination {
        flex-wrap: wrap;
    }
    
    .pagination .prev,
    .pagination .next {
        padding: 0 var(--space-2);
    }
    
    /* Search Modal */
    .search-modal-content {
        padding: var(--space-4) 0;
    }
    
    .search-form {
        flex-direction: column;
        gap: var(--space-3);
    }
    
    .search-field {
        font-size: var(--text-base);
    }
    
    .search-results-list {
        grid-template-columns: 1fr;
    }
    
    /* Grids */
    .grid-cols-2,
    .grid-cols-3,
    .grid-cols-4,
    .grid-cols-5,
    .grid-cols-6 {
        grid-template-columns: 1fr;
    }
}

/* ============================================
   Small Mobile (max-width: 374px)
   ============================================ */
@media (max-width: 374px) {
    .products-grid {
        grid-template-columns: 1fr;
    }
    
    .product-card-image {
        aspect-ratio: 4 / 5;
    }
    
    .hero-title {
        font-size: var(--text-2xl);
    }
    
    .btn {
        padding: var(--space-3) var(--space-6);
        font-size: var(--text-xs);
    }
}

/* ============================================
   Desktop (min-width: 1024px)
   ============================================ */
@media (min-width: 1024px) {
    /* Hide mobile elements */
    .mobile-menu-toggle,
    .mobile-navigation,
    .filter-toggle-btn {
        display: none;
    }
    
    /* Show desktop navigation */
    .main-navigation {
        display: flex;
    }
}

/* ============================================
   Wide Desktop (min-width: 1280px)
   ============================================ */
@media (min-width: 1280px) {
    .products-grid.columns-5 {
        grid-template-columns: repeat(5, 1fr);
    }
    
    .footer-main {
        gap: var(--space-16);
    }
}

/* ============================================
   Ultra Wide (min-width: 1600px)
   ============================================ */
@media (min-width: 1600px) {
    :root {
        --container-max: 1520px;
    }
    
    .hero-content {
        max-width: 700px;
    }
}

/* ============================================
   Height-based adjustments
   ============================================ */
@media (max-height: 700px) {
    .hero {
        min-height: 400px;
    }
    
    .hero-lg {
        min-height: 500px;
    }
}

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

/* ============================================
   Dark Mode Support (optional)
   ============================================ */
@media (prefers-color-scheme: dark) {
    /* 
     * Dark mode styles can be enabled by uncommenting below
     * and implementing dark color palette
     */
    /*
    :root {
        --color-primary: #FAF9F7;
        --color-background: #1A1918;
        --color-white: #2A2928;
        --color-border: #3A3938;
    }
    */
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .top-bar,
    .site-header,
    .site-footer,
    .shop-sidebar,
    .product-card-actions,
    .quick-add-btn,
    .mini-cart-drawer,
    .mobile-navigation,
    .search-modal,
    .toast-container,
    .pagination,
    .breadcrumbs,
    .btn,
    button {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.4;
        background: white;
        color: black;
    }
    
    .container {
        max-width: none;
        padding: 0;
    }
    
    .product-layout,
    .shop-layout,
    .cart-layout,
    .checkout-layout,
    .account-layout {
        display: block;
    }
    
    .product-card {
        break-inside: avoid;
        page-break-inside: avoid;
    }
    
    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
        color: #666;
    }
    
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ============================================
   High Contrast Mode
   ============================================ */
@media (prefers-contrast: high) {
    :root {
        --color-border: #000000;
        --color-secondary: #000000;
    }
    
    .btn-outline {
        border-width: 2px;
    }
    
    .form-control {
        border-width: 2px;
    }
}

/* ============================================
   Touch Device Optimizations
   ============================================ */
@media (hover: none) and (pointer: coarse) {
    /* Increase touch targets */
    .btn {
        min-height: 44px;
    }
    
    .header-action-btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    .quantity-btn {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Show actions always on touch */
    .product-card-actions {
        opacity: 1;
        transform: none;
    }
    
    /* Remove hover effects that don't work on touch */
    .product-card:hover .product-card-image img {
        transform: none;
    }
    
    .product-card:hover .product-card-image .secondary-image {
        opacity: 0;
    }
    
    .quick-add-btn {
        display: none;
    }
}

/* ============================================
   Landscape Phone Adjustments
   ============================================ */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: 100vh;
    }
    
    .hero-content {
        padding: var(--space-4) 0;
    }
    
    .modal-content {
        max-height: 95vh;
    }
}
