/**
 * BienHabillé - Responsive Styles
 * 
 * Breakpoints globaux et ajustements responsive
 * Ce fichier doit être chargé en dernier
 * 
 * @package BienHabille
 * @since 1.0.0
 */

/* ========================================================================== */
/* BREAKPOINTS REFERENCE
 * 
 * xs: 0 - 479px      (Mobile portrait)
 * sm: 480px - 767px  (Mobile landscape / Small tablet)
 * md: 768px - 991px  (Tablet)
 * lg: 992px - 1199px (Small desktop)
 * xl: 1200px - 1399px (Desktop)
 * xxl: 1400px+       (Large desktop)
 * 
 * ========================================================================== */

/* ========================================================================== */
/* CONTAINER RESPONSIVE */
/* ========================================================================== */

.bh-container {
    width: 100%;
    max-width: var(--bh-container-max-width, 1400px);
    margin-left: auto;
    margin-right: auto;
    padding-left: var(--bh-container-padding, 20px);
    padding-right: var(--bh-container-padding, 20px);
}

@media (max-width: 767px) {
    :root {
        --bh-container-padding: 16px;
    }
}

@media (min-width: 1400px) {
    .bh-container--wide {
        max-width: 1600px;
    }
}

/* ========================================================================== */
/* GRILLES RESPONSIVE */
/* ========================================================================== */

/* Grille de base */
.bh-grid {
    display: grid;
    gap: var(--bh-spacing-6);
}

/* Grille 2 colonnes */
.bh-grid--2 {
    grid-template-columns: repeat(2, 1fr);
}

/* Grille 3 colonnes */
.bh-grid--3 {
    grid-template-columns: repeat(3, 1fr);
}

/* Grille 4 colonnes */
.bh-grid--4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Grille produits (responsive) */
.bh-grid--products {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--bh-spacing-4);
}

