/* ==========================
   menu.css
   Responsive main menu, sub-menu, header
   ========================== */

/* ===== HEADER ===== */
header { 
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 1rem;
    position: relative;
    flex-wrap: wrap;
}

/* ===== BRAND ===== */
.header-brand {
    display: flex;
    align-items: center;
    order: 1;
}
.header-brand img {
    height: 32px;
    margin-right: 0.5rem;
}
.header-brand span {
    color: var(--color-cta);
    font-size: 1.25rem;
    font-weight: bold;
}

/* ===== USER ===== */
.header-user {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
    padding-right: 15px; 
    order: 3;
}

.header-user .user-name {
    color: var(--color-cta); 
    border: 1px solid var(--color-cta);
    padding: 5px 15px;
    border-radius: 4px;
    font-size: 0.75rem;
    text-transform: uppercase;
    transition: all 0.3s ease;
    text-decoration: none;
}

.header-user .user-name:hover {
    background: var(--color-cta);
    color: #000;
    box-shadow: 0 0 10px rgba(0, 255, 0, 0.3);
}

.user-name-display {
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis; 
}

/* ===== TICKER ===== */
.header-ticker {
    position: relative;
    overflow: hidden;
    flex: 1 1 auto;
    min-width: 200px;
    order: 2;
    margin-right: 1rem;
    font-size: 0.75rem;
}
.ticker-item {
    display: none;
    position: relative;
    left: 1rem;
    height: 1.5rem;
    line-height: 1.5rem;
    text-align: left;
    color: #ddd;
    white-space: normal;
    padding-right: 0.5rem;
}
.ticker-item.active {
    display: block;
}
.header-ticker .admin-message {
    display: block !important;
    color: var(--color-submenu);
    font-weight: bold;
}

/* ===== MENU ===== */
.menu {
    display: flex;
    align-items: center;
    justify-content: flex-start;
}
.menu a {
    padding: 0.4rem 0.8rem;
    font-size: 0.85rem;
    border-radius: 6px;
    white-space: nowrap;
    color: #fff;
    background: var(--color-btn-main);
    text-decoration: none;
    font-weight: bold;
    margin-right: 0.5rem;
}
.menu a:hover,
.menu a.active {
    background: var(--color-btn-hover);
}
.menu .mobile-login {
    display: none;
}
.menu .mobile-logout {
    display: none;
}

/* ===== SUBMENU ===== */
.submenu {
    display: flex;
    justify-content: flex-start;
    padding: 0.5rem 1rem;
    flex-wrap: wrap;
}
.submenu a {
    padding: 0.3rem 0.7rem;
    font-size: 0.75rem; 
    text-transform: uppercase;
    letter-spacing: 0.03rem;
    color: #fff;
    background: var(--color-submenu);
    margin-right: 0.5rem;
    font-weight: bold;
    text-decoration: none;
}
.submenu a:hover,
.submenu a.active {
    background: var(--color-submenu-hover);
}

/* ===== HAMBURGER ===== */
.menu-toggle {
    display: none; 
    flex-direction: column;
    cursor: pointer;
    order: 4;
    margin-right: 15px;      
    padding: 10px;           
    transition: transform 0.2s ease;
}

.menu-toggle:active {
    transform: scale(0.9);    
}

.menu-toggle span {
    width: 25px;
    height: 3px;
    background: var(--color-cta);
    margin: 2px 0;           
    border-radius: 2px;
}

/* ===== SITE LINKS ===== */
.site-name {
    text-decoration: none;
    cursor: pointer;
}
.user-name {
    text-decoration: none;
    cursor: pointer;
    color:#fff
}

/* ===== MOBILE / RESPONSIVE ===== */
@media (max-width: 768px) {

    /* Header en colonne */
    header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        padding: 0.5rem 1rem;
    }
    .header-brand { order: 0; }
    .header-ticker { order: 1; width: 100%; display: flex; }
    .header-user { display: none; } /* header user caché en mobile */
    .menu-toggle { 
        order: 2; 
        display: flex;
        align-self: flex-end;
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
        z-index: 1000;
    }

    /* Ticker full width */
    .header-ticker > div { width: 100%; }
    .ticker-item { flex: 1 1 auto; width: 100%; white-space: normal; }

    /* Menu caché par défaut */
    .menu {
        display: none;
        flex-direction: column;
        align-items: flex-start;
        width: 100%;
        padding: 0.5rem 1rem;
        margin: 0;
    }
    .submenu {
        display: flex; 
        flex-direction: row;
        overflow-x: auto;
        width: 100%;
        padding: 0.5rem 1rem;
    }
    .menu.active,
    .submenu.active { display: flex; }

    .menu a,
    .submenu a { margin: 0.5rem 0; }

    /* MOBILE LOGIN/LOGOUT */
    .menu .mobile-login,
    .menu .mobile-logout {
        display: block;
        padding: 0.5rem 1rem;
        font-weight: bold;
        text-transform: uppercase;
    }
    .menu .mobile-login:hover,
    .menu .mobile-logout:hover { background: rgba(255,255,255,0.1); }

    /* Menu logout spacing */
    .menu.active .menu-logout {
        margin-top: 1rem;
        width: calc(100% - 2rem);
        text-align: center;
    }

    /* Submenu horizontal scroll (<600px) */
    nav.submenu {
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        position: static;
        background: #1E1E1E;
        padding: 1px 4px;
        gap: 4px;
        font-size: 0.8rem;
        min-width: auto;
    }
    nav.submenu a { flex: 0 0 auto; white-space: nowrap; }

    .submenu {
        scrollbar-width: none; /* Firefox */
        -ms-overflow-style: none;  /* IE/Edge */
    }
    .submenu::-webkit-scrollbar {
        display: none; /* Chrome/Safari */
    }    

    /* Header ticker admin */
    .header-ticker.has-admin {
        max-width: none;
        min-width: 0;
        width: 100%;
        margin: 0;
        padding: 0;
        height: auto;
        min-height: 0;
        overflow: visible;
        display: flex;
        flex-direction: column;
        font-size: 1rem;
    }
    .header-ticker.has-admin .ticker-item,
    .header-ticker.has-admin .admin-message {
        left: 0;
        padding: 0.5rem 1rem;
        height: auto;
        line-height: normal;
        display: block;
        width: 100%;
        box-sizing: border-box;
        font-weight: bold;
    }
}