/* ========================================
   NAVBAR
   ======================================== */

/* Variables CSS pour cohérence */
:root {
    --nav-bg: rgba(255, 255, 255, 1);
    --nav-shadow: 0 2px 20px rgba(0, 0, 0, 0.08);
    --nav-border: rgba(255, 255, 255, 0.2);
    --primary-green: #059669;
    --primary-green-light: #10b981;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --nav-height: 90px;
    --nav-height-mobile: 60px;
}

/* Base navbar styling */
.navbarResponsive {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    background: var(--nav-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--nav-border);
    box-shadow: var(--nav-shadow);
    height: var(--nav-height);
    transition: var(--transition);
}

/* Extend navbar background when commercial control is active */
.navbarResponsive.has-extended-control::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    height: 60px;
    background: var(--nav-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.06);
    z-index: -1;
}

/* Mobile extension */
@media (max-width: 768px) {
    .navbarResponsive.has-extended-control::after {
        height: 50px;
    }
}

.navbarResponsive .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 100%;
    padding: 0 1rem;
    max-width: 1600px;
}

/* Logo section */
.navbarLogo {
    flex-shrink: 0;
    z-index: 1001;
}

.navbarLogo a {
    display: block;
    transition: var(--transition);
}

.navbarLogo a:hover {
    transform: scale(1.02);
}

.navbarLogo img {
    height: 45px;
    width: auto;
    transition: var(--transition);
    margin-bottom: 13px;
}

/* Navigation menu */
#navbar {
    display: flex;
    align-items: center;
    flex: 1;
    justify-content: center;
}

#navbar ul {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 2rem;
    align-items: center;
}

#navbar li {
    position: relative;
}

.navlinkUnderline {
    text-decoration: none;
    color: var(--text-secondary);
    font-weight: 500;
    letter-spacing: 0.3px;
    transition: var(--transition);
    position: relative;
    padding: 0.5rem 0;
}

.navlinkUnderline:hover {
    color: var(--text-primary);
    transform: translateY(-1px);
}

.navlinkUnderline::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    width: 0;
    height: 2px;
    background: linear-gradient(135deg, var(--primary-green), var(--primary-green-light));
    transition: var(--transition);
    transform: translateX(-50%);
}

.navlinkUnderline:hover::after {
    width: 100%;
}

.backgroundTextNav {
    background: none;
    color: var(--text-secondary) !important;
    padding: 0.5rem 0;
    border-radius: 0;
    font-size: 0.875rem;
    font-weight: 500;
    letter-spacing: 0.3px;
    transition: var(--transition);
    border: none;
    cursor: pointer;
    position: relative;
}

.backgroundTextNav:hover {
    color: var(--primary-green) !important;
    transform: translateY(-1px);
    box-shadow: none;
}

/* User section */
.navPartieUserAndCart {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

/* Commercial control */
.commercialControl {
    display: flex;
    align-items: center;
    position: relative;
}

/* Commercial control - when active, position below navbar and progress bar */
.commercialControl.has-active-control {
    position: fixed;
    top: calc(var(--nav-height) + 40px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 997;
    background: white;
    width: 100%;
    padding: 1rem 1.5rem;
    justify-content: center;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* Adjust for tablet */
@media (max-width: 1400px) and (min-width: 769px) {
    .commercialControl.has-active-control {
        top: calc(var(--nav-height) + 100px);
        left: 0;
        transform: none;
        width: 100%;
        padding: 1rem 1.5rem;
        justify-content: center;
        z-index: 997;
    }
}

/* Adjust for mobile */
@media (max-width: 768px) {
    .commercialControl.has-active-control {
        top: calc(var(--nav-height-mobile) + 82px);
        left: 0;
        transform: none;
        width: 100%;
        padding: 1rem 1.5rem;
        justify-content: center;
        z-index: 997;
    }
}

.commercial-status,
.commercial-control {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(34, 197, 94, 0.1);
    color: #059669;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.commercial-control {
    background: rgba(5, 150, 105, 0.1);
    color: var(--primary-green);
    border-color: rgba(5, 150, 105, 0.2);
}

.commercial-status:hover,
.commercial-control:hover {
    background: rgba(34, 197, 94, 0.15);
    border-color: rgba(34, 197, 94, 0.3);
    text-decoration: none;
}

.commercial-control:hover {
    background: rgba(5, 150, 105, 0.15);
    border-color: rgba(5, 150, 105, 0.3);
}

/* User dropdown */
.userCart .dropdown-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: rgba(248, 250, 252, 0.8);
    color: var(--text-primary);
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    border: 1px solid rgba(226, 232, 240, 0.5);
}

.userCart .dropdown-toggle:hover {
    background: rgba(248, 250, 252, 1);
    border-color: rgba(226, 232, 240, 0.8);
    text-decoration: none;
    color: var(--text-primary);
}

.userCart .dropdown-toggle::after {
    margin-left: 0.5rem;
}

.user-logo {
    font-size: 1rem;
    color: var(--primary-green);
}

/* Cart */
#myCart a {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, var(--primary-green), var(--primary-green-light));
    color: white;
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: var(--transition);
    position: relative;
}

#myCart a:hover {
    background: linear-gradient(135deg, var(--primary-green-light), var(--primary-green));
    text-decoration: none;
    color: white;
}

