/* ===================================
   PROFESSIONAL RESPONSIVE DESIGN SYSTEM
   Mobile-First Approach | Industry Standards
   =================================== */

/* ===================================
   RESPONSIVE DESIGN PRINCIPLES:
   - Mobile-First: Base styles for mobile, enhance for larger screens
   - Fluid Typography: clamp() for scalable text
   - Flexible Grids: CSS Grid & Flexbox with auto-fit/auto-fill
   - Breakpoints: Standard device sizes
   - Touch-Friendly: 44px minimum tap targets
   - Performance: Optimized for all devices
   =================================== */

/* ===================================
   1. RESPONSIVE BREAKPOINTS (Industry Standard)
   =================================== */
:root {
    /* Breakpoint Variables */
    --breakpoint-xs: 320px;   /* Small phones */
    --breakpoint-sm: 576px;   /* Large phones */
    --breakpoint-md: 768px;   /* Tablets */
    --breakpoint-lg: 1024px;  /* Small laptops */
    --breakpoint-xl: 1280px;  /* Desktops */
    --breakpoint-2xl: 1536px; /* Large desktops */
    
    /* Fluid Spacing Scale */
    --space-3xs: clamp(0.25rem, 0.5vw, 0.5rem);
    --space-2xs: clamp(0.5rem, 1vw, 0.75rem);
    --space-xs: clamp(0.75rem, 1.5vw, 1rem);
    --space-sm: clamp(1rem, 2vw, 1.5rem);
    --space-md: clamp(1.5rem, 3vw, 2rem);
    --space-lg: clamp(2rem, 4vw, 3rem);
    --space-xl: clamp(3rem, 6vw, 5rem);
    --space-2xl: clamp(4rem, 8vw, 7rem);
    --space-3xl: clamp(5rem, 10vw, 10rem);
    
    /* Fluid Container Widths */
    --container-xs: 100%;
    --container-sm: 540px;
    --container-md: 720px;
    --container-lg: 960px;
    --container-xl: 1140px;
    --container-2xl: 1320px;
}

/* ===================================
   2. FLUID TYPOGRAPHY SYSTEM
   =================================== */

/* Base Font Size - 16px default, scales with viewport */
html {
    font-size: 100%; /* 16px */
    -webkit-text-size-adjust: 100%;
    -moz-text-size-adjust: 100%;
    -ms-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

/* Fluid Typography Scale */
body {
    font-size: clamp(0.875rem, 0.875rem + 0.25vw, 1rem);
    line-height: 1.6;
}

h1, .h1 {
    font-size: clamp(2rem, 1.5rem + 2.5vw, 4rem);
    line-height: 1.1;
    margin-bottom: var(--space-md);
}

h2, .h2 {
    font-size: clamp(1.75rem, 1.25rem + 2vw, 3rem);
    line-height: 1.2;
    margin-bottom: var(--space-sm);
}

h3, .h3 {
    font-size: clamp(1.5rem, 1rem + 1.5vw, 2.25rem);
    line-height: 1.3;
    margin-bottom: var(--space-sm);
}

h4, .h4 {
    font-size: clamp(1.25rem, 0.875rem + 1vw, 1.75rem);
    line-height: 1.4;
    margin-bottom: var(--space-xs);
}

h5, .h5 {
    font-size: clamp(1.125rem, 0.75rem + 0.75vw, 1.5rem);
    line-height: 1.5;
    margin-bottom: var(--space-xs);
}

h6, .h6 {
    font-size: clamp(1rem, 0.75rem + 0.5vw, 1.25rem);
    line-height: 1.5;
    margin-bottom: var(--space-xs);
}

p {
    font-size: clamp(0.875rem, 0.875rem + 0.25vw, 1.125rem);
    line-height: 1.7;
    margin-bottom: var(--space-sm);
}

/* ===================================
   3. RESPONSIVE CONTAINER SYSTEM
   =================================== */

.container {
    width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--space-sm);
    padding-right: var(--space-sm);
}

/* Mobile First - Base (320px+) */
@media (min-width: 320px) {
    .container {
        max-width: var(--container-xs);
        padding-left: 1rem;
        padding-right: 1rem;
    }
}

/* Small devices (576px+) */
@media (min-width: 576px) {
    .container {
        max-width: var(--container-sm);
        padding-left: 1.5rem;
        padding-right: 1.5rem;
    }
}

/* Medium devices (768px+) */
@media (min-width: 768px) {
    .container {
        max-width: var(--container-md);
        padding-left: 2rem;
        padding-right: 2rem;
    }
}

/* Large devices (1024px+) */
@media (min-width: 1024px) {
    .container {
        max-width: var(--container-lg);
    }
}

