/* ========================================
   DevShop - Mise en Page & Responsive
   Fichier : layout.css
   ======================================== */

/* ========================================
   HEADER
   ======================================== */

.header {
    position: sticky;
    top: 0;
    width: 100%;
    height: var(--header-height);
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    z-index: 1000;
}

.header-content {
    max-width: 1400px;
    height: 100%;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.logo h1 {
    font-size: clamp(20px, 2.5vw, 26px);
    font-weight: 600;
    letter-spacing: -0.025em;
    color: var(--primary);
    cursor: pointer;
}

.navbar {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* ========================================
   MAIN CONTENT & LAYOUT
   ======================================== */

.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px 20px;
    display: grid;
    grid-template-columns: 240px minmax(0, 1fr);
    gap: clamp(24px, 3vw, 42px);
    min-height: calc(100vh - var(--header-height));
}

/* ========================================
   FILTER SIDEBAR
   ======================================== */

.filter-sidebar {
    min-width: 0;
    position: sticky;
    top: calc(var(--header-height) + 24px);
    align-self: start;
    width: 240px;
    max-height: calc(100vh - var(--header-height) - 48px);
    overflow-y: auto;
    scrollbar-color: var(--line-strong) transparent;
    scrollbar-width: thin;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius-md);
    padding: 16px;
    z-index: 100;
}

.filter-sidebar.open {
    left: 0;
}

.filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--line);
}

.filter-header h2 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.025em;
}

/* Barre de recherche dans le tiroir des filtres */
.filter-search-container {
    padding: 0 0 16px 0;
    border-bottom: 1px solid var(--line);
    margin-bottom: 16px;
    display: block;
}

.filter-search-container .search-container input {
    width: 100%;
}

.filter-section {
    margin-bottom: 20px;
}

.filter-section h3 {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
    letter-spacing: -0.025em;
}

.category-filters {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.category-button {
    width: 100%;
    padding: 10px 12px;
    background: var(--surface-soft);
    color: var(--text);
    border: 1px solid var(--line);
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 400;
    text-align: left;
    cursor: pointer;
    transition: all var(--duration) var(--ease-out);
}

.category-button:hover {
    background: var(--line);
    border-color: var(--line-strong);
}

.category-button.active {
    background: var(--primary-soft);
    border-color: var(--primary);
    color: var(--primary);
    font-weight: 600;
}

.category-button i {
    margin-right: 8px;
}

.category-button span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========================================
   PRODUCTS SECTION
   ======================================== */

.products-section {
    min-width: 0;
}

.catalog-heading {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 26px;
    flex-wrap: wrap;
}

.title-group {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    flex-direction: column;
}

.title-group h2 {
    font-size: clamp(26px, 3vw, 34px);
    font-weight: 600;
    letter-spacing: -0.025em;
}

.product-count {
    font-size: 13px;
    color: var(--text-secondary);
}

/* Products Grid */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: clamp(16px, 2vw, 24px);
}

/* ========================================
   CART DRAWER (OFF-CANVAS)
   ======================================== */

.cart-drawer {
    position: fixed;
    top: 0;
    right: 0;
    width: 100%;
    height: 100vh;
    z-index: 1500;
    display: flex;
    align-items: flex-start;
    justify-content: flex-end;
    opacity: 0;
    visibility: hidden;
    transition: opacity var(--duration) var(--ease-out), 
                visibility var(--duration) var(--ease-out);
}

.cart-drawer.open {
    opacity: 1;
    visibility: visible;
}

.cart-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    /* backdrop-filter: blur(8px); */
    /* -webkit-backdrop-filter: blur(8px); */
    /* z-index: 1; */
}

.cart-content {
    width: min(400px, 100%);
    height: 100vh;
    background: var(--surface);
    border-left: 1px solid var(--line);
    box-shadow: var(--shadow-menu);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateX(100%);
    transition: transform var(--duration) var(--ease-out);
}

.cart-drawer.open .cart-content {
    transform: translateX(0);
}

.cart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--line);
}

.cart-header h2 {
    font-size: 18px;
    font-weight: 600;
    letter-spacing: -0.025em;
}

.cart-items {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.cart-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--line);
    background: var(--surface-soft);
}

.cart-footer.empty {
    display: none;
}

.cart-total {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    font-size: 16px;
    color: var(--text);
}

.cart-total strong {
    font-size: 18px;
    font-weight: 600;
    color: var(--primary);
}

.clear-cart-button {
    width: 100%;
    padding: 12px;
    margin-bottom: 10px;
    background: transparent;
    border: 1px solid var(--danger);
    color: var(--danger);
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--duration) var(--ease-out);
}

.clear-cart-button:hover {
    background: var(--danger-soft);
}

.checkout-button {
    width: 100%;
    padding: 14px;
    background: var(--primary);
    color: white;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--radius-sm);
    transition: all var(--duration) var(--ease-out);
}

