/* Style commun pour tous les headers du module stage */
header {
    padding: 20px 24px;
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 50%, #020617 100%);
    border-bottom: 1px solid rgba(59, 130, 246, 0.3);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(59, 130, 246, 0.1) inset;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent 0%, rgba(59, 130, 246, 0.6) 50%, transparent 100%);
    animation: header-shimmer 3s ease-in-out infinite;
}

@keyframes header-shimmer {
    0%, 100% { opacity: 0.3; }
    50% { opacity: 0.8; }
}

header .header-left {
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    z-index: 1;
    min-width: 0;
    flex: 1 1 auto;
}

header .header-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    text-decoration: none;
    transition: transform 0.2s ease;
    border-radius: 8px;
    padding: 4px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

header .header-logo:hover {
    transform: scale(1.05);
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.2);
}

header .header-logo img {
    width: 40px;
    height: 40px;
    object-fit: cover;
    border-radius: 6px;
    display: block;
}

header .header-title-wrapper {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
    flex: 0 1 auto;
}

header .header-title-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

header .header-title-heading h1 {
    min-width: 0;
}

header .header-module-version {
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 800;
    letter-spacing: 0.04em;
    line-height: 1;
    color: #bfdbfe;
    -webkit-text-fill-color: #bfdbfe;
    background: rgba(59, 130, 246, 0.18);
    border: 1px solid rgba(147, 197, 253, 0.32);
    border-radius: 999px;
    padding: 4px 8px;
}

