@import "./constants.css";

/* ----------------------------------------------------------*/
/* APP HEADER                                                */
/* ----------------------------------------------------------*/
.app-header {
    height: var(--header-height);
    width: 100%;
    background-color: var(--header-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 var(--spacing-md);
    box-shadow: var(--box-shadow);
    z-index: 1100;
    position: fixed;
    top: 0;
    left: 0;
}

/* ----------------------------------------------------------*/
/* BRANDING (logo + title)                                   */
/* ----------------------------------------------------------*/
.app-header a#header-home-link {
    text-decoration: none;
    display: flex;
    align-items: center;
}

.app-header a#header-home-link:hover {
    text-decoration: none;
    opacity: 0.85;
}

.header-branding {
    display: flex;
    align-items: center;
    gap: 10px;
}

.header-logo {
    max-height: 70px;
    width: auto;
    object-fit: contain;
}

.header-title {
    font-family: var(--heading-font);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--font-color);
    letter-spacing: var(--letter-spacing-medium);
    white-space: nowrap;
}

/* ----------------------------------------------------------*/
/* LEFT GROUP (branding + optional project name)             */
/* ----------------------------------------------------------*/
.header-left {
    display: flex;
    align-items: center;
    gap: 0;
    min-width: 0;
}

/* ----------------------------------------------------------*/
/* PROJECT NAME (inline after app title, project pages only) */
/* ----------------------------------------------------------*/
.header-project-name {
    display: flex;
    align-items: center;
    min-width: 0;
}

.header-project-name:not(:empty)::before {
    content: "/";
    font-family: var(--heading-font);
    font-size: 1.25rem;
    font-weight: 300;
    color: var(--font-color);
    opacity: 0.35;
    margin: 0 8px;
}

.header-project-name-icon {
    font-size: 0.85rem;
    opacity: 0.6;
}

.header-project-name-text {
    font-family: var(--heading-font);
    font-size: 1.1rem;
    font-weight: 400;
    color: var(--font-color);
    opacity: 0.65;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

@media (max-width: 768px) {
    .header-project-name { display: none; }
}

/* ----------------------------------------------------------*/
/* RIGHT CONTROLS (badge + language + profile)               */
/* ----------------------------------------------------------*/
.header-right-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ----------------------------------------------------------*/
/* SELECTION BADGE                                           */
/* ----------------------------------------------------------*/
.header-selection-badge {
    display: flex;
    align-items: center;
}

.header-selection-badge--content {
    display: inline-flex;
    align-items: center;
    padding: 5px 14px;
    border-radius: 20px;
    background: rgba(0, 130, 142, 0.1);
    border: 1px solid rgba(0, 130, 142, 0.35);
    color: var(--main-color-dark);
    font-size: 0.82rem;
    white-space: nowrap;
    animation: fadeIn-badge 0.2s ease;
}

@keyframes fadeIn-badge {
    from { opacity: 0; transform: scale(0.95); }
    to   { opacity: 1; transform: scale(1); }
}

/* ----------------------------------------------------------*/
/* LANGUAGE SELECTOR DROPDOWN                                */
/* ----------------------------------------------------------*/
.header-language-picker {
    position: relative;
    display: flex;
    align-items: center;
}

.lang-trigger {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--font-color);
    font-size: 1.1rem;
    opacity: 0.65;
    transition: opacity 0.2s, background-color 0.2s;
}

.header-language-picker:hover .lang-trigger {
    opacity: 1;
    background-color: var(--main-color-light);
}

.lang-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    padding: 14px 8px 8px; /* top padding bridges the gap to the trigger */
    flex-direction: column;
    gap: 6px;
    z-index: 1200;
    min-width: 52px;
    align-items: center;
}

.header-language-picker:hover .lang-menu {
    display: flex;
}

.flag-icon {
    width: 28px;
    height: auto;
    cursor: pointer;
    border-radius: 3px;
    opacity: 0.85;
    transition: opacity 0.15s, transform 0.15s;
    display: block;
}

.flag-icon:hover {
    opacity: 1;
    transform: scale(1.12);
}

/* ----------------------------------------------------------*/
/* PROFILE DROPDOWN                                          */
/* ----------------------------------------------------------*/
.header-profile-btn {
    position: relative;
    display: flex;
    align-items: center;
}

.profile-trigger {
    display: flex;
    align-items: center;
    height: 34px;
    padding: 0 10px;
    border-radius: 17px;
    cursor: pointer;
    color: var(--font-color);
    font-size: 0.85rem;
    opacity: 0.7;
    transition: opacity 0.2s, background-color 0.2s;
    white-space: nowrap;
    gap: 4px;
}

.profile-trigger .fa-user-circle {
    font-size: 1.1rem;
}

.header-username {
    max-width: 120px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.header-profile-btn:hover .profile-trigger {
    opacity: 1;
    background-color: var(--main-color-light);
}

.profile-menu {
    display: none;
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    padding: 14px 8px 8px;
    flex-direction: column;
    gap: 4px;
    z-index: 1200;
    min-width: 140px;
}

.header-profile-btn:hover .profile-menu {
    display: flex;
}

.profile-menu-item {
    display: flex;
    align-items: center;
    padding: 7px 12px;
    border-radius: 6px;
    color: var(--font-color);
    font-size: 0.85rem;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s;
}

.profile-menu-item:hover {
    background-color: var(--main-color-light);
    text-decoration: none;
    color: var(--main-color-dark);
}

/* ----------------------------------------------------------*/
/* SHORT / FULL TITLE TOGGLE                                 */
/* ----------------------------------------------------------*/
.header-title--short { display: none; }
.header-title--full  { display: inline; }

/* ----------------------------------------------------------*/
/* HAMBURGER BUTTON                                          */
/* ----------------------------------------------------------*/
.sidebar-hamburger-btn {
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
    width: 44px;
    height: 44px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: var(--border-radius);
    transition: background-color 0.2s;
}

.sidebar-hamburger-btn:hover {
    background-color: var(--main-color-light);
}

.hamburger-line {
    display: block;
    width: 22px;
    height: 2px;
    background-color: var(--font-color);
    border-radius: 2px;
    transition: transform 0.2s;
}

/* ----------------------------------------------------------*/

@media (max-width: 768px) {
    /* Header en ligne unique */
    .app-header {
        flex-direction: row;
        height: var(--header-height);
        padding: 0 var(--spacing-md);
        gap: 8px;
        align-items: center;
        justify-content: space-between;
    }

    .header-logo {
        max-height: 60px;
    }

    /* Titres : court visible, long masqué */
    .header-title--full  { display: none; }
    .header-title--short { display: inline; font-size: 1rem; }

    /* Touch targets agrandis */
    .lang-trigger,
    .profile-trigger {
        min-height: 44px;
        min-width: 44px;
        justify-content: center;
    }

    /* Masquer le nom d'utilisateur */
    .header-username { display: none; }

    /* Masquer le badge de sélection */
    .header-selection-badge { display: none; }

    /* Contraindre les menus */
    .profile-menu,
    .lang-menu {
        right: 0;
        max-width: calc(100vw - 16px);
    }

    /* Afficher le hamburger */
    .sidebar-hamburger-btn { display: flex; }
}

@media (max-width: 480px) {
    .header-right-controls { gap: 4px; }
}

/* Bootstrap modals must sit above the fixed header (z-index: 1100) */
.modal       { z-index: 1200 !important; }
.modal-backdrop { z-index: 1150 !important; }
