/* --- Variables & Configuration de Base --- */
:root {
    --primary: #2c3e50;
    --secondary: #27ae60;
    --bg-light: #f8fafc;
    --border: #edf2f7;
    --text-muted: #718096;
    --text-dark: #2d3748;
    --shadow: 0 10px 30px rgba(0,0,0,0.08);
}

* {
    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;
}

.container { 
    max-width: 1200px; 
    margin: 0 auto; 
    padding: 0 20px; 
}

/* --- Composants Globaux --- */
.card-modern {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    transition: transform 0.3s ease;
}

/* Correction importante : la sidebar ne doit pas cacher ce qui dépasse */
aside.sidebar-nav.card-modern {
    overflow: visible !important;
}

.btn-modern {
    border: none;
    border-radius: 8px;
    padding: 12px 20px;
    font-weight: 600;
    cursor: pointer;
    transition: 0.3s;
    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%; }

/* --- Header & Navigation --- */
.main-header {
    background: #ffffff;
    padding: 5px 0;
    box-shadow: 0 2px 15px rgba(0,0,0,0.05);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-grid {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 30px;
}

.header-logo {
    display: flex;
    align-items: center;
    min-width: 180px;
}

.logo-img {
    height: 80px;
    width: auto;
    object-fit: contain;
    display: block;
    transition: transform 0.3s ease;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.05));
}

.logo-img:hover { transform: scale(1.05); }

.header-search { flex: 1; max-width: 500px; }
.search-form {
    display: flex;
    background: #f8fafc;
    border-radius: 50px;
    padding: 5px 15px;
    border: 1px solid var(--border);
    height: 45px;
    transition: all 0.3s ease;
}

.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; padding: 8px; 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; }
.action-btn {
    text-decoration: none;
    color: var(--primary);
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

.cart-icon-container {
    position: relative;
    font-size: 1.5rem;
    color: var(--primary);
    display: flex;
    align-items: center;
}

.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;
}

/* --- Hero Section --- */
/* --- Hero Slider Styles --- */
.hero {
    position: relative;
    height: 330px; /* Ajustez la hauteur selon vos besoins */
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    text-align: center;
    margin-bottom: 50px;
    background: #2c3e50; /* Couleur de secours */
}

.hero-slider {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
}

.slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-size:contain;
    background-position: center;
    opacity: 0;
    transition: opacity 1.5s ease-in-out; /* Transition douce de 1.5s */
}

.slide.active {
    opacity: 1;
}

.hero-content {
    position: relative;
    z-index: 2; /* Pour rester au-dessus des images */
}

