/* ===================================
   RESPONSIVE DESIGN SYSTEM
   =================================== */

/* CSS Variables for Responsive Design */
:root {
    /* Breakpoints */
    --breakpoint-xs: 375px;
    --breakpoint-sm: 640px;
    --breakpoint-md: 768px;
    --breakpoint-lg: 1024px;
    --breakpoint-xl: 1280px;
    --breakpoint-2xl: 1536px;
    
    /* Spacing Scale */
    --space-xs: 0.25rem;
    --space-sm: 0.5rem;
    --space-md: 1rem;
    --space-lg: 1.5rem;
    --space-xl: 2rem;
    --space-2xl: 3rem;
    --space-3xl: 4rem;
    
    /* Container Widths */
    --container-xs: 100%;
    --container-sm: 640px;
    --container-md: 768px;
    --container-lg: 1024px;
    --container-xl: 1280px;
    --container-2xl: 1536px;
}

/* ===================================
   BASE RESPONSIVE STYLES
   =================================== */

* {
    box-sizing: border-box;
}

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

body {
    margin: 0;
    padding: 0;
    min-width: 320px;
    overflow-x: hidden;
}

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

/* Responsive Container */
.container {
    width: 100%;
    margin: 0 auto;
    padding: 0 1rem;
}

@media (min-width: 640px) {
    .container {
        max-width: var(--container-sm);
        padding: 0 1.5rem;
    }
}

@media (min-width: 768px) {
    .container {
        max-width: var(--container-md);
        padding: 0 2rem;
    }
}

@media (min-width: 1024px) {
    .container {
        max-width: var(--container-lg);
    }
}

@media (min-width: 1280px) {
    .container {
        max-width: var(--container-xl);
    }
}

/* ===================================
   NAVIGATION RESPONSIVE
   =================================== */

/* Mobile Navigation */
.mobile-menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--foreground);
}

@media (max-width: 768px) {
    .mobile-menu-toggle {
        display: block;
    }
    
    .navbar {
        position: relative;
    }
    
    .navbar-nav {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background: var(--background);
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
        transition: left 0.3s ease;
        z-index: 1000;
        overflow-y: auto;
        padding: 1rem;
    }
    
    .navbar-nav.active {
        left: 0;
    }
    
    .navbar-nav li {
        display: block;
        margin: 0.5rem 0;
    }
    
    .navbar-nav a {
        display: block;
        padding: 0.75rem;
        border-radius: var(--radius);
    }
    
    /* Mobile Overlay */
    .mobile-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0,0,0,0.5);
        z-index: 999;
    }
    
    .mobile-overlay.active {
        display: block;
    }
    
    /* Search Bar Mobile */
    .search-form {
        width: 100%;
        margin: 1rem 0;
    }
    
    .search-form input {
        width: 100%;
    }
}

/* ===================================
   PRODUCT GRID RESPONSIVE
   =================================== */

.product-list {
    display: grid;
    gap: 1.5rem;
    padding: 1rem;
}

/* Mobile: 1 column */
@media (max-width: 639px) {
    .product-list {
        grid-template-columns: 1fr;
    }
    
    .product-card {
        margin: 0 auto;
        max-width: 400px;
        width: 100%;
    }
}

/* Tablet: 2 columns */
@media (min-width: 640px) and (max-width: 1023px) {
    .product-list {
        grid-template-columns: repeat(2, 1fr);
    }
}

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

@media (min-width: 1280px) {
    .product-list {
        grid-template-columns: repeat(4, 1fr);
    }
}

/* ===================================
   CHECKOUT PAGES RESPONSIVE
   =================================== */

/* Checkout Progress */
@media (max-width: 768px) {
    .checkout-progress {
        padding: 1rem;
    }
    
    .progress-steps {
        flex-wrap: wrap;
        gap: 0.5rem;
    }
    
    .step-number {
        width: 32px;
        height: 32px;
        font-size: 14px;
    }
    
    .step-label {
        font-size: 0.75rem;
    }
    
    .step-connector {
        display: none;
    }
}