.checkout-button:hover:not(:disabled) {
    background: var(--primary-hover);
}

.checkout-button:disabled,
.checkout-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--text-tertiary);
}

/* ========================================
   MOBILE NAVIGATION
   ======================================== */

.mobile-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: var(--mobile-nav-height);
    background: var(--surface);
    border-top: 1px solid var(--line);
    display: none;
    z-index: 1000;
}

.mobile-nav.active {
    display: flex;
}

.mobile-nav-item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 8px 16px;
    background: transparent;
    border: 0;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--duration) var(--ease-out);
    border-top: 2px solid transparent;
}

.mobile-nav-item:hover {
    color: var(--text);
}

.mobile-nav-item i {
    font-size: 18px;
}

.mobile-cart-count {
    position: absolute;
    top: 4px;
    right: 8px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    background: var(--primary);
    color: white;
    font-size: 10px;
    font-weight: 600;
    border-radius: var(--radius-pill);
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-cart-count:empty {
    display: none;
}

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

@media (min-width: 1025px) {
    .main-content {
        grid-template-columns: 240px minmax(0, 1fr);
        gap: clamp(24px, 3vw, 42px);
    }
    
    .filter-sidebar {
        width: 240px;
        max-height: calc(100vh - var(--header-height) - 48px);
    }
    
    .cart-content {
        height: 100vh;
        border-left: 1px solid var(--line);
    }
    
    .navbar {
        gap: 16px;
    }
    
    .header-search input {
        width: 240px;
    }
    
    .mobile-nav {
        display: none;
    }
    
    /* Masquer le bouton de fermeture sur desktop */
    #close-filters {
        display: none;
    }
}

/* Tablettes et grands écrans (920px - 1024px) */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 200px minmax(0, 1fr);
        gap: 20px;
    }
    
    .filter-sidebar {
        width: 200px;
        max-height: calc(100vh - var(--header-height) - 40px);
    }
    
    /* Masquer le bouton de fermeture sur tablette aussi */
    #close-filters {
        display: none;
    }
    
    .mobile-nav {
        display: none;
    }
    
    .header-search input {
        width: 200px;
    }
}

/* Mobile et petits écrans (<= 919px) */
@media (max-width: 919px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .filter-sidebar {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        border-radius: 0;
        border: 0;
        border-right: 1px solid var(--line);
        max-height: none;
        z-index: 1500;
        transform: translateX(0);
        transition: transform var(--duration) var(--ease-out);
    }
    
    .filter-sidebar.open {
        left: 0;
    }
    
    /* Afficher le bouton de fermeture sur mobile */
    #close-filters {
        display: flex;
        justify-content: space-around;
    }
    
    .navbar {
        gap: 12px;
    }
    
    .header-search input {
        width: 160px;
    }
    
    .mobile-nav {
        display: flex;
    }
}

@media (max-width: 768px) {
    .header-content {
        padding: 0 16px;
    }
    
    .header-search input {
        width: 250px;
    }
    
    .catalog-heading {
        flex-direction: column;
        align-items: flex-start;
        gap: 16px;
    }
    
    .sort-select {
        min-width: 140px;
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 16px;
    }
    
    .cart-content {
        width: 100%;
        border-left: 0;
    }
    
    .cart-item {
        grid-template-columns: 60px minmax(0, 1fr) auto;
    }
    
    .cart-item-image {
        width: 60px;
        height: 60px;
    }
    
    .filter-sidebar {
        width: 85%;
    }
}

@media (max-width: 559px) {
    .header-content {
        padding: 0 12px;
    }
    
    .logo h1 {
        font-size: 22px;
    }
    
    .header-search {
        display: none;
    }
    
    .main-content {
        padding: 16px 12px;
        min-height: calc(100vh - var(--header-height) - var(--mobile-nav-height));
    }
    
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
        gap: 14px;
    }
    
    .product-card {
        min-width: 160px;
    }
    
    .product-media {
        aspect-ratio: 1;
    }
    
    .product-info {
        padding: 12px;
    }
    
    .product-title {
        font-size: 13px;
    }
    
    .product-price {
        font-size: 14px;
    }
    
    .add-to-cart {
        padding: 6px 10px;
        font-size: 11px;
    }
    
    .cart-empty {
        padding: 30px 16px;
    }
    
    .cart-empty button {
        width: 100%;
    }
    
    .mobile-nav {
        display: flex;
    }
}

@media (max-width: 400px) {
    .header-search {
        display: none;
    }
    
    .products-grid {
        grid-template-columns: 1fr;
    }
    
    .product-card {
        min-width: 0;
    }
    
    .sort-select {
        display: none;
    }
    
    .add-to-cart-notification {
        left: 16px;
        right: 16px;
        transform: none;
        width: auto;
        max-width: calc(100% - 32px);
    }
}