.cart-logo {
    font-size: 1rem;
}

#myCartQuantity {
    background: rgba(255, 255, 255, 0.2);
    padding: 0.125rem 0.5rem;
    border-radius: 10px;
    font-weight: 600;
    min-width: 1.5rem;
    text-align: center;
}

/* Dropdown menu styling */
.dropdown-menu {
    background: var(--nav-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--nav-border);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    border-radius: 12px;
    padding: 0.5rem 0;
    margin-top: 0.5rem;
    min-width: 200px;
}

.dropdown-item {
    padding: 0.75rem 1.25rem;
    color: var(--text-secondary);
    font-weight: 500;
    transition: var(--transition);
    border: none;
    background: none;
}

.dropdown-item:hover {
    background: rgba(5, 150, 105, 0.1);
    color: var(--primary-green);
    transform: translateX(4px);
}

/* Mobile menu toggle */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    z-index: 1001;
}

.mobile-menu-toggle span {
    width: 24px;
    height: 2px;
    background: var(--text-primary);
    border-radius: 2px;
    transition: var(--transition);
    transform-origin: center;
}

.mobile-menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.mobile-menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.mobile-menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

/* Body padding to account for fixed navbar */
body {
    padding-top: var(--nav-height);
}

/* ========================================
   RESPONSIVE BREAKPOINTS
   ======================================== */

/* Desktop > 1400px - Reset to horizontal layout */
@media (min-width: 1401px) {
    .navbar-bottom-row {
        display: contents;
    }
    
    .navbarResponsive .container {
        flex-direction: row;
        gap: 0;
    }
    
    .navbarLogo {
        order: 0;
        align-self: auto;
        margin-bottom: 0;
    }
    
    .navbarLogo img {
        height: 45px;
    }
    
    #navbar {
        order: 0;
        flex: 1;
        justify-content: center;
    }
    
    .navPartieUserAndCart {
        order: 0;
        gap: 1rem;
    }
}

/* Large tablet/Small desktop (769px - 1400px) */
@media (max-width: 1400px) and (min-width: 769px) {
    .navbarResponsive {
        height: calc(var(--nav-height) + 35px);
    }
    
    .navbarResponsive .container {
        flex-direction: column;
        padding: 0.25rem 1rem 0.5rem 1rem;
        gap: 0.25rem;
    }
    
    /* Logo centered at top */
    .navbarLogo {
        order: 1;
        align-self: center;
        margin-bottom: 0;
    }
    
    .navbarLogo img {
        height: 35px;
    }
    
    /* Second row: menu and user actions on same line */
    .navbar-bottom-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        order: 2;
    }
    
    #navbar {
        flex: 1;
        justify-content: center;
    }
    
    .navPartieUserAndCart {
        gap: 0.75rem;
        flex-shrink: 0;
    }
    
    body {
        padding-top: calc(var(--nav-height) + 35px);
    }
}

/* Tablette (768px - 1024px) */
@media (max-width: 1024px) {
    #navbar ul {
        gap: 1.5rem;
    }
    
    .backgroundTextNav {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    
    .navPartieUserAndCart {
        gap: 0.75rem;
    }
    
    .commercial-status,
    .commercial-control,
    .userCart .dropdown-toggle,
    #myCart a {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
}

