/* ==========================================
   CANONITY - HEADER STYLES
   Dropdown, Language Switcher, User Menu
   ========================================== */

/* === HEADER BASE === */
.site-header {
    position: sticky;
    top: 0;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border, rgba(0,0,0,0.08));
    transition: box-shadow 0.3s ease;
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    gap: 1rem;
}

/* === LOGO === */
.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    flex-shrink: 0;
}

.logo-icon img {
    height: 32px;
    width: auto;
}

.logo-text {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary, #4285f4);
}

/* === NAV MENU === */
.nav-menu {
    display: flex;
    list-style: none;
    align-items: center;
    gap: 0.25rem;
    margin: 0;
    padding: 0;
}

.nav-menu > li {
    position: relative;
}

.nav-menu > li > a:not(.btn) {
    display: block;
    padding: 0.5rem 0.875rem;
    color: var(--text-sec, #505565);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.9rem;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
}

.nav-menu > li > a:not(.btn):hover {
    color: var(--text-main, #0a0b10);
    background: rgba(0, 0, 0, 0.04);
}

/* === LANGUAGE SWITCHER === */
.lang-menu {
    position: relative;
}

.lang-switcher {
    position: relative;
}

.lang-button {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #f0f4ff;
    border: 1px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--primary, #4285f4);
    transition: all 0.2s;
}

.lang-button:hover {
    background: #e3ebff;
    border-color: var(--primary, #4285f4);
}

.lang-icon {
    font-size: 1rem;
}

.lang-code {
    font-weight: 700;
}

.lang-arrow {
    font-size: 0.6rem;
    opacity: 0.7;
    transition: transform 0.2s;
}

/* Dropdown aperto */
.lang-switcher.open .lang-arrow {
    transform: rotate(180deg);
}

/* === LANGUAGE DROPDOWN === */
.lang-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 160px;
    background: white;
    border: 1px solid var(--border, rgba(0,0,0,0.08));
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.lang-switcher.open .lang-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-dropdown a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    color: var(--text-sec, #505565);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.15s;
}

.lang-dropdown a:hover {
    background: #f8f9fc;
    color: var(--text-main, #0a0b10);
}

.lang-dropdown a.active {
    background: #f0f4ff;
    color: var(--primary, #4285f4);
    font-weight: 600;
}

.lang-flag {
    text-transform: uppercase;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-sec);
    background: #f1f3f4;
    padding: 2px 6px;
    border-radius: 4px;
}

/* === CART LINK === */
.cart-link {
    position: relative;
}

.nav-cart {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    color: var(--text-sec, #505565);
    transition: all 0.2s;
}

.nav-cart:hover {
    background: rgba(0, 0, 0, 0.04);
    color: var(--text-main, #0a0b10);
}

.cart-counter {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 18px;
    height: 18px;
    background: #ea4335;
    color: white;
    font-size: 0.7rem;
    font-weight: 700;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

/* === USER MENU === */
.user-menu {
    position: relative;
}

.user-button {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px 6px 6px;
    background: #f0f4ff;
    border: 1px solid transparent;
    border-radius: 50px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--primary, #4285f4);
    transition: all 0.2s;
}

.user-button:hover {
    background: #e3ebff;
    border-color: var(--primary, #4285f4);
}

.user-button img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.user-initial {
    width: 28px;
    height: 28px;
    background: var(--primary, #4285f4);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
}

/* === USER DROPDOWN === */
.user-menu .dropdown-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    min-width: 200px;
    background: white;
    border: 1px solid var(--border, rgba(0,0,0,0.08));
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
    padding: 6px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
}

.user-menu.open .dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.user-menu .dropdown-menu a {
    display: block;
    padding: 10px 14px;
    color: var(--text-sec, #505565);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.15s;
}

.user-menu .dropdown-menu a:hover {
    background: #f8f9fc;
    color: var(--text-main, #0a0b10);
}

.dropdown-divider {
    height: 1px;
    background: var(--border, rgba(0,0,0,0.08));
    margin: 6px 0;
}

/* Logout con colore diverso */
.user-menu .dropdown-menu a[href*="logout"] {
    color: #ea4335;
}

.user-menu .dropdown-menu a[href*="logout"]:hover {
    background: #fef2f2;
    color: #dc2626;
}

/* === LOGIN BUTTON (utente non autenticato) === */
.nav-menu .btn-outline {
    padding: 8px 20px;
    border: 2px solid var(--primary, #4285f4);
    color: var(--primary, #4285f4);
    font-weight: 600;
    border-radius: 8px;
    background: transparent;
    transition: all 0.2s;
}

.nav-menu .btn-outline:hover {
    background: var(--primary, #4285f4);
    color: white;
}

/* === MOBILE MENU TOGGLE === */
.mobile-menu-toggle {
    display: none;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 40px;
    height: 40px;
    padding: 8px;
    background: none;
    border: none;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
}

.mobile-menu-toggle:hover {
    background: rgba(0, 0, 0, 0.04);
}

.mobile-menu-toggle span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text-main, #0a0b10);
    border-radius: 2px;
    transition: all 0.3s;
}

.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(5px, -5px);
}

/* === RESPONSIVE === */
@media (max-width: 968px) {
    .mobile-menu-toggle {
        display: flex;
    }

    .nav-menu {
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 0;
        background: white;
        padding: 1rem;
        border-top: 1px solid var(--border);
        transform: translateX(-100%);
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
        overflow-y: auto;
    }

    .nav-menu.active {
        transform: translateX(0);
        opacity: 1;
        visibility: visible;
    }

    .nav-menu > li {
        width: 100%;
    }

    .nav-menu > li > a:not(.btn) {
        padding: 1rem;
        font-size: 1rem;
    }

    /* Language switcher mobile */
    .lang-switcher {
        width: 100%;
    }

    .lang-button {
        width: 100%;
        justify-content: space-between;
        padding: 1rem;
        border-radius: 12px;
    }

    .lang-dropdown {
        position: static;
        box-shadow: none;
        border: 1px solid var(--border);
        margin-top: 8px;
        opacity: 1;
        visibility: visible;
        transform: none;
        display: none;
    }

    .lang-switcher.open .lang-dropdown {
        display: block;
    }

    /* User menu mobile */
    .user-menu {
        width: 100%;
    }

    .user-button {
        width: 100%;
        justify-content: flex-start;
        padding: 0.75rem 1rem;
        border-radius: 12px;
    }

    .user-menu .dropdown-menu {
        position: static;
        box-shadow: none;
        border: 1px solid var(--border);
        margin-top: 8px;
        opacity: 1;
        visibility: visible;
        transform: none;
        display: none;
    }

    .user-menu.open .dropdown-menu {
        display: block;
    }

    /* Cart mobile */
    .cart-link {
        width: 100%;
    }

    .nav-cart {
        width: 100%;
        height: auto;
        justify-content: flex-start;
        padding: 1rem;
        border-radius: 12px;
        gap: 10px;
    }

    .nav-cart::after {
        content: 'Carrello';
        font-weight: 500;
    }
}