/* ==========================================================================
   1. VARIABLES & CONFIGURATION DE BASE
   ========================================================================== */
:root {
    /* Couleurs principales */
    --primary: #2c3e50;
    --primary-light: #34495e;
    --secondary: #27ae60;
    --secondary-hover: #219150;
    --accent: #e67e22;
    
    /* Couleurs de fond et bordures */
    --bg-light: #f8fafc;
    --bg-white: #ffffff;
    --border: #edf2f7;
    
    /* Typographie */
    --text-dark: #2d3748;
    --text-muted: #718096;
    
    /* Effets */
    --shadow-sm: 0 2px 4px rgba(0,0,0,0.05);
    --shadow-md: 0 10px 30px rgba(0,0,0,0.08);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --radius-md: 12px;
    --radius-sm: 8px;
}

* {
    box-sizing: border-box;
}

body { 
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; 
    margin: 0; 
    background: var(--bg-light); 
    color: var(--text-dark); 
    line-height: 1.6;
    overflow-x: hidden;
}

.container { 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 0 15px; 
}

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

/* ==========================================================================
   2. COMPOSANTS GLOBAUX
   ========================================================================== */
.card-modern {
    background: white;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border);
    transition: var(--transition);
}

.btn-modern {
    border: none;
    border-radius: var(--radius-sm);
    padding: 12px 20px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--secondary); color: white; }
.btn-modern:hover { opacity: 0.9; transform: translateY(-1px); }
.w-100 { width: 100%; }

/* ==========================================================================
   3. HEADER & NAVIGATION
   ========================================================================== */
.main-header {
    background: var(--bg-white);
    padding: 10px 0;
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-grid {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.logo-img {
    height: 70px;
    width: auto;
    object-fit: contain;
    transition: var(--transition);
}

.search-form {
    display: flex;
    background: var(--bg-light);
    border-radius: 50px;
    padding: 5px 15px;
    border: 1px solid var(--border);
    height: 45px;
    transition: var(--transition);
}

.search-form:focus-within {
    background: white;
    box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.1);
    border-color: var(--secondary);
}

.search-form input { border: none; background: transparent; width: 100%; outline: none; }
.search-form button { border: none; background: transparent; color: var(--text-muted); cursor: pointer; }

.header-actions { display: flex; align-items: center; gap: 20px; }

.cart-icon-container {
    position: relative;
    font-size: 1.5rem;
    color: var(--primary);
}

.cart-badge {
    position: absolute;
    top: -8px;
    right: -10px;
    background: var(--secondary);
    color: white;
    font-size: 0.7rem;
    min-width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 2px solid white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* ==========================================================================
   4. INDEX : HERO & PRODUITS
   ========================================================================== */
.hero {
    position: relative;
    height: 330px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    text-align: center;
    margin-bottom: 40px;
}

.hero-slider .slide {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-size: cover;
    background-position: center;
    opacity: 0;
    transition: opacity 1.5s ease-in-out;
}

.slide.active { opacity: 1; }

.product-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr); 
    gap: 20px;
}

.product-card:hover {
    transform: translateY(-5px);
}

.product-image-container {
    position: relative;
    height: 230px;
    overflow: hidden;
    cursor: pointer;
}

.product-image-container img, .product-image-container video {
    width: 100%; height: 100%; object-fit: cover;
    transition: transform 0.5s ease;
}

.product-card:hover .product-image-container img {
    transform: scale(1.1);
}

.product-link { text-decoration: none; color: inherit; }
.product-card h3 { transition: color 0.3s ease; }
.product-card:hover h3 { color: var(--secondary); }

.stock-progress-bar {
    background: #edf2f7;
    height: 6px;
    border-radius: 10px;
    margin-top: 5px;
    overflow: hidden;
}

.stock-fill { height: 100%; transition: width 0.5s ease-out; }

/* ==========================================================================
   5. SIDEBAR : DESIGN ATTRACTIF
   ========================================================================== */
.sidebar-nav {
    width: 280px;
    position: sticky;
    top: 100px;
    z-index: 10;
    overflow: hidden;
    background: white;
}