/* Checkout Forms */
@media (max-width: 768px) {
    .checkout-form {
        padding: 1rem;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .form-group {
        width: 100%;
        margin-bottom: 1rem;
    }
    
    .checkout-sidebar {
        position: relative;
        width: 100%;
        margin-top: 2rem;
    }
    
    /* Stack checkout layout on mobile */
    .checkout-content {
        flex-direction: column;
    }
    
    .checkout-main {
        width: 100%;
        padding-right: 0;
    }
}

/* Payment Methods Grid */
@media (max-width: 768px) {
    .payment-methods-grid {
        grid-template-columns: 1fr;
    }
    
    .payment-card {
        width: 100%;
    }
}

/* ===================================
   TABLES RESPONSIVE
   =================================== */

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

@media (max-width: 768px) {
    table {
        font-size: 0.875rem;
    }
    
    th, td {
        padding: 0.5rem;
    }
    
    /* Convert table to cards on mobile */
    .table-card-view {
        display: block;
    }
    
    .table-card-view thead {
        display: none;
    }
    
    .table-card-view tbody tr {
        display: block;
        margin-bottom: 1rem;
        border: 1px solid var(--border);
        border-radius: var(--radius);
        padding: 1rem;
    }
    
    .table-card-view tbody td {
        display: flex;
        justify-content: space-between;
        padding: 0.5rem 0;
        border: none;
    }
    
    .table-card-view tbody td:before {
        content: attr(data-label);
        font-weight: 600;
        margin-right: 1rem;
    }
}

/* ===================================
   BASKET/CART RESPONSIVE
   =================================== */

@media (max-width: 768px) {
    .basket-items {
        padding: 0.5rem;
    }
    
    .basket-item {
        flex-direction: column;
        padding: 1rem;
        border-bottom: 1px solid var(--border);
    }
    
    .basket-item-image {
        width: 100%;
        max-width: 200px;
        margin: 0 auto 1rem;
    }
    
    .basket-item-details {
        text-align: center;
    }
    
    .basket-item-actions {
        display: flex;
        justify-content: center;
        gap: 1rem;
        margin-top: 1rem;
    }
    
    .basket-summary {
        position: relative;
        width: 100%;
        margin-top: 2rem;
    }
}

/* ===================================
   PRODUCT DETAIL RESPONSIVE
   =================================== */

@media (max-width: 768px) {
    .product-detail {
        flex-direction: column;
    }
    
    .product-images {
        width: 100%;
        margin-bottom: 2rem;
    }
    
    .product-info {
        width: 100%;
        padding: 0 1rem;
    }
    
    .product-thumbnails {
        display: flex;
        overflow-x: auto;
        gap: 0.5rem;
        padding: 0.5rem 0;
    }
    
    .product-thumbnails img {
        width: 60px;
        height: 60px;
        flex-shrink: 0;
    }
}

/* ===================================
   MODALS RESPONSIVE
   =================================== */

@media (max-width: 768px) {
    .modal-dialog {
        margin: 0;
        width: 100%;
        height: 100%;
        max-width: none;
    }
    
    .modal-content {
        height: 100%;
        border-radius: 0;
    }
    
    .modal-body {
        overflow-y: auto;
    }
}

/* ===================================
   FORMS RESPONSIVE
   =================================== */

@media (max-width: 768px) {
    .form-group {
        margin-bottom: 1rem;
    }
    
    input[type="text"],
    input[type="email"],
    input[type="tel"],
    input[type="password"],
    textarea,
    select {
        width: 100%;
        font-size: 16px; /* Prevents zoom on iOS */
    }
    
    .btn {
        width: 100%;
        padding: 0.75rem;
        font-size: 1rem;
    }
    
    .btn-group {
        flex-direction: column;
        width: 100%;
    }
    
    .btn-group .btn {
        border-radius: var(--radius);
        margin: 0.25rem 0;
    }
}

/* ===================================
   FOOTER RESPONSIVE
   =================================== */

@media (max-width: 768px) {
    footer {
        padding: 2rem 1rem;
    }
    
    .footer-content {
        flex-direction: column;
        text-align: center;
    }
    
    .footer-section {
        margin-bottom: 2rem;
        width: 100%;
    }
    
    .footer-links {
        flex-direction: column;
        gap: 0.5rem;
    }
}

/* ===================================
   UTILITY CLASSES
   =================================== */

/* Hide on mobile */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

/* Hide on tablet */
@media (min-width: 769px) and (max-width: 1024px) {
    .hide-tablet {
        display: none !important;
    }
}

/* Hide on desktop */
@media (min-width: 1025px) {
    .hide-desktop {
        display: none !important;
    }
}

/* Show only on mobile */
.show-mobile {
    display: none !important;
}

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

/* Responsive Text */
@media (max-width: 768px) {
    h1 {
        font-size: 1.75rem;
    }
    
    h2 {
        font-size: 1.5rem;
    }
    
    h3 {
        font-size: 1.25rem;
    }
    
    h4 {
        font-size: 1.125rem;
    }
    
    .text-xs {
        font-size: 0.75rem;
    }
    
    .text-sm {
        font-size: 0.875rem;
    }
    
    .text-base {
        font-size: 1rem;
    }
    
    .text-lg {
        font-size: 1.125rem;
    }
    
    .text-xl {
        font-size: 1.25rem;
    }
}

/* Responsive Spacing */
@media (max-width: 768px) {
    .p-xs { padding: var(--space-xs); }
    .p-sm { padding: var(--space-sm); }
    .p-md { padding: var(--space-md); }
    .p-lg { padding: var(--space-lg); }
    
    .m-xs { margin: var(--space-xs); }
    .m-sm { margin: var(--space-sm); }
    .m-md { margin: var(--space-md); }
    .m-lg { margin: var(--space-lg); }
}

/* Responsive Flexbox */
@media (max-width: 768px) {
    .flex-mobile-column {
        flex-direction: column;
    }
    
    .flex-mobile-wrap {
        flex-wrap: wrap;
    }
}

/* Touch-friendly elements */
@media (hover: none) and (pointer: coarse) {
    button,
    a,
    .clickable {
        min-height: 44px;
        min-width: 44px;
    }
}