/* Extra large devices (1280px+) */
@media (min-width: 1280px) {
    .container {
        max-width: var(--container-xl);
    }
}

/* 2XL devices (1536px+) */
@media (min-width: 1536px) {
    .container {
        max-width: var(--container-2xl);
    }
}

/* Fluid Container (always 100% width) */
.container-fluid {
    width: 100%;
    padding-left: var(--space-sm);
    padding-right: var(--space-sm);
}

/* ===================================
   4. RESPONSIVE GRID SYSTEM
   =================================== */

/* Flexible Grid - Auto-responsive */
.grid {
    display: grid;
    gap: var(--space-md);
    width: 100%;
}

/* Auto-fit columns (responsive by default) */
.grid-auto-fit {
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 250px), 1fr));
}

.grid-auto-fill {
    grid-template-columns: repeat(auto-fill, minmax(min(100%, 250px), 1fr));
}

/* Mobile First Grid Columns */
.grid-cols-1 { grid-template-columns: repeat(1, 1fr); }

@media (min-width: 576px) {
    .grid-cols-sm-2 { grid-template-columns: repeat(2, 1fr); }
    .grid-cols-sm-3 { grid-template-columns: repeat(3, 1fr); }
}

@media (min-width: 768px) {
    .grid-cols-md-2 { grid-template-columns: repeat(2, 1fr); }
    .grid-cols-md-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-cols-md-4 { grid-template-columns: repeat(4, 1fr); }
}

@media (min-width: 1024px) {
    .grid-cols-lg-3 { grid-template-columns: repeat(3, 1fr); }
    .grid-cols-lg-4 { grid-template-columns: repeat(4, 1fr); }
    .grid-cols-lg-5 { grid-template-columns: repeat(5, 1fr); }
    .grid-cols-lg-6 { grid-template-columns: repeat(6, 1fr); }
}

@media (min-width: 1280px) {
    .grid-cols-xl-4 { grid-template-columns: repeat(4, 1fr); }
    .grid-cols-xl-5 { grid-template-columns: repeat(5, 1fr); }
    .grid-cols-xl-6 { grid-template-columns: repeat(6, 1fr); }
}

/* ===================================
   5. RESPONSIVE FLEXBOX UTILITIES
   =================================== */

.flex {
    display: flex;
    gap: var(--space-sm);
}

.flex-wrap {
    flex-wrap: wrap;
}

.flex-col {
    flex-direction: column;
}

/* Responsive Flex Direction */
@media (max-width: 767px) {
    .flex-col-mobile {
        flex-direction: column;
    }
}

@media (min-width: 768px) {
    .flex-row-tablet {
        flex-direction: row;
    }
}

/* ===================================
   6. RESPONSIVE NAVIGATION
   =================================== */

.navbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) 0;
    flex-wrap: wrap;
}

/* Mobile Navigation (< 768px) */
@media (max-width: 767px) {
    .nav-menu {
        position: fixed;
        top: 70px;
        left: -100%;
        width: 85%;
        max-width: 320px;
        height: calc(100vh - 70px);
        background: var(--white-color, #fff);
        flex-direction: column;
        padding: var(--space-md);
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
        transition: left 0.3s ease;
        overflow-y: auto;
        z-index: 1060;
    }
    
    .nav-menu.active {
        left: 0;
    }
    
    .nav-link {
        display: block;
        padding: var(--space-sm);
        font-size: 1.125rem;
    }
    
    .mobile-menu-btn {
        display: block;
        font-size: 1.5rem;
        padding: var(--space-xs);
        min-width: 44px;
        min-height: 44px;
    }
}

/* Tablet & Desktop Navigation (768px+) */
@media (min-width: 768px) {
    .nav-menu {
        position: static;
        display: flex !important;
        flex-direction: row;
        width: auto;
        height: auto;
        background: transparent;
        box-shadow: none;
        padding: 0;
        gap: var(--space-md);
    }
    
    .mobile-menu-btn {
        display: none;
    }
}

/* ===================================
   7. RESPONSIVE HERO SECTION
   =================================== */

.hero {
    position: relative;
    min-height: 60vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-xl) var(--space-sm);
}

@media (min-width: 576px) {
    .hero {
        min-height: 70vh;
        padding: var(--space-2xl) var(--space-md);
    }
}

@media (min-width: 768px) {
    .hero {
        min-height: 80vh;
    }
}

@media (min-width: 1024px) {
    .hero {
        min-height: 90vh;
    }
}

