/**
 * DigitalWC - Responsive Styles
 * Mobile-first responsive design
 */

/* ==========================================================================
   MOBILE FIRST - BASE (< 640px)
   ========================================================================== */

/* Typography adjustments */
@media (max-width: 639px) {
    html {
        font-size: 15px;
    }

    h1 {
        font-size: var(--dwc-font-size-2xl);
    }

    h2 {
        font-size: var(--dwc-font-size-xl);
    }

    h3 {
        font-size: var(--dwc-font-size-lg);
    }

    .dwc-section {
        padding: var(--dwc-space-10) 0;
    }

    .dwc-section__title {
        font-size: var(--dwc-font-size-2xl);
    }

    .dwc-section__subtitle {
        font-size: var(--dwc-font-size-base);
    }

    /* Buttons stack on mobile */
    .dwc-btn-group--mobile-stack {
        flex-direction: column;
        width: 100%;
    }

    .dwc-btn-group--mobile-stack .dwc-btn {
        width: 100%;
    }

    /* Cards full width */
    .dwc-card {
        border-radius: var(--dwc-radius-lg);
    }

    /* Smaller padding on mobile */
    .dwc-card__body {
        padding: var(--dwc-space-4);
    }
}

/* ==========================================================================
   SMALL TABLETS (640px - 767px)
   ========================================================================== */

@media (min-width: 640px) and (max-width: 767px) {
    .dwc-container {
        padding-left: var(--dwc-space-5);
        padding-right: var(--dwc-space-5);
    }
}

/* ==========================================================================
   TABLETS (768px - 1023px)
   ========================================================================== */

@media (min-width: 768px) and (max-width: 1023px) {
    .dwc-section {
        padding: var(--dwc-space-12) 0;
    }
}

/* ==========================================================================
   MOBILE MENU
   ========================================================================== */

@media (max-width: 1023px) {
    /* Mobile header adjustments */
    .dwc-header {
        height: var(--dwc-header-height-mobile);
    }

    .dwc-main {
        padding-top: var(--dwc-header-height-mobile);
    }

    /* Hide desktop navigation */
    .dwc-nav--desktop {
        display: none;
    }

    /* Show mobile menu button */
    .dwc-menu-toggle {
        display: flex;
    }

    /* Mobile menu fullscreen */
    .dwc-mobile-menu {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--dwc-bg-surface);
        z-index: var(--dwc-z-modal);
        display: flex;
        flex-direction: column;
        opacity: 0;
        visibility: hidden;
        transform: translateX(-100%);
        transition: all 0.3s ease;
    }

    .dwc-mobile-menu--open {
        opacity: 1;
        visibility: visible;
        transform: translateX(0);
    }

    .dwc-mobile-menu__header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: var(--dwc-space-4);
        border-bottom: 1px solid var(--dwc-border-color);
    }

    .dwc-mobile-menu__nav {
        flex: 1;
        overflow-y: auto;
        padding: var(--dwc-space-4);
    }

    .dwc-mobile-menu__item {
        display: flex;
        align-items: center;
        gap: var(--dwc-space-4);
        padding: var(--dwc-space-4);
        font-size: var(--dwc-font-size-lg);
        font-weight: var(--dwc-font-weight-medium);
        color: var(--dwc-text-primary);
        border-radius: var(--dwc-radius-lg);
        transition: background var(--dwc-transition-fast);
    }

    .dwc-mobile-menu__item:hover,
    .dwc-mobile-menu__item--active {
        background: var(--dwc-bg-surface-2);
        color: var(--dwc-color-primary);
    }

    .dwc-mobile-menu__footer {
        padding: var(--dwc-space-4);
        border-top: 1px solid var(--dwc-border-color);
    }

    /* Bottom navigation for mobile */
    .dwc-bottom-nav {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: var(--dwc-bg-surface);
        border-top: 1px solid var(--dwc-border-color);
        display: flex;
        justify-content: space-around;
        padding: var(--dwc-space-2) 0;
        padding-bottom: calc(var(--dwc-space-2) + env(safe-area-inset-bottom));
        z-index: var(--dwc-z-sticky);
        box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    }

    .dwc-bottom-nav__item {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: var(--dwc-space-1);
        padding: var(--dwc-space-2);
        color: var(--dwc-text-secondary);
        font-size: var(--dwc-font-size-xs);
        transition: color var(--dwc-transition-fast);
    }

    .dwc-bottom-nav__item--active {
        color: var(--dwc-color-primary);
    }

    .dwc-bottom-nav__icon {
        width: 24px;
        height: 24px;
    }

    /* Add padding to main for bottom nav */
    body.dwc-has-bottom-nav .dwc-main {
        padding-bottom: 70px;
    }
}

/* ==========================================================================
   DESKTOP (1024px+)
   ========================================================================== */

@media (min-width: 1024px) {
    /* Hide mobile elements */
    .dwc-menu-toggle {
        display: none;
    }

    .dwc-mobile-menu {
        display: none;
    }

    .dwc-bottom-nav {
        display: none;
    }

    /* Desktop navigation */
    .dwc-nav--desktop {
        display: flex;
    }
}