/* Mobile/Tablet (< 768px) */
@media (max-width: 768px) {
    :root {
        --nav-height: calc(var(--nav-height-mobile) + 30px);
    }
    
    .navbarResponsive {
        height: calc(var(--nav-height-mobile) + 30px);
    }
    
    .navbarResponsive .container {
        flex-direction: column;
        padding: 0.25rem 1rem 0.5rem 1rem;
        gap: 0.25rem;
    }
    
    /* Logo centered at top */
    .navbarLogo {
        order: 1;
        align-self: center;
        margin-bottom: 0;
    }
    
    .navbarLogo img {
        height: 30px;
    }
    
    /* Second row: hamburger left, user/cart right */
    .navbar-bottom-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        width: 100%;
        order: 2;
    }
    
    /* Show mobile menu toggle on left */
    .mobile-menu-toggle {
        display: flex;
        order: 1;
    }
    
    /* Hide desktop navigation initially */
    #navbar {
        position: fixed;
        top: calc(var(--nav-height-mobile) + 30px);
        left: 0;
        right: 0;
        bottom: 0;
        width: 100vw;
        height: calc(100vh - var(--nav-height-mobile) - 30px);
        background: var(--nav-bg);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        transform: translateY(-100%);
        opacity: 0;
        visibility: hidden;
        transition: var(--transition);
        justify-content: flex-start;
        padding: 1rem;
        z-index: 998;
        order: 0; /* Reset order for mobile menu */
    }
    
    #navbar.active {
        transform: translateY(0);
        opacity: 1;
        visibility: visible;
    }
    
    #navbar ul {
        flex-direction: column;
        width: 100%;
        gap: 0;
        align-items: stretch;
        justify-content: flex-start;
        height: 100%;
        padding: 1rem 0;
    }
    
    #navbar li {
        width: 100%;
        border-bottom: 1px solid rgba(226, 232, 240, 0.3);
    }
    
    #navbar li:last-child {
        border-bottom: none;
    }
    
    .navlinkUnderline {
        display: block;
        padding: 1.5rem;
        width: 100%;
        text-align: center;
        font-size: 1.1rem;
        font-weight: 500;
    }
    
    .navlinkUnderline::after {
        display: none;
    }
    
    .backgroundTextNav {
        display: inline-block;
        margin: 0.5rem 1rem;
        padding: 0.75rem 0;
        border-radius: 0;
    }
    
    /* User section on right side of second row */
    .navPartieUserAndCart {
        order: 3;
        gap: 0.5rem;
        flex-shrink: 0;
    }
    
    .commercialControl {
        display: flex; /* Show on mobile */
        order: 2;
    }
    
    .userCart .dropdown-toggle {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    
    .userCart .dropdown-toggle span {
        display: none; /* Hide email text on mobile */
    }
    
    #myCart a {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
    
    #myCart a span:not(#myCartQuantity) {
        display: none; /* Hide "Panier" text, keep only icon and count */
    }
    
    /* Adjust body padding for new height */
    body {
        padding-top: calc(var(--nav-height-mobile) + 30px);
    }
}

/* Very small mobile (< 480px) */
@media (max-width: 480px) {
    .navbarResponsive .container {
        padding: 0 0.75rem;
    }
    
    .navbarLogo img {
        height: 30px;
    }
    
    .navPartieUserAndCart {
        gap: 0.25rem;
    }
    
    .userCart .dropdown-toggle,
    #myCart a {
        padding: 0.3rem 0.6rem;
        font-size: 0.75rem;
    }
    
    #myCartQuantity {
        padding: 0.1rem 0.4rem;
        font-size: 0.75rem;
    }
}

/* ========================================
   ANIMATIONS ET MICRO-INTERACTIONS
   ======================================== */

/* Smooth entrance animation */
.navbarResponsive {
    animation: slideDown 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Hover animations for interactive elements */
.navAnimate {
    transition: var(--transition);
}

.navAnimate:hover {
    transform: translateY(-1px);
}

/* Focus states for accessibility */
.navlinkUnderline:focus,
.backgroundTextNav:focus,
.commercial-status:focus,
.commercial-control:focus,
.userCart .dropdown-toggle:focus,
#myCart a:focus,
.mobile-menu-toggle:focus {
    outline: 2px solid var(--primary-green);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Loading state for cart */
#myCart.loading a {
    opacity: 0.7;
    pointer-events: none;
}

#myCart.loading .cart-logo {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}