.hero-content {
    text-align: center;
    max-width: 100%;
    padding: var(--space-md);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.hero-content .container {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

@media (min-width: 768px) {
    .hero-content {
        max-width: 80%;
    }
}

@media (min-width: 1024px) {
    .hero-content {
        max-width: 70%;
    }
}

/* ===================================
   8. RESPONSIVE PRODUCT GRID
   =================================== */

.products-grid {
    display: grid;
    gap: var(--space-md);
    width: 100%;
}

/* Mobile: 1 column */
@media (max-width: 575px) {
    .products-grid {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }
}

/* Small devices: 2 columns */
@media (min-width: 576px) and (max-width: 767px) {
    .products-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-sm);
    }
}

/* Tablets: 3 columns */
@media (min-width: 768px) and (max-width: 1023px) {
    .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: var(--space-md);
    }
}

/* Desktop: 4 columns */
@media (min-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: var(--space-lg);
    }
}

/* Large Desktop: 5 columns (optional) */
@media (min-width: 1536px) {
    .products-grid.grid-5-cols {
        grid-template-columns: repeat(5, 1fr);
    }
}

/* ===================================
   9. RESPONSIVE CATEGORIES GRID
   =================================== */

.categories-grid {
    display: grid;
    gap: var(--space-md);
    width: 100%;
}

/* Mobile: 1 column */
@media (max-width: 575px) {
    .categories-grid {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }
}

/* Small devices: 2 columns */
@media (min-width: 576px) and (max-width: 1023px) {
    .categories-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-md);
    }
}

/* Desktop: 4 columns */
@media (min-width: 1024px) {
    .categories-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: var(--space-lg);
    }
}

/* ===================================
   10. RESPONSIVE FEATURES GRID
   =================================== */

.features-grid {
    display: grid;
    gap: var(--space-md);
    width: 100%;
}

/* Mobile: 1 column */
@media (max-width: 575px) {
    .features-grid {
        grid-template-columns: 1fr;
    }
}