@media (max-width: 1199px) {
    .bh-grid--4,
    .bh-grid--products {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 991px) {
    .bh-grid--3,
    .bh-grid--4,
    .bh-grid--products {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 479px) {
    .bh-grid--2,
    .bh-grid--3,
    .bh-grid--4 {
        grid-template-columns: 1fr;
    }
    
    .bh-grid--products {
        grid-template-columns: repeat(2, 1fr);
        gap: var(--bh-spacing-3);
    }
}

/* ========================================================================== */
/* LAYOUT PRINCIPAL */
/* ========================================================================== */

.bh-layout {
    display: flex;
    gap: var(--bh-spacing-8);
}

.bh-layout__main {
    flex: 1;
    min-width: 0;
}

.bh-layout__sidebar {
    flex: 0 0 280px;
    width: 280px;
}

.bh-layout--sidebar-left {
    flex-direction: row-reverse;
}

@media (max-width: 991px) {
    .bh-layout {
        flex-direction: column;
    }
    
    .bh-layout__sidebar {
        flex: none;
        width: 100%;
    }
}

/* ========================================================================== */
/* TYPOGRAPHIE RESPONSIVE */
/* ========================================================================== */

@media (max-width: 767px) {
    :root {
        --bh-font-size-base: 14px;
        --bh-font-size-lg: 16px;
        --bh-font-size-xl: 18px;
        --bh-font-size-2xl: 20px;
        --bh-font-size-3xl: 24px;
        --bh-font-size-4xl: 28px;
    }
    
    h1, .h1 {
        font-size: var(--bh-font-size-3xl);
    }
    
    h2, .h2 {
        font-size: var(--bh-font-size-2xl);
    }
    
    h3, .h3 {
        font-size: var(--bh-font-size-xl);
    }
}

/* ========================================================================== */
/* ESPACEMENTS RESPONSIVE */
/* ========================================================================== */

@media (max-width: 767px) {
    :root {
        --bh-spacing-8: 24px;
        --bh-spacing-10: 32px;
        --bh-spacing-12: 40px;
        --bh-spacing-16: 48px;
    }
    
    .bh-section {
        padding-top: var(--bh-spacing-10);
        padding-bottom: var(--bh-spacing-10);
    }
}

/* ========================================================================== */
/* UTILITAIRES D'AFFICHAGE RESPONSIVE */
/* ========================================================================== */

/* Masquer sur mobile */
@media (max-width: 767px) {
    .bh-hide-mobile {
        display: none !important;
    }
}

/* Masquer sur tablette */
@media (min-width: 768px) and (max-width: 991px) {
    .bh-hide-tablet {
        display: none !important;
    }
}

/* Masquer sur desktop */
@media (min-width: 992px) {
    .bh-hide-desktop {
        display: none !important;
    }
}

/* Afficher seulement sur mobile */
@media (min-width: 768px) {
    .bh-show-mobile-only {
        display: none !important;
    }
}

/* Afficher seulement sur desktop */
@media (max-width: 991px) {
    .bh-show-desktop-only {
        display: none !important;
    }
}

/* ========================================================================== */
/* TEXTE RESPONSIVE */
/* ========================================================================== */

@media (max-width: 767px) {
    .bh-text-center-mobile {
        text-align: center !important;
    }
    
    .bh-text-left-mobile {
        text-align: left !important;
    }
}

/* ========================================================================== */
/* FLEX RESPONSIVE */
/* ========================================================================== */

@media (max-width: 767px) {
    .bh-flex-column-mobile {
        flex-direction: column !important;
    }
    
    .bh-flex-wrap-mobile {
        flex-wrap: wrap !important;
    }
}

/* ========================================================================== */
/* BOUTONS RESPONSIVE */
/* ========================================================================== */

@media (max-width: 479px) {
    .bh-btn--full-mobile {
        width: 100%;
    }
    
    .bh-btn-group--stack-mobile {
        flex-direction: column;
    }
    
    .bh-btn-group--stack-mobile .bh-btn {
        width: 100%;
    }
}

/* ========================================================================== */
/* IMAGES RESPONSIVE */
/* ========================================================================== */

.bh-img-responsive {
    max-width: 100%;
    height: auto;
}

.bh-img-cover {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.bh-img-contain {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* ========================================================================== */
/* TABLEAUX RESPONSIVE */
/* ========================================================================== */

.bh-table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

@media (max-width: 767px) {
    .bh-table-responsive table {
        min-width: 600px;
    }
    
    /* Table en mode carte sur mobile */
    .bh-table-stack-mobile thead {
        display: none;
    }
    
    .bh-table-stack-mobile tbody tr {
        display: block;
        margin-bottom: var(--bh-spacing-4);
        padding: var(--bh-spacing-4);
        border: 1px solid var(--bh-border-color);
        border-radius: var(--bh-border-radius);
    }
    
    .bh-table-stack-mobile tbody td {
        display: flex;
        justify-content: space-between;
        padding: var(--bh-spacing-2) 0;
        border: none;
        border-bottom: 1px solid var(--bh-border-color);
    }
    
    .bh-table-stack-mobile tbody td:last-child {
        border-bottom: none;
    }
    
    .bh-table-stack-mobile tbody td::before {
        content: attr(data-label);
        font-weight: var(--bh-font-weight-semibold);
        margin-right: var(--bh-spacing-4);
    }
}

/* ========================================================================== */
/* FORMULAIRES RESPONSIVE */
/* ========================================================================== */

@media (max-width: 767px) {
    .bh-form-row {
        flex-direction: column;
    }
    
    .bh-form-row > * {
        width: 100%;
    }
    
    .bh-form-inline {
        flex-direction: column;
        align-items: stretch;
    }
    
    .bh-form-inline .bh-btn {
        width: 100%;
        margin-top: var(--bh-spacing-3);
    }
}

/* ========================================================================== */
/* MODAL / DRAWER RESPONSIVE */
/* ========================================================================== */

@media (max-width: 767px) {
    .bh-modal__content {
        width: 95%;
        max-width: none;
        margin: var(--bh-spacing-4);
        max-height: calc(100vh - 32px);
    }
    
    .bh-drawer {
        width: 100%;
        max-width: 100%;
    }
}

/* ========================================================================== */
/* NAVIGATION RESPONSIVE */
/* ========================================================================== */

@media (max-width: 991px) {
    /* Menu principal caché sur mobile/tablette */
    .bh-nav--main {
        display: none;
    }
    
    /* Bouton menu hamburger visible */
    .bh-mobile-menu-toggle {
        display: flex;
    }
}

@media (min-width: 992px) {
    /* Menu principal visible sur desktop */
    .bh-nav--main {
        display: flex;
    }
    
    /* Bouton menu hamburger caché */
    .bh-mobile-menu-toggle {
        display: none;
    }
    
    /* Menu mobile caché */
    .bh-mobile-menu {
        display: none;
    }
}

/* ========================================================================== */
/* PRODUITS RESPONSIVE */
/* ========================================================================== */

@media (max-width: 767px) {
    /* Carte produit compacte */
    .bh-product-card__info {
        padding: var(--bh-spacing-3);
    }
    
    .bh-product-card__title {
        font-size: var(--bh-font-size-sm);
    }
    
    .bh-product-card__price {
        font-size: var(--bh-font-size-sm);
    }
    
    /* Badges plus petits */
    .bh-badge {
        font-size: 10px;
        padding: 2px 6px;
    }
    
    /* Actions rapides empilées */
    .bh-product-card__actions {
        flex-direction: column;
        gap: var(--bh-spacing-2);
    }
}

/* ========================================================================== */
/* PAGE PRODUIT RESPONSIVE */
/* ========================================================================== */

@media (max-width: 991px) {
    .bh-product-single {
        flex-direction: column;
    }
    
    .bh-product-single__gallery {
        width: 100%;
    }
    
    .bh-product-single__info {
        width: 100%;
    }
}

@media (max-width: 767px) {
    .bh-product-single__gallery-thumbs {
        display: flex;
        overflow-x: auto;
        gap: var(--bh-spacing-2);
        padding-bottom: var(--bh-spacing-2);
    }
    
    .bh-product-single__gallery-thumb {
        flex: 0 0 60px;
    }
}

/* ========================================================================== */
/* CHECKOUT RESPONSIVE */
/* ========================================================================== */

@media (max-width: 991px) {
    .bh-checkout-layout {
        flex-direction: column;
    }
    
    .bh-checkout__main,
    .bh-checkout__sidebar {
        width: 100%;
    }
    
    .bh-checkout__sidebar {
        order: -1;
        margin-bottom: var(--bh-spacing-6);
    }
}

/* ========================================================================== */
/* PANIER RESPONSIVE */
/* ========================================================================== */

@media (max-width: 767px) {
    .bh-cart-item {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .bh-cart-item__image {
        width: 100%;
        max-width: 120px;
    }
    
    .bh-cart-item__details {
        width: 100%;
    }
    
    .bh-cart-item__quantity {
        margin-top: var(--bh-spacing-3);
    }
}

/* ========================================================================== */
/* BLOG RESPONSIVE */
/* ========================================================================== */

@media (max-width: 767px) {
    .bh-post-card--horizontal {
        flex-direction: column;
    }
    
    .bh-post-card--horizontal .bh-post-card__image {
        width: 100%;
        aspect-ratio: 16/9;
    }
}

/* ========================================================================== */
/* TOUCH DEVICES */
/* ========================================================================== */

@media (hover: none) and (pointer: coarse) {
    /* Agrandir les zones tactiles */
    .bh-btn,
    .bh-link,
    input,
    select,
    textarea {
        min-height: 44px;
    }
    
    /* Désactiver les effets hover */
    .bh-product-card:hover .bh-product-card__actions {
        opacity: 1;
        visibility: visible;
    }
    
    /* Afficher les actions toujours sur tactile */
    .bh-product-card__quick-actions {
        opacity: 1;
    }
}

/* ========================================================================== */
/* ORIENTATION */
/* ========================================================================== */

@media (orientation: landscape) and (max-height: 500px) {
    /* Ajustements pour paysage sur petit écran (mobile horizontal) */
    .bh-modal__content {
        max-height: 90vh;
    }
    
    .bh-header--sticky {
        position: relative;
    }
}

/* ========================================================================== */
/* HIGH DPI / RETINA */
/* ========================================================================== */

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Bordures plus fines sur écrans retina */
    .bh-border-thin {
        border-width: 0.5px;
    }
}

/* ========================================================================== */
/* PREFERS 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;
    }
}

/* ========================================================================== */
/* DARK MODE (si supporté) */
/* ========================================================================== */

@media (prefers-color-scheme: dark) {
    /* 
     * Décommenter pour activer le dark mode automatique
     * 
    :root {
        --bh-bg-primary: #1a1a1a;
        --bh-bg-secondary: #2d2d2d;
        --bh-text-primary: #ffffff;
        --bh-text-secondary: #a3a3a3;
        --bh-text-tertiary: #737373;
        --bh-border-color: #404040;
    }
    */
}

/* ========================================================================== */
/* PRINT */
/* ========================================================================== */

@media print {
    /* Reset pour impression */
    *,
    *::before,
    *::after {
        background: transparent !important;
        color: #000 !important;
        box-shadow: none !important;
        text-shadow: none !important;
    }
    
    body {
        font-size: 12pt;
        line-height: 1.5;
    }
    
    /* Masquer éléments non essentiels */
    .bh-header,
    .bh-footer,
    .bh-sidebar,
    .bh-nav,
    .bh-mobile-menu,
    .bh-announcement,
    .bh-btn,
    .bh-pagination,
    .bh-breadcrumbs,
    .bh-filters,
    .bh-quick-view,
    .bh-modal,
    nav,
    aside,
    form {
        display: none !important;
    }
    
    /* Afficher les URLs des liens */
    a[href]::after {
        content: " (" attr(href) ")";
        font-size: 10pt;
    }
    
    /* Éviter les coupures */
    img,
    tr,
    h1, h2, h3, h4, h5, h6 {
        page-break-inside: avoid;
    }
    
    h1, h2, h3 {
        page-break-after: avoid;
    }
    
    /* Images en niveau de gris */
    img {
        max-width: 100% !important;
        filter: grayscale(100%);
    }
}