/* Header App Styles */
body > header:first-child {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 70px; /* Hauteur fixe standardisée */
    padding: 0 15px;
    background-color: var(--main-color);
    color: var(--text-color);
    box-shadow: 0 2px 4px var(--shadow-color);
    margin: 0;
    opacity: 0.99;
    position: sticky;
    top: 0px;
    z-index: 10100; /* Au-dessus de tous les overlays */
    width: 100%; /* Utiliser 100% pour éviter le débordement horizontal */
    left: 0;
    box-sizing: border-box;
}

body > header:first-child img.logo {
    width: 65px;
    height: auto;
    object-fit: contain;
    cursor: default;
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 5px; /* Ajustement fin pour le centrage vertical dans le header */
    z-index: 10101; /* Au-dessus des tabs */
}

body > header:first-child button {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.9rem;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
}

body > header:first-child button.arrow-left {
    margin-right: auto;
}

body > header:first-child button.arrow-right {
    margin-left: auto;
}

/* Tabs Focus and Learn - Hidden by default */
body > header:first-child button.tab-focus,
body > header:first-child button.tab-learn {
    display: none;
    background: var(--main-color);
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 20px;
    padding: 0.5rem 1.2rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    width: auto;
    height: auto;
    min-width: auto;
    position: relative;
}

/* Connecteur qui relie le tab au logo */
body > header:first-child button.tab-focus::after,
body > header:first-child button.tab-learn::before {
    content: '';
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 25px;
    height: 2px;
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.1));
    transition: height 0.3s ease;
    pointer-events: none;
}

body > header:first-child button.tab-focus::after {
    left: calc(100% + 2px); /* Commence après la bordure de 2px */
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.1));
}

body > header:first-child button.tab-learn::before {
    right: calc(100% + 2px); /* Commence après la bordure de 2px */
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.3));
}

body > header:first-child button.tab-focus:hover,
body > header:first-child button.tab-learn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.5);
}

body > header:first-child button.tab-focus.active {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

body > header:first-child button.tab-learn.active {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.6);
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.3);
}

/* Position tabs around logo - symétriques et équilibrées */
body > header:first-child button.tab-focus {
    position: absolute;
    left: 50%;
    transform: translateX(calc(-100% - 59.5px)); /* -100% (largeur du tab) - 32.5px (moitié du logo) - 25px (connecteur) - 2px (bordure) */
}

body > header:first-child button.tab-learn {
    position: absolute;
    left: 50%;
    transform: translateX(calc(59.5px)); /* 32.5px (moitié du logo) + 25px (connecteur) + 2px (bordure) */
}

/* Language Selector in Header */
.language-selector {
    display: flex;
    align-items: center;
    flex: 0 0 auto;
}

.language-selector select {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: calc(100% - 8px) center;
    background-size: 0.8rem;
    padding-right: 28px;
    width: 80px;
    box-sizing: border-box;
    flex-shrink: 0; /* Empêche le select de rétrécir */
}

.language-selector select:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

.language-selector select:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

/* Show tabs only on index page */
body[data-page="index"] > header:first-child button.tab-focus,
body[data-page="index"] > header:first-child button.tab-learn {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    body > header:first-child {
        height: 60px; /* Hauteur réduite pour tablettes */
    }

    body > header:first-child img.logo {
        width: 50px;
        max-height: 50px;
    }

    body > header:first-child button {
        font-size: 1.6rem;
        width: 35px;
        height: 35px;
        min-width: 35px;
    }

    .language-selector {
        margin-right: 10px;
    }

    .language-selector select {
        padding: 0.3rem 0.5rem;
        font-size: 0.8rem;
    }

    /* Ajustement des tabs pour tablettes */
    body > header:first-child button.tab-focus {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
        border-radius: 15px;
        transform: translateX(calc(-100% - 47px)); /* -100% - 25px (moitié logo) - 20px (connecteur) - 2px (bordure) */
    }

    body > header:first-child button.tab-learn {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
        border-radius: 15px;
        transform: translateX(47px); /* 25px (moitié logo) + 20px (connecteur) + 2px (bordure) */
    }

    body > header:first-child button.tab-focus::after,
    body > header:first-child button.tab-learn::before {
        width: 20px;
    }
}

@media (max-width: 480px) {
    body > header:first-child {
        height: 50px; /* Hauteur réduite pour mobiles */
        padding: 0 10px;
    }

    body > header:first-child img.logo {
        width: 40px;
        max-height: 40px;
    }

    body > header:first-child button {
        font-size: 1.4rem;
        width: 30px;
        height: 30px;
        min-width: 30px;
    }

    /* Ajustement des tabs pour mobiles - symétriques */
    body > header:first-child button.tab-focus {
        padding: 0.3rem 0.6rem;
        font-size: 0.7rem;
        border-radius: 12px;
        transform: translateX(calc(-100% - 37px)); /* -100% - 20px (moitié logo) - 15px (connecteur) - 2px (bordure) */
    }

    body > header:first-child button.tab-learn {
        padding: 0.3rem 0.6rem;
        font-size: 0.7rem;
        border-radius: 12px;
        transform: translateX(37px); /* 20px (moitié logo) + 15px (connecteur) + 2px (bordure) */
    }

    body > header:first-child button.tab-focus::after,
    body > header:first-child button.tab-learn::before {
        width: 15px;
    }
}