.sidebar-header {
    background: linear-gradient(135deg, var(--primary) 0%, #34495e 100%);
    color: white;
    padding: 18px 20px;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-header i {
    font-size: 1.1rem;
    color: var(--secondary);
}

.cat-menu li {
    border-bottom: 1px solid var(--border);
    transition: var(--transition);
}

.cat-menu li:last-child {
    border-bottom: none;
}

.cat-menu li a {
    display: flex;
    padding: 14px 20px;
    text-decoration: none;
    font-weight: 500;
    color: var(--text-dark);
    transition: var(--transition);
    border-left: 4px solid transparent;
}

.cat-menu li:hover {
    background: #f0fdf4; /* Vert très pâle */
}

.cat-menu li:hover a {
    color: var(--secondary);
    border-left-color: var(--secondary);
    padding-left: 28px; /* Effet de glissement */
}

.cat-menu li a div {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ==========================================================================
   6. PAGE PRODUIT : GALERIE & INFOS
   ========================================================================== */
.product-view-container { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 40px; 
}

#media-viewer {
    width: 100%;
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-light);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.thumbnail-list {
    display: flex; gap: 10px; margin-top: 15px; overflow-x: auto; padding: 5px;
}

.thumbnail-item {
    cursor: pointer; width: 70px; height: 70px; border: 2px solid var(--border);
    border-radius: var(--radius-sm); overflow: hidden; flex-shrink: 0;
}

.thumbnail-item:hover { border-color: var(--secondary); }

/* ==========================================================================
   7. PANIER (CART.PHP)
   ========================================================================== */
.cart-table {
    width: 100%;
    border-collapse: collapse;
}

.cart-table th {
    padding: 15px;
    text-align: left;
    border-bottom: 2px solid var(--border);
    color: var(--text-muted);
}

.cart-table td {
    padding: 15px;
    border-bottom: 1px solid var(--border);
}

.cart-summary {
    margin-top: 30px;
    padding-top: 20px;
    max-width: 400px;
    margin-left: auto;
}

/* ==========================================================================
   8. AUTHENTIFICATION (LOGIN & REGISTER)
   ========================================================================== */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 60px 15px;
    min-height: 60vh;
}

.auth-card {
    max-width: 450px;
    width: 100%;
    padding: 40px;
}

.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-weight: 600; margin-bottom: 8px; font-size: 0.9rem; }
.form-group input {
    width: 100%; padding: 12px 15px; border: 1px solid var(--border);
    border-radius: var(--radius-sm); outline: none; transition: var(--transition);
}

.form-group input:focus { border-color: var(--secondary); box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.1); }

.error-msg, .success-msg {
    padding: 12px; border-radius: var(--radius-sm); margin-bottom: 20px; font-size: 0.9rem;
}
.error-msg { background: #fff5f5; color: #c53030; border-left: 4px solid #f56565; }
.success-msg { background: #f0fff4; color: #2f855a; border-left: 4px solid #48bb78; }

/* ==========================================================================
   9. FOOTER
   ========================================================================== */
.main-footer {
    background: #1a202c;
    color: #a0aec0;
    padding: 60px 0 20px;
    margin-top: 80px;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 40px;
}

.footer-logo { height: 100px; margin-bottom: 20px; filter: brightness(0) invert(1); }
.footer-links { list-style: none; padding: 0; line-height: 2; }
.footer-links a { color: inherit; text-decoration: none; transition: var(--transition); }
.footer-links a:hover { color: white; }

/* ==========================================================================
   10. MEDIA QUERIES (RESPONSIVE)
   ========================================================================== */

/* Tablettes */
@media (max-width: 992px) {
    .product-view-container { grid-template-columns: 1fr; }
    .sidebar-nav { width: 100%; position: static; order: -1; margin-bottom: 20px; }
    .product-grid { grid-template-columns: repeat(3, 1fr); }
}

/* Smartphones */
@media (max-width: 768px) {
    .header-grid { flex-wrap: wrap; }
    .header-search { order: 3; width: 100%; }
    .product-grid { grid-template-columns: repeat(2, 1fr); gap: 15px; }
    
    /* Sidebar Horizontale sur Mobile */
    .sidebar-nav .sidebar-header {
        display: none !important;
    }

    .sidebar-nav {
        width: 100%;
        position: static;
        margin-bottom: 25px;
        box-shadow: none;
        border: none;
        background: transparent;
    }

    .sidebar-nav .cat-menu {
        display: flex !important;
        flex-direction: row !important;
        justify-content: center !important;
        gap: 25px !important;
        padding: 10px 0 !important;
    }

    .sidebar-nav .cat-menu li { border: none; background: transparent !important; }

    .sidebar-nav .cat-menu li a {
        padding: 0 !important;
        border: none !important;
    }

    .sidebar-nav .cat-menu li a span {
        display: none !important;
    }

    .sidebar-nav .cat-menu li a i {
        font-size: 2rem !important;
    }

    /* Adaptation Table Panier */
    .cart-table thead { display: none; }
    .cart-table tr { display: block; border: 1px solid var(--border); margin-bottom: 10px; border-radius: var(--radius-sm); }
    .cart-table td { display: flex; justify-content: space-between; text-align: right; }
    .cart-table td::before { content: attr(data-label); font-weight: bold; }

    .auth-card { padding: 25px 20px; }
}

/* ==========================================================================
   11. ANIMATIONS & TOASTS
   ========================================================================== */
#toast-container { position: fixed; top: 20px; right: 20px; z-index: 9999; }
.toast {
    background: white; padding: 15px 25px; border-radius: 10px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15); margin-bottom: 10px;
    display: flex; align-items: center; gap: 12px;
    border-left: 5px solid var(--secondary);
    transform: translateX(120%); transition: transform 0.4s ease;
}
.toast.show { transform: translateX(0); }
.toast.error { border-left-color: #e53e3e; }

@keyframes shake-cart {
    0% { transform: scale(1) rotate(0); }
    15% { transform: scale(1.2) rotate(-15deg); }
    30% { transform: scale(1.2) rotate(15deg); }
    45% { transform: scale(1.2) rotate(-15deg); }
    60% { transform: scale(1.2) rotate(15deg); }
    100% { transform: scale(1) rotate(0); }
}

.shake {
    animation: shake-cart 0.6s ease-in-out;
    display: inline-block;
}

@keyframes fadeIn { from {opacity:0;} to {opacity:1;} }