header h1 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: #f9fafb;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: -0.3px;
    background: linear-gradient(135deg, #f9fafb 0%, #e5e7eb 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

header .header-title-subtitle {
    font-size: 12px;
    color: #94a3b8;
    font-weight: 400;
    letter-spacing: 0.2px;
}

header .user {
    font-size: 13px;
    color: #9ca3af;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    z-index: 1;
    padding: 8px 16px;
    background: rgba(15, 23, 42, 0.4);
    border-radius: 8px;
    border: 1px solid rgba(148, 163, 184, 0.2);
    transition: all 0.2s ease;
}

header .user:hover {
    background: rgba(15, 23, 42, 0.6);
    border-color: rgba(148, 163, 184, 0.3);
}

header .header-end {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 0 1 auto;
    position: relative;
    z-index: 1;
    min-width: 0;
}

header .user strong {
    color: #e5e7eb;
    font-weight: 600;
}

header .header-user-identity {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

header .header-user-email {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

header .header-user-identity .header-user-email {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    background: transparent;
    text-decoration: none;
}

header .header-user-identity .header-user-email:hover {
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.15);
    text-decoration: none;
}

header > div:last-child {
    position: relative;
    z-index: 1;
}

header a {
    color: #93c5fd;
    font-size: 13px;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-weight: 500;
}

header a:hover {
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.15);
}

header a.logout,
header button.header-user-action.logout,
header .header-user-action.logout {
    color: #f97373;
}

header a.logout:hover,
header button.header-user-action.logout:hover,
header .header-user-action.logout:hover {
    color: #ef4444;
    background: rgba(239, 68, 68, 0.15);
}

/* POST CSRF : le formulaire ne participe pas au flex, le bouton se comporte comme l'ancien <a> */
header .header-csrf-form {
    display: contents;
}

/* Même DNA que header a / .header-user-email (padding 4×8, radius 6, font 13/500). */
header button.header-user-action,
header .header-user-action {
    color: #93c5fd;
    font-size: 13px;
    text-decoration: none;
    padding: 4px 8px;
    border-radius: 6px;
    transition: all 0.2s ease;
    font-weight: 500;
    background: transparent;
    border: 0;
    cursor: pointer;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    appearance: none;
    -webkit-appearance: none;
    margin: 0;
    line-height: inherit;
    box-shadow: none;
    min-height: 0;
    height: auto;
}

header button.header-user-action:hover,
header .header-user-action:hover {
    color: #60a5fa;
    background: rgba(59, 130, 246, 0.15);
}

header button.header-user-action.header-switch-role-link,
header .header-user-action.header-switch-role-link {
    color: #fbbf24;
}

header button.header-user-action.header-switch-role-link:hover,
header .header-user-action.header-switch-role-link:hover {
    color: #fcd34d;
    background: rgba(251, 191, 36, 0.15);
}

.header-action-label-short {
    display: none;
}

/* Espacement des icônes Font Awesome dans le header */
header a i,
header .header-user-action i,
header .user i {
    margin-right: 6px;
    font-size: 0.9em;
}

header .user span i {
    margin-right: 6px;
    opacity: 0.8;
}

/* Styles externalisés depuis les styles inline */
.header-year-selector-form {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin: 0;
    flex: 0 0 auto;
}

.header-year-selector-select {
    padding: 4px 6px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: #f1f5f9;
    font-size: 12px;
    cursor: pointer;
    min-width: 0;
    max-width: 9.5rem;
}

.header-year-selector-close {
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    color: #f1f5f9;
    text-decoration: none;
    font-size: 11px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.header-switch-role-link {
    color: #fbbf24;
}

/* Ligne 1 : logo + titre + année (grille, pas de wrap). Ligne 2 : identité + actions */
@media (max-width: 768px) {
    header {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        padding: 10px 12px;
        gap: 8px;
    }

    header .header-left {
        grid-column: 1 / -1;
        grid-row: 1;
        min-width: 0;
        gap: 8px;
        align-items: center;
        display: flex;
        flex-direction: row;
        flex: none;
    }

    header:has(.header-year-selector-form) .header-left {
        grid-column: 1;
    }

    header .header-logo {
        flex-shrink: 0;
        display: flex;
        align-items: center;
    }

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

    header .header-end {
        display: contents;
    }

    header .header-title-wrapper {
        display: flex;
        flex-direction: row;
        align-items: center;
        gap: 0;
        min-width: 0;
        flex: 1 1 auto;
        margin: 0;
        padding: 0;
        height: auto;
        min-height: 0;
    }

    header .header-title-heading {
        min-width: 0;
        flex: 1 1 auto;
    }

    header h1 {
        font-size: 15px;
        line-height: 1.25;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        margin: 0;
        padding: 0;
        max-width: 100%;
        background: none;
        -webkit-background-clip: unset;
        -webkit-text-fill-color: unset;
        background-clip: unset;
        color: #f9fafb;
        text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
        display: block;
    }

    header .header-title-subtitle {
        display: none;
    }

    header .user {
        grid-column: 1 / -1;
        grid-row: 2;
        width: auto;
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        align-items: center;
        gap: 4px;
        padding: 6px 8px;
        font-size: 12px;
        min-width: 0;
        box-sizing: border-box;
    }

    header .header-user-identity {
        display: flex;
        flex: 1 1 0;
        min-width: 0;
        overflow: hidden;
    }

    header .header-user-identity i {
        flex-shrink: 0;
    }

    header .header-user-email,
    header .user strong {
        font-size: 12px;
        flex: 1 1 auto;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    header .header-year-selector-form {
        grid-column: 2;
        grid-row: 1;
        margin: 0;
        gap: 4px;
        align-self: center;
    }

    header .header-year-selector-select,
    header .header-year-selector-close {
        font-size: 12px;
        min-height: 28px;
        height: 28px;
        box-sizing: border-box;
        line-height: 1.2;
    }

    header .header-year-selector-select {
        min-width: 0;
        width: auto;
        max-width: 8rem;
        padding: 2px 4px 2px 6px;
    }

    header .header-year-selector-close {
        padding: 0 8px;
        min-width: 28px;
        justify-content: center;
    }

    header .header-year-selector-close i {
        margin-right: 0;
    }

    header .stages-breadcrumb {
        grid-column: 1 / -1;
        grid-row: 3;
    }

    header .user > a,
    header .user > .header-user-action {
        flex: 0 0 auto;
        flex-shrink: 0;
        min-width: 0;
        min-height: 28px;
        height: 28px;
        padding: 0 6px;
        font-size: 12px;
        text-align: left;
        display: inline-flex;
        align-items: center;
        justify-content: flex-start;
        white-space: nowrap;
        box-sizing: border-box;
    }

    header .user a i,
    header .user .header-user-action i {
        margin-right: 4px;
        font-size: 11px;
        flex-shrink: 0;
    }

    .header-action-label-full {
        display: none;
    }

    .header-action-label-short {
        display: inline;
    }
}