/* ==========================================================================
   LARGE DESKTOP (1280px+)
   ========================================================================== */

@media (min-width: 1280px) {
    .dwc-container {
        padding-left: var(--dwc-space-8);
        padding-right: var(--dwc-space-8);
    }
}

/* ==========================================================================
   EXTRA LARGE (1536px+)
   ========================================================================== */

@media (min-width: 1536px) {
    .dwc-container {
        max-width: 1500px;
    }
}

/* ==========================================================================
   TOUCH DEVICES
   ========================================================================== */

@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .dwc-btn {
        min-height: 44px;
    }

    .dwc-btn--sm {
        min-height: 36px;
    }

    .dwc-input {
        min-height: 44px;
    }

    /* Remove hover effects on touch */
    .dwc-card--hover:hover {
        transform: none;
    }

    .dwc-hover-lift:hover {
        transform: none;
    }

    .dwc-hover-scale:hover {
        transform: none;
    }

    /* Active states instead of hover */
    .dwc-btn:active {
        transform: scale(0.98);
    }

    .dwc-card--hover:active {
        transform: scale(0.99);
    }
}

/* ==========================================================================
   LANDSCAPE MOBILE
   ========================================================================== */

@media (max-height: 500px) and (orientation: landscape) {
    .dwc-mobile-menu__nav {
        padding: var(--dwc-space-2);
    }

    .dwc-mobile-menu__item {
        padding: var(--dwc-space-2) var(--dwc-space-4);
    }

    .dwc-hero {
        min-height: auto;
        padding: var(--dwc-space-8) 0;
    }
}

/* ==========================================================================
   HIGH RESOLUTION DISPLAYS
   ========================================================================== */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Use higher resolution images */
}

/* ==========================================================================
   PRINT STYLES
   ========================================================================== */

@media print {
    .dwc-header,
    .dwc-footer,
    .dwc-bottom-nav,
    .dwc-mobile-menu,
    .dwc-btn,
    .dwc-modal {
        display: none !important;
    }

    body {
        background: white;
        color: black;
    }

    .dwc-main {
        padding-top: 0;
    }

    .dwc-container {
        max-width: 100%;
        padding: 0;
    }

    a {
        color: black;
        text-decoration: underline;
    }

    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 0.8em;
    }
}

/* ==========================================================================
   SAFE AREA INSETS (iOS)
   ========================================================================== */

@supports (padding: env(safe-area-inset-bottom)) {
    .dwc-bottom-nav {
        padding-bottom: calc(var(--dwc-space-2) + env(safe-area-inset-bottom));
    }

    .dwc-mobile-menu__footer {
        padding-bottom: calc(var(--dwc-space-4) + env(safe-area-inset-bottom));
    }
}

/* ==========================================================================
   DARK MODE RESPONSIVE
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    /* Auto dark mode based on system preference */
    .dwc-auto-dark {
        --dwc-bg-body: #0F0F1A;
        --dwc-bg-surface: #1A1A2E;
        --dwc-text-primary: #F8F9FC;
    }
}

/* ==========================================================================
   CONTAINER QUERIES (Future-proofing)
   ========================================================================== */

@supports (container-type: inline-size) {
    .dwc-product-grid {
        container-type: inline-size;
    }

    @container (max-width: 600px) {
        .dwc-product-card {
            flex-direction: column;
        }
    }
}

/* ==========================================================================
   ACCESSIBILITY - FORCED COLORS
   ========================================================================== */

@media (forced-colors: active) {
    .dwc-btn {
        border: 2px solid currentColor;
    }

    .dwc-input {
        border: 2px solid currentColor;
    }

    .dwc-card {
        border: 1px solid currentColor;
    }
}

/* ==========================================================================
   SIDEBAR RESPONSIVE
   ========================================================================== */

@media (max-width: 1023px) {
    .dwc-layout-sidebar {
        flex-direction: column;
    }

    .dwc-sidebar {
        width: 100%;
        order: 2;
        margin-top: var(--dwc-space-8);
    }

    .dwc-content {
        width: 100%;
        order: 1;
    }
}

@media (min-width: 1024px) {
    .dwc-layout-sidebar {
        display: flex;
        gap: var(--dwc-space-8);
    }

    .dwc-content {
        flex: 1;
        min-width: 0;
    }

    .dwc-sidebar {
        width: var(--dwc-sidebar-width);
        flex-shrink: 0;
    }

    .dwc-sidebar--left {
        order: -1;
    }
}

/* ==========================================================================
   FILTER RESPONSIVE
   ========================================================================== */

@media (max-width: 767px) {
    .dwc-filters {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--dwc-bg-surface);
        z-index: var(--dwc-z-modal);
        overflow-y: auto;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }

    .dwc-filters--open {
        transform: translateX(0);
    }

    .dwc-filter-toggle {
        display: flex;
    }
}

@media (min-width: 768px) {
    .dwc-filters {
        display: block;
    }

    .dwc-filter-toggle {
        display: none;
    }
}