.hero h1 {
    font-size: 2.5rem;
    margin-bottom: 15px;
    text-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.hero p {
    font-size: 1.2rem;
    margin-bottom: 30px;
    text-shadow: 0 1px 5px rgba(0,0,0,0.5);
}

/* --- Sidebar Nav Premium --- */
.sidebar-nav {
    width: 280px;
    background: white;
    position: sticky;
    top: 100px;
    z-index: 10;
}

.sidebar-header {
    background: linear-gradient(135deg, var(--primary) 0%, #34495e 100%);
    color: white;
    padding: 20px;
    font-weight: bold;
    border-radius: 12px 12px 0 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.cat-menu { list-style: none; padding: 0; margin: 0; }
.cat-menu li { position: relative; border-bottom: 1px solid #f1f4f6; transition: all 0.3s ease; }

.cat-menu li a {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    text-decoration: none;
    color: #4a5568;
    font-weight: 500;
}

.cat-menu li:hover { background: linear-gradient(to right, #ffffff, #f7fafc); padding-left: 5px; }
.cat-menu li:hover > a { color: var(--secondary); }

.arrow { font-size: 0.8rem; opacity: 0.3; transition: transform 0.3s; }
.cat-menu li:hover .arrow { transform: translateX(5px); opacity: 1; color: var(--secondary); }

/* --- Le Sous-Menu (Mouse Over) --- */
.submenu {
    display: none;
    opacity: 0;
    transform: translateX(15px);
    position: absolute;
    top: -1px;
    left: 100%;
    width: 260px;
    background: white;
    border-radius: 0 12px 12px 12px;
    box-shadow: 15px 10px 40px rgba(0,0,0,0.12);
    border-left: 3px solid var(--secondary);
    padding: 20px;
    z-index: 1000;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.has-subs:hover .submenu {
    display: block;
    opacity: 1; /* Remis à 1 pour être visible */
    transform: translateX(0);
    animation: slideInRight 0.3s cubic-bezier(0.165, 0.84, 0.44, 1);
}

.submenu-header { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 15px; font-weight: 700; }
.submenu-grid a { display: block; padding: 10px 0; color: var(--text-dark); text-decoration: none; border-bottom: 1px solid #f7fafc; }
.submenu-grid a:hover { color: var(--secondary); padding-left: 8px; }

/* --- Grille de Produits --- */
.product-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 25px;
}

.product-image img { width: 100%; height: 200px; object-fit: cover; }
.product-info { padding: 20px; }
.cat-tag { font-size: 0.75rem; color: var(--text-muted); text-transform: uppercase; }
.price { font-size: 1.25rem; font-weight: 700; color: var(--secondary); margin: 10px 0; }

/* --- Authentification & Formulaires --- */
.auth-container { display: flex; justify-content: center; align-items: center; min-height: 80vh; padding: 20px; }
.auth-card { width: 100%; max-width: 400px; padding: 40px; }
.form-group { margin-bottom: 20px; }
.form-group label { display: block; margin-bottom: 8px; font-size: 0.9rem; color: var(--text-muted); }
.form-group input, .form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    outline: none;
    transition: 0.3s;
}
.form-group input:focus, .form-group textarea:focus { border-color: var(--secondary); box-shadow: 0 0 0 3px rgba(39, 174, 96, 0.1); }

.error-msg { background: #fff5f5; color: #c53030; padding: 10px; border-radius: 8px; margin-bottom: 20px; text-align: center; }
.success-msg { background: #f0fff4; color: #2f855a; padding: 10px; border-radius: 8px; margin-bottom: 20px; text-align: center; }

/* --- Détails Produit --- */
.product-view-container { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; }
.qty-controls { display: flex; align-items: center; gap: 10px; margin: 15px 0; }
.qty-controls button { width: 35px; height: 35px; border: 1px solid var(--border); background: white; border-radius: 8px; cursor: pointer; }
.qty-controls input { width: 50px; text-align: center; border: 1px solid var(--border); padding: 5px; }

/* --- Animations & RTL --- */
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(15px); }
    to { opacity: 1; transform: translateX(0); }
}

[dir="rtl"] .header-actions { flex-direction: row-reverse; }
[dir="rtl"] .action-btn i { margin-left: 8px; margin-right: 0; }
[dir="rtl"] .submenu { left: auto; right: 100%; border-left: none; border-right: 3px solid var(--secondary); }

/* --- Responsive --- */
@media (max-width: 768px) {
    .header-search { display: none; }
    .header-grid { gap: 15px; }
    .action-btn span { display: none; }
    .logo-img { height: 50px; }
    .sidebar-nav { width: 100%; position: static; margin-bottom: 30px; }
    .product-view-container { grid-template-columns: 1fr; }
    
    /* Sur mobile, on affiche le sous-menu en dessous au clic si nécessaire */
    .has-subs:hover .submenu { position: static; width: 100%; border: none; box-shadow: none; }
}

/* Système de Notifications Toast */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    background: white;
    color: var(--text-dark);
    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 cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

.toast.show { transform: translateX(0); }
.toast.error { border-left-color: #e53e3e; }
.toast i { font-size: 1.2rem; }
.toast.success i { color: var(--secondary); }
.toast.error i { color: #e53e3e; }