/* Small devices: 2 columns */
@media (min-width: 576px) and (max-width: 1023px) {
    .features-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop: 4 columns */
@media (min-width: 1024px) {
    .features-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ===================================
   11. RESPONSIVE FOOTER
   =================================== */

.footer-content {
    display: grid;
    gap: var(--space-lg);
    width: 100%;
}

/* Mobile: 1 column */
@media (max-width: 575px) {
    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
    }
}

/* Tablets: 2 columns */
@media (min-width: 576px) and (max-width: 1023px) {
    .footer-content {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Desktop: 4 columns */
@media (min-width: 1024px) {
    .footer-content {
        grid-template-columns: 2fr 1fr 1fr 1fr;
    }
}

/* ===================================
   12. RESPONSIVE IMAGES
   =================================== */

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Responsive Image Container */
.img-responsive {
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* Aspect Ratio Containers */
.aspect-square {
    aspect-ratio: 1 / 1;
}

.aspect-video {
    aspect-ratio: 16 / 9;
}

.aspect-portrait {
    aspect-ratio: 3 / 4;
}

/* ===================================
   13. RESPONSIVE SPACING
   =================================== */

section {
    padding: var(--space-xl) 0;
}

@media (min-width: 768px) {
    section {
        padding: var(--space-2xl) 0;
    }
}

@media (min-width: 1024px) {
    section {
        padding: var(--space-3xl) 0;
    }
}

/* ===================================
   14. RESPONSIVE BUTTONS
   =================================== */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: clamp(0.75rem, 1vw, 1rem) clamp(1.5rem, 2vw, 2rem);
    font-size: clamp(0.875rem, 1vw, 1rem);
    min-height: 44px; /* Touch-friendly */
    border-radius: 8px;
    transition: all 0.3s ease;
}

.btn-large {
    padding: clamp(1rem, 1.5vw, 1.25rem) clamp(2rem, 3vw, 3rem);
    font-size: clamp(1rem, 1.25vw, 1.125rem);
    min-height: 48px;
}

/* Full width on mobile */
@media (max-width: 575px) {
    .btn-mobile-full {
        width: 100%;
    }
}

/* ===================================
   15. RESPONSIVE MODALS
   =================================== */

.modal-content {
    width: 95%;
    max-width: 1000px;
    max-height: 90vh;
    margin: auto;
    overflow-y: auto;
    border-radius: 12px;
}

@media (max-width: 767px) {
    .modal-content {
        width: 100%;
        max-width: 100%;
        height: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    
    .modal-body {
        padding: var(--space-sm);
    }
}

@media (min-width: 768px) {
    .modal-body {
        padding: var(--space-lg);
    }
}

/* ===================================
   16. RESPONSIVE CART SIDEBAR
   =================================== */

.cart-sidebar {
    position: fixed;
    top: 0;
    right: -100%;
    width: 100%;
    max-width: 400px;
    height: 100vh;
    transition: right 0.3s ease;
}

@media (max-width: 575px) {
    .cart-sidebar {
        max-width: 100%;
    }
}

.cart-sidebar.active {
    right: 0;
}

/* ===================================
   17. RESPONSIVE UTILITIES
   =================================== */

/* Display Utilities */
.hide-mobile {
    display: none;
}

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

.show-mobile {
    display: block;
}

/* Text Alignment */
.text-center-mobile {
    text-align: center;
}

@media (min-width: 768px) {
    .text-left-desktop {
        text-align: left;
    }
}

/* ===================================
   18. RESPONSIVE FORMS
   =================================== */

input,
textarea,
select {
    width: 100%;
    padding: clamp(0.75rem, 1vw, 1rem);
    font-size: clamp(0.875rem, 1vw, 1rem);
    border-radius: 8px;
    min-height: 44px; /* Touch-friendly */
}

/* Prevent zoom on iOS */
@media (max-width: 767px) {
    input,
    textarea,
    select {
        font-size: 16px; /* Prevents iOS zoom */
    }
}

.newsletter-form {
    display: flex;
    gap: var(--space-sm);
    flex-direction: column;
}

@media (min-width: 576px) {
    .newsletter-form {
        flex-direction: row;
    }
}

/* ===================================
   19. TOUCH-FRIENDLY INTERACTIONS
   =================================== */

/* Minimum touch target size (44x44px) */
button,
a,
input[type="button"],
input[type="submit"],
.clickable {
    min-width: 44px;
    min-height: 44px;
}

/* Remove tap highlight on mobile */
@media (max-width: 767px) {
    * {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
    }
}

/* ===================================
   20. RESPONSIVE PRODUCT DETAIL
   =================================== */

.product-detail {
    display: grid;
    gap: var(--space-lg);
}

/* Mobile: Stack vertically */
@media (max-width: 767px) {
    .product-detail {
        grid-template-columns: 1fr;
    }
}

/* Desktop: Side by side */
@media (min-width: 768px) {
    .product-detail {
        grid-template-columns: 1fr 1fr;
    }
}

/* ===================================
   21. RESPONSIVE TABLES
   =================================== */

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 767px) {
    table {
        font-size: 0.875rem;
    }
}

/* ===================================
   22. LANDSCAPE ORIENTATION
   =================================== */

@media (max-width: 767px) and (orientation: landscape) {
    .hero {
        min-height: 100vh;
    }
    
    .modal-content {
        max-height: 95vh;
    }
}

/* ===================================
   23. HIGH RESOLUTION DISPLAYS
   =================================== */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Optimize for retina displays */
    img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}

/* ===================================
   24. PRINT STYLES
   =================================== */

@media print {
    .header,
    .footer,
    .cart-sidebar,
    .modal,
    .btn,
    .nav-actions {
        display: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
    }
    
    .container {
        max-width: 100%;
    }
}

/* ===================================
   25. 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;
    }
}

/* ===================================
   26. DARK MODE SUPPORT (Optional)
   =================================== */

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1a1a1a;
        --text-color: #f5f5f5;
    }
    
    /* Add dark mode styles as needed */
}

/* ===================================
   27. RESPONSIVE OVERFLOW HANDLING
   =================================== */

html {
    overflow-x: hidden;
}

body {
    overflow-x: hidden;
    width: 100%;
}

/* ===================================
   28. SAFE AREA INSETS (iOS Notch)
   =================================== */

@supports (padding: max(0px)) {
    .header {
        padding-top: max(0.5rem, env(safe-area-inset-top));
    }
    
    .footer {
        padding-bottom: max(1rem, env(safe-area-inset-bottom));
    }
}

/* ===================================
   29. RESPONSIVE ASPECT RATIOS
   =================================== */

.product-image,
.category-image {
    position: relative;
    width: 100%;
    overflow: hidden;
}

/* Mobile: More square */
@media (max-width: 575px) {
    .product-image {
        aspect-ratio: 1 / 1;
    }
}

/* Desktop: Slightly taller */
@media (min-width: 576px) {
    .product-image {
        aspect-ratio: 4 / 5;
    }
}

/* ===================================
   30. RESPONSIVE GAP UTILITIES
   =================================== */

.gap-responsive {
    gap: var(--space-sm);
}

@media (min-width: 768px) {
    .gap-responsive {
        gap: var(--space-md);
    }
}

@media (min-width: 1024px) {
    .gap-responsive {
        gap: var(--space-lg);
    }
}
