/* SPDX-License-Identifier: AGPL-3.0-only
 * Copyright (C) 2026 Vivian Epiney (AP-EdNum, HEP-VS) */
/* --- Header unifié --- */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border, var(--card-border, rgba(0, 0, 0, 0.08)));
    width: 100%;
    position: relative;
    z-index: 50;
}

.app-header.dropdown-open,
.app-header:has(.settings-dropdown-content.show),
.app-header:has(.settings-dropdown:hover) {
    z-index: 2000;
}

/* Réduction de l'espace excessif au sommet et au bas des cartes d'applications */
.container:has(> .app-header),
.container:has(> header.app-header) {
    padding-top: 0 !important;
    padding-bottom: 22px !important;
}

.container > .app-header:first-child,
.container > header.app-header:first-child {
    padding-top: 1rem;
    padding-bottom: 0.85rem;
    padding-left: 0;
    padding-right: 0;
    margin-bottom: 1rem;
}

.header-title-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 0;
}

/* --- Bouton de retour dédié vers l'accueil / le portail --- */
.header-back-btn {
    width: 42px;
    height: 42px;
    min-width: 42px;
    min-height: 42px;
    background: var(--card-bg, rgba(255, 255, 255, 0.8));
    border: 1px solid var(--border, rgba(0, 0, 0, 0.1));
    color: var(--text-light, #64748b);
    border-radius: var(--radius-xl, 14px);
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    cursor: pointer;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
    transition: color 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
    flex-shrink: 0;
}

.header-back-btn svg {
    width: 20px;
    height: 20px;
    transition: transform 0.2s ease;
}

.header-back-btn:hover {
    color: var(--primary, #a52a23);
    border-color: var(--primary, #a52a23);
    background: var(--card-bg, #ffffff);
    transform: translateX(-3px);
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}

.header-back-btn:hover svg {
    transform: translateX(-1px);
}

.header-back-btn:active {
    transform: translateX(-1px) scale(0.96);
}

body.dark .header-back-btn {
    background: rgba(30, 41, 59, 0.7);
    border-color: rgba(255, 255, 255, 0.12);
    color: var(--text-light, #94a3b8);
    box-shadow: none;
}

body.dark .header-back-btn:hover {
    background: rgba(30, 41, 59, 0.95);
    border-color: var(--primary-hover, #da5c55);
    color: var(--primary-hover, #da5c55);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

body.high-contrast .header-back-btn {
    border: 2px solid currentColor;
}

/* --- Badge d'icône d'application --- */
.header-icon {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    max-width: 44px;
    max-height: 44px;
    aspect-ratio: 1;
    background: var(--primary-light, var(--badge-bg, rgba(2, 132, 199, 0.15)));
    color: var(--primary, var(--accent, #0284c7));
    border-radius: var(--radius-xl, 14px);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: none;
    text-decoration: none;
    flex: 0 0 44px;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

div.header-icon,
span.header-icon {
    cursor: default;
    user-select: none;
}

/* Rétro-compatibilité pour les pages non encore migrées en <a> */
a.header-icon {
    cursor: pointer;
}

a.header-icon:hover {
    background: var(--primary, var(--accent, #0284c7));
    color: white;
    transform: translateY(-2px) scale(1.05);
}

body.dark .header-icon {
    background: rgba(255, 255, 255, 0.08);
    color: var(--primary-light, #38bdf8);
}

body.dark a.header-icon:hover {
    background: var(--primary, var(--accent, #0284c7));
    color: #ffffff;
}

.app-header h1 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 0;
    font-size: 1.35rem;
    font-weight: 800;
    letter-spacing: -0.025em;
    color: var(--text-main, #0f172a);
    flex-wrap: wrap;
}

/* --- Badge Alpha --- */
.badge-alpha {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 2px 8px;
    border-radius: var(--radius-pill, 30px);
    background: rgba(245, 158, 11, 0.15);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.3);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
    vertical-align: middle;
    flex-shrink: 0;
}

body.dark .badge-alpha {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border-color: rgba(245, 158, 11, 0.4);
}

body.high-contrast .badge-alpha {
    background: #ffffff !important;
    color: #000000 !important;
    border: 2px solid #000000 !important;
}

/* --- Badge Niveau (Pill) --- */
.badge-level {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: var(--radius-pill, 30px);
    background: var(--primary-light, var(--badge-bg, rgba(2, 132, 199, 0.15)));
    color: var(--primary, var(--accent, #0284c7));
    border: 1px solid var(--primary-light, rgba(2, 132, 199, 0.3));
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
    vertical-align: middle;
    flex-shrink: 0;
}

body.dark .badge-level {
    background: rgba(255, 255, 255, 0.08);
    color: var(--primary-light, #38bdf8);
    border-color: rgba(255, 255, 255, 0.15);
}

body.high-contrast .badge-level {
    background: #ffffff !important;
    color: #000000 !important;
    border: 2px solid #000000 !important;
}

/* Cache les badge-level dans le header des applications sur mobile et petit écran */
@media (max-width: 768px) {
    header .badge-level,
    .app-header .badge-level,
    .header-title-wrapper .badge-level,
    h1 .badge-level,
    .badge-level {
        display: none !important;
    }
}

/* --- Boutons d'action --- */
.action-buttons {
    display: flex;
    gap: 8px;
    z-index: 100;
}
/* --- Dropdown Réglages --- */
.settings-dropdown {
    position: relative;
    display: inline-block;
    z-index: 100;
}

.settings-dropdown:has(.settings-dropdown-content.show),
.settings-dropdown:hover {
    z-index: 1000;
}

.settings-dropdown-content {
    display: none;
    position: absolute;
    right: 0;
    top: 110%;
    background: var(--container-bg, oklch(1 0 0 / 0.95));
    min-width: 60px;
    box-shadow: 0 10px 40px -10px oklch(0 0 0 / 0.3);
    border: 1px solid var(--card-border, oklch(0 0 0 / 0.1));
    border-radius: var(--radius-lg);
    z-index: 1001;
    backdrop-filter: blur(20px);
    padding: 10px;
    flex-direction: column;
    gap: 10px;
}

/* Pseudo-element to bridge the gap between button and dropdown to prevent hover loss */
.dropdown-divider {
    height: 1px;
    background-color: oklch(0 0 0 / 0.1);
    margin: 2px 0;
}
body.dark .dropdown-divider {
    background-color: oklch(1 0 0 / 0.1);
}

.settings-dropdown-content::before {
    content: '';
    position: absolute;
    top: -15px;
    left: 0;
    right: 0;
    height: 15px;
    background: transparent;
}

body.dark .settings-dropdown-content {
    background: rgb(15 23 42 / 98%);
    border: 1px solid oklch(1 0 0 / 0.1);
    box-shadow: 0 10px 40px -10px oklch(0 0 0 / 0.6);
}

/* Affichage au survol ou au clic sur le bouton déclencheur */
.settings-dropdown:hover .settings-dropdown-content,
.settings-dropdown-content.show {
    display: flex;
    animation: fade-in-cascade 0.2s var(--spring-easing, cubic-bezier(0.175, 0.885, 0.32, 1.275)) forwards;
}

.icon-action-btn {
    background: var(--card-bg, oklch(1 0 0 / 0.8));
    border: 1px solid var(--card-border, oklch(0 0 0 / 0.1));
    color: var(--text-main, #1e293b);
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-full);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-shadow: 0 2px 5px oklch(0 0 0 / 0.05);
    min-width: 44px;
    min-height: 44px;
}

.icon-action-btn:hover {
    background: oklch(1 0 0 / 0.9);
    transform: scale(1.05);
}

.settings-dropdown-content .icon-action-btn {
    color: var(--text-main, #1e293b);
    background: transparent;
    border: 1px solid transparent;
    box-shadow: none;
}

body.dark .icon-action-btn {
    background: rgb(30 41 59 / 80%);
    border: 1px solid oklch(1 0 0 / 0.1);
    color: #f8fafc;
}

.settings-dropdown-content .icon-action-btn:hover {
    background: oklch(0 0 0 / 0.05);
    transform: none;
}

body.dark .icon-action-btn:hover {
    background: rgb(30 41 59 / 90%);
}

body.dark .settings-dropdown-content .icon-action-btn {
    color: #fff;
    background: transparent;
    border: 1px solid transparent;
}

body.dark .settings-dropdown-content .icon-action-btn:hover {
    background: oklch(1 0 0 / 0.1);
}

/* --- Bascule automatique des icônes Mode TNI/TBI (Plein écran / Projection) --- */
#icon-proj-compress {
    display: none !important;
}
body.projection #icon-proj-expand {
    display: none !important;
}
body.projection #icon-proj-compress {
    display: inline-block !important;
}
/* --- Footer générique et accessible --- */
footer {
    text-align: center;
    margin-top: 2rem;
    padding: 1.25rem 1rem;
    font-size: 0.8rem;
    line-height: 1.6;
    width: 100%;
    color: var(--text-secondary, #475569);
}

footer a {
    color: var(--primary, #0284c7);
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
    transition: color 0.2s ease;
}

footer a:hover {
    color: var(--primary-hover, #0369a1);
}

body.dark footer {
    color: #94a3b8 !important;
}

body.dark footer a {
    color: #38bdf8 !important;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
}

body.dark footer a:hover {
    color: #7dd3fc !important;
}

body.dark footer span,
body.dark footer span[style*="opacity"] {
    opacity: 1 !important;
    color: #94a3b8;
}

/* Cœur du footer : haute visibilité et lisibilité */
footer a [data-fa="heart"],
footer a svg.fa-heart,
footer [data-fa="heart"] {
    color: #ef4444;
    display: inline-block;
    transition: transform 0.2s var(--spring-easing, ease-in-out);
}

footer a:hover [data-fa="heart"],
footer a:hover svg.fa-heart {
    transform: scale(1.25);
}

body.dark footer a [data-fa="heart"],
body.dark footer a svg.fa-heart,
body.dark footer [data-fa="heart"] {
    color: #ff6b81 !important;
    fill: #ff6b81 !important;
    filter: drop-shadow(0 0 4px rgba(255, 107, 129, 0.45));
}

body.dark footer a:hover [data-fa="heart"],
body.dark footer a:hover svg.fa-heart {
    color: #fda4af !important;
    fill: #fda4af !important;
}

/* Footer pour les webapps élèves sur fond dégradé (flat, épuré, sans conteneur pill) */
.container + footer.no-print,
.app-shell + footer.no-print,
.container ~ footer.no-print,
.app-shell ~ footer.no-print {
    margin-top: 1rem;
    margin-bottom: 1rem;
    padding: 0 1rem;
    text-align: center;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
}

.container + footer.no-print p,
.app-shell + footer.no-print p,
.container ~ footer.no-print p,
.app-shell ~ footer.no-print p {
    display: block;
    margin: 0 auto;
    padding: 0;
    background: transparent !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    backdrop-filter: none !important;
    -webkit-backdrop-filter: none !important;
    color: rgba(255, 255, 255, 0.95);
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
    font-size: 0.8rem;
    line-height: 1.6;
    text-align: center;
}

.container + footer.no-print a,
.app-shell + footer.no-print a,
.container ~ footer.no-print a,
.app-shell ~ footer.no-print a {
    color: #ffffff !important;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
    transition: opacity 0.2s ease;
}

.container + footer.no-print a:hover,
.app-shell + footer.no-print a:hover,
.container ~ footer.no-print a:hover,
.app-shell ~ footer.no-print a:hover {
    color: #ffffff !important;
    opacity: 0.8;
}

body.dark .container + footer.no-print p,
body.dark .app-shell + footer.no-print p,
body.dark .container ~ footer.no-print p,
body.dark .app-shell ~ footer.no-print p {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    color: #94a3b8 !important;
    text-shadow: none;
}

body.dark .container + footer.no-print a,
body.dark .app-shell + footer.no-print a,
body.dark .container ~ footer.no-print a,
body.dark .app-shell ~ footer.no-print a {
    color: #38bdf8 !important;
    text-shadow: none;
}

body.dark .container + footer.no-print a:hover,
body.dark .app-shell + footer.no-print a:hover,
body.dark .container ~ footer.no-print a:hover,
body.dark .app-shell ~ footer.no-print a:hover {
    color: #7dd3fc !important;
}

body.high-contrast footer,
body.high-contrast footer.no-print,
body.high-contrast .container + footer.no-print p,
body.high-contrast .app-shell + footer.no-print p,
body.high-contrast .container ~ footer.no-print p,
body.high-contrast .app-shell ~ footer.no-print p {
    background: transparent !important;
    color: #000000 !important;
    border: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
}

body.high-contrast footer a,
body.high-contrast footer.no-print a,
body.high-contrast .container + footer.no-print a,
body.high-contrast .app-shell + footer.no-print a,
body.high-contrast .container ~ footer.no-print a,
body.high-contrast .app-shell ~ footer.no-print a {
    color: #0000ff !important;
    text-decoration: underline !important;
    text-shadow: none !important;
}
/* ============================================================
   Modal Statistiques détaillées (ScoreManager)
   ============================================================ */
.ui-modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100vw; height: 100vh;
    background: oklch(0 0 0 / 0.4);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.ui-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.ui-modal-content {
    background: var(--card-bg, oklch(1 0 0 / 0.95));
    border: var(--glass-border);
    box-shadow: var(--glass-shadow);
    border-radius: var(--radius-2xl);
    padding: 30px;
    width: 90%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    transform: scale(0.95) translateY(20px);
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    color: var(--text-color, #1a202c);
}

body.dark .ui-modal-content {
    background: #2d3748;
    color: #f7fafc;
}

.ui-modal-overlay.active .ui-modal-content {
    transform: scale(1) translateY(0);
}

.btn-reset-scores {
    margin-top: 25px;
    padding: 12px 24px;
    background: #e53e3e;
    color: white;
    border: none;
    border-radius: var(--radius-lg);
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    display: block;
    width: 100%;
}

.btn-reset-scores:hover {
    background: #c53030;
    transform: scale(1.02);
}

.stat-mode-title {
    margin-top: 20px;
    margin-bottom: 10px;
    border-bottom: 2px solid var(--primary-color, #667eea);
    padding-bottom: 5px;
    font-size: 1.2rem;
}

.stat-table-wrapper {
    overflow-x: auto;
}

.stat-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
    font-size: 0.95rem;
}

.stat-table th, .stat-table td {
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid oklch(0 0 0 / 0.1);
}

.stat-table th {
    font-weight: bold;
    color: var(--primary-color, #667eea);
}

/* Dark mode overrides (si géré par des classes sur body, à ajuster selon le projet) */

body.dark .stat-table th, body.dark .stat-table td {
    border-bottom: 1px solid oklch(1 0 0 / 0.1);
}

.menu-item-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 16px;
    background: transparent;
    border: none;
    color: var(--text-main, #1e293b);
    font-size: 15px;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    border-radius: var(--radius-md);
    text-align: left;
    transition: background-color 0.2s, transform 0.1s;
    white-space: nowrap;
}

.menu-item-btn:hover {
    background: oklch(0 0 0 / 0.05);
}

.menu-item-btn:active {
    transform: scale(0.98);
}

body.dark .menu-item-btn {
    color: #f8fafc;
}

body.dark .menu-item-btn:hover {
    background: oklch(1 0 0 / 0.1);
}

/* Graphiques Donut */
.stat-mode-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 30px;
}

.stat-chart-wrapper {
    display: flex;
    align-items: center;
    gap: 30px;
    background: oklch(0 0 0 / 0.02);
    padding: 20px;
    border-radius: var(--radius-xl);
    flex-wrap: wrap;
    justify-content: center;
}

body.dark .stat-chart-wrapper {
    background: oklch(1 0 0 / 0.03);
}

.stat-donut-container {
    position: relative;
    width: 140px;
    height: 140px;
    animation: donut-fade-in 0.5s ease-out forwards;
}

.stat-donut {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.stat-donut-circle {
    fill: none;
    stroke-width: 18;
    stroke-linecap: butt;
    transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-donut-bg {
    fill: none;
    stroke: oklch(0 0 0 / 0.05);
    stroke-width: 18;
}

body.dark .stat-donut-bg {
    stroke: oklch(1 0 0 / 0.1);
}

.stat-legend {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-legend-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.stat-legend-color {
    width: 12px;
    height: 12px;
    border-radius: var(--radius-xs);
    flex-shrink: 0;
}

.color-success-1st { background-color: #22c55e; stroke: #22c55e; }
.color-success-more { background-color: #f59e0b; stroke: #f59e0b; }
.color-mistakes { background-color: #ef4444; stroke: #ef4444; }

body.dark .color-success-1st { background-color: #16a34a; stroke: #16a34a; }
body.dark .color-success-more { background-color: #d97706; stroke: #d97706; }
body.dark .color-mistakes { background-color: #b91c1c; stroke: #b91c1c; }

.stat-legend-label {
    color: var(--text-secondary);
}

.stat-legend-value {
    font-weight: 700;
    margin-left: auto;
}

@keyframes donut-fade-in {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* ============================================================
   Mobile Bottom Tab Bar (Espace, Simulateur, Pilotage, etc.)
   ============================================================ */
@media (width <= 600px) {
    /* Header Responsive Layout */
    .app-header {
        gap: 10px;
        margin-bottom: 16px;
    }

    .header-title-wrapper {
        min-width: 0;
        flex: 1;
        gap: 8px;
    }

    .header-back-btn {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
        border-radius: 11px;
    }

    .header-back-btn svg {
        width: 17px;
        height: 17px;
    }

    .header-icon {
        width: 38px;
        height: 38px;
        min-width: 38px;
        min-height: 38px;
        max-width: 38px;
        max-height: 38px;
        aspect-ratio: 1;
        flex: 0 0 38px;
        border-radius: 11px;
    }

    .header-icon svg {
        width: 20px;
        height: 20px;
    }

    .header-title-wrapper > div:not(.header-icon) {
        min-width: 0;
        flex: 1;
    }

    .app-header h1 {
        white-space: normal;
        font-size: clamp(1.05rem, 4.2vw, 1.35rem);
        line-height: 1.25;
        overflow: visible;
        text-overflow: clip;
        flex-wrap: wrap;
    }

    /* Fix for position: fixed failing inside animated containers */
    html body:has(.tabs) > main,
    html body:has(.tab-bar) > main,
    html body:has(.tabs) .container,
    html body:has(.tab-bar) .container,
    html body:has(.tabs) .app-shell,
    html body:has(.tab-bar) .app-shell,
    html body:has(.tabs) > .app-shell,
    html body:has(.tab-bar) > .app-shell {
        transform: none;
        animation: none;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }

    html body {
        padding-bottom: 90px; /* Prevent content from being hidden behind the bar */
    }

    html body:has(.tabs),
    html body:has(.tab-bar) {
        padding-bottom: calc(85px + env(safe-area-inset-bottom, 0px)) !important;
    }

    html body > .tabs, html body main > .tabs, html body > .tab-bar, html body .container > .tabs, html body .container main > .tabs, html body .container .tabs, html body .tabs {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        margin: 0;
        padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px)) 10px;
        background: var(--container-bg, oklch(1 0 0 / 0.9));
        backdrop-filter: var(--glass-blur, blur(16px));
        -webkit-backdrop-filter: var(--glass-blur, blur(16px));
        border-top: var(--glass-border, 1px solid oklch(1 0 0 / 0.2));
        box-shadow: 0 -4px 16px oklch(0 0 0 / 0.1);
        z-index: 1000;
        display: flex;
        justify-content: center;
        gap: 8px;
        border-radius: var(--radius-2xl) var(--radius-2xl) 0 0;
        box-sizing: border-box;
    }

    /* Make buttons expand to fill the bar */
    html body > .tabs > *, html body main > .tabs > *, html body > .tab-bar > *, html body .container > .tabs > *, html body .container main > .tabs > *, html body .container .tabs > *, html body .tabs > * {
        flex: 1;
        text-align: center;
        min-width: 0; /* allows flex to shrink below intrinsic width if needed */
        font-size: 12px;
        padding: 8px 4px;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-direction: column;
    }

    html body.dark .tabs, html body.dark main > .tabs, html body.dark .tab-bar, html body.dark .container .tabs {
        background: rgb(30 41 59 / 90%);
        border-top: 1px solid oklch(1 0 0 / 0.1);
        box-shadow: 0 -4px 16px oklch(0 0 0 / 0.5);
    }

    html .settings-dropdown-content {
        right: 0;
        left: auto;
    }

    /* Fix containing block issues on mobile for fixed bottom bars */
    html body > header, html .container, html body > .container, html .app-shell, html body > .app-shell {
        transform: none;
        animation: none;
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}

/* TBI (Tableau Blanc Interactif) & Large Screens Optimization */
@media (width >= 1200px) {
  :root {
    --container-max-width: 1400px;
  }

  body {
    font-size: 18px; /* Bump base font size for better readability from afar */
  }

  body .container {
    max-width: var(--container-max-width);
  }

  /* Increase base interactive element sizes slightly */
  button, select, input {
    font-size: 1.1em;
  }

}
/* ============================================================
   Unified Toast Notification (c2-toast / toast.js)
   ============================================================ */
#c2-toast-container {
    position: fixed;
    bottom: 32px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10001;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}

.c2-toast {
    padding: 10px 20px;
    border-radius: var(--radius-pill, 30px);
    font-weight: 600;
    font-size: 0.95rem;
    color: white;
    background: rgb(30 41 59 / 90%);
    backdrop-filter: blur(8px);
    border: 1px solid oklch(1 0 0 / 0.1);
    box-shadow: 0 10px 25px oklch(0 0 0 / 0.3);
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transform: translateY(12px) scale(0.95);
    transition: opacity 0.3s var(--spring-easing, ease),
                transform 0.3s var(--spring-easing, ease);
    text-align: center;
    max-width: min(90vw, 450px);
    white-space: pre-wrap;
    pointer-events: auto;
}

.c2-toast.success { background: rgb(16 185 129 / 95%); }
.c2-toast.error   { background: rgb(239 68 68 / 95%); }
.c2-toast.warn    { background: rgb(245 158 11 / 95%); }
.c2-toast.info    { background: rgb(99 102 241 / 95%); }

.c2-toast i {
    flex-shrink: 0;
}

.c2-toast.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.c2-toast-update-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-align: center;
}

.c2-toast-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: #ffffff;
    color: #4338ca;
    border: none;
    border-radius: var(--radius-pill, 9999px);
    padding: 8px 18px;
    font-size: 0.88rem;
    font-weight: 700;
    font-family: inherit;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.16);
    transition: all 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
    width: fit-content;
    line-height: 1.2;
    margin-top: 4px;
}

.c2-toast-btn:hover {
    background: #ffffff;
    color: #3730a3;
    transform: translateY(-2px) scale(1.04);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.24);
}

.c2-toast-btn:active {
    transform: translateY(0) scale(0.96);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}

.c2-toast-btn i, .c2-toast-btn svg {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    transition: transform 0.4s ease;
}

.c2-toast-btn:hover i, .c2-toast-btn:hover svg {
    transform: rotate(180deg);
}

body.high-contrast .c2-toast-btn {
    background: #ffffff;
    color: #000000;
    border: 2px solid #000000;
}

/* ============================================================
   Boutons (Standardisés)
   ============================================================ */
.btn {
    border: none;
    border-radius: var(--radius-md);
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s var(--spring-easing, ease);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 44px;
    min-height: 44px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn:hover:not(:disabled) {
    transform: translateY(-2px);
}

.btn:active:not(:disabled) {
    transform: scale(0.95) translateY(0);
}

.btn-small {
    padding: 6px 12px;
    font-size: 14px;
    border-radius: var(--radius-sm);
    min-height: auto;
    min-width: auto;
}

.btn-primary, .btn-new {
    background: var(--accent);
    color: #fff;
}

.btn-primary:hover:not(:disabled), .btn-new:hover:not(:disabled) {
    background: var(--accent-dark, var(--accent-hover, #4f46e5));
}

.btn-success, .btn-check {
    background: var(--success);
    color: #fff;
}

.btn-success:hover:not(:disabled), .btn-check:hover:not(:disabled) {
    background: #059669;
}

.btn-clear {
    background: var(--bb-blue, #3b82f6);
    color: #fff;
}

.btn-clear:hover:not(:disabled) {
    background: var(--bb-blue-shadow, #2563eb);
}

.btn-outline {
    background: transparent;
    border: 2px solid var(--card-border, #e2e8f0);
    color: var(--text-muted);
}

body.dark .btn-outline {
    border-color: #334155;
    color: #cbd5e1;
}

.btn-outline:hover:not(:disabled) {
    background: var(--card-bg, #f1f5f9);
    color: var(--text-main);
    border-color: var(--text-secondary, #cbd5e1);
}

.btn-outline-error {
    background: transparent;
    border: 2px solid #fca5a5;
    color: #ef4444;
}

body.dark .btn-outline-error {
    border-color: #991b1b;
    color: #f87171;
}

.btn-outline-error:hover:not(:disabled) {
    background: #fef2f2;
    color: #b91c1c;
    border-color: #f87171;
}

body.dark .btn-outline:hover:not(:disabled) {
    background: #334155;
    color: #f8fafc;
}

body.dark .btn-outline-error:hover:not(:disabled) {
    background: #450a0a;
    color: #fca5a5;
}
/* ============================================================
   Navigation par onglets (Standardisée)
   ============================================================ */
.tabs {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

.tab-btn {
    padding: 10px 20px;
    border-radius: var(--radius-lg);
    border: 2px solid #e2e8f0;
    background: #ffffff;
    color: var(--text-muted);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s var(--spring-easing, ease);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 44px;
    min-height: 44px;
}

.tab-btn:hover {
    border-color: #cbd5e1;
    transform: translateY(-2px);
}

.tab-btn:active {
    transform: scale(0.95);
}

.tab-btn.active {
    background: var(--accent);
    color: white;
    border-color: var(--accent);
    box-shadow: 0 4px 12px rgb(99 102 241 / 30%);
}

body.dark .tab-btn {
    background: var(--card-bg);
    border-color: #334155;
    color: #94a3b8;
}

body.dark .tab-btn:hover {
    border-color: #475569;
}

body.dark .tab-btn.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
/* ============================================================
   Instructions (Standardisée)
   ============================================================ */
.game-instruction {
    text-align: center;
    color: var(--text-main);
    font-size: 1.1em;
    font-weight: 600;
    margin-bottom: 15px;
}

.fa-icon {
    width: 1em;
    height: 1em;
    vertical-align: -0.125em;
    fill: currentcolor;
    overflow: visible;
}

.header-icon svg {
    width: 24px;
    height: 24px;
}

/* Accessibility: Skip to main content link */
.skip-link {
    position: absolute;
    top: -100px;
    left: 0;
    background: var(--primary, #2563eb);
    color: white;
    padding: 8px;
    z-index: 10000;
    transition: top 0.2s;
    text-decoration: none;
    font-weight: bold;
}

.skip-link:focus {
    top: 0;
}
/* ============================================================
   Card Footer & Score Bar (Standard Unifié)
   ============================================================ */
.card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid var(--card-border, #e2e8f0);
    flex-wrap: wrap;
    gap: 15px;
}

body.dark .card-footer {
    border-top-color: #334155;
}

.score-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    flex-wrap: wrap;
}

.card-footer .score-bar {
    margin-top: 0;
    padding-top: 0;
    border-top: none;
    flex: 1;
    justify-content: flex-end;
}

.score-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    min-width: 60px;
}

.score-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-muted, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 2px;
    user-select: none;
    -webkit-user-select: none;
}

.score-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent, var(--primary, #6366f1));
    font-family: 'JetBrains Mono', Consolas, monospace;
    line-height: 1.2;
}

body.dark .score-label {
    color: var(--text-muted, #94a3b8);
}

body.dark .score-value {
    color: var(--accent, #818cf8);
}

/* Fix for .card-footer inside .desktop-layout-side to prevent squeezing */
.desktop-layout-side .card-footer {
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 20px;
}

.desktop-layout-side .card-footer .score-bar {
    justify-content: center;
    width: 100%;
}

/* Mode Projection / TBI pour les scores */
body.projection .score-bar {
    gap: 36px;
}

body.projection .score-label {
    font-size: 16px;
}

body.projection .score-value {
    font-size: 32px;
}

/* ============================================================
   Share Modal Styles
   ============================================================ */
#share-modal {
    max-width: 850px;
}

.share-header {
    text-align: center;
    margin-bottom: 25px;
}

.share-header h2 {
    margin-top: 0;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 1.5em;
}

.share-header p {
    color: var(--text-secondary, #4a5568);
    margin: 0;
}

body.dark .share-header p {
    color: #a0aec0;
}

.share-main {
    margin-bottom: 25px;
}

.share-url-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    background: var(--bg-color, #f7fafc);
    padding: 10px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--grid-border, #e2e8f0);
}

body.dark .share-url-container {
    background: #1a202c;
    border-color: #4a5568;
}

#share-url-input {
    flex-grow: 1;
    min-width: 200px;
    border: none;
    background: transparent;
    font-family: 'JetBrains Mono', monospace;
    font-size: 16px;
    color: var(--text-color, #1a202c);
    padding: 0 10px;
    outline: none;
}

body.dark #share-url-input {
    color: #f7fafc;
}

.share-url-container .btn {
    white-space: nowrap;
    padding: 8px 16px;
    font-size: 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1 1 auto;
}

.share-advanced {
    border-top: 1px solid var(--grid-border, #e2e8f0);
    padding-top: 20px;
}

body.dark .share-advanced {
    border-top-color: #4a5568;
}

.btn-advanced-toggle {
    background: transparent;
    border: none;
    color: var(--btn-primary-bg, #667eea);
    font-weight: 600;
    font-size: 1em;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0;
    margin-bottom: 15px;
    transition: color 0.2s;
}

.btn-advanced-toggle:hover {
    color: var(--btn-primary-hover, #5a67d8);
}

body.dark .btn-advanced-toggle {
    color: #7f9cf5;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    background: var(--bg-color, #f7fafc);
    padding: 15px;
    border-radius: var(--radius-lg);
}

body.dark .options-grid {
    background: #2d3748;
}

.options-column h3 {
    font-size: 0.9em;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary, #4a5568);
    margin-top: 0;
    margin-bottom: 15px;
    border-bottom: 1px solid var(--grid-border, #e2e8f0);
    padding-bottom: 5px;
}

body.dark .options-column h3 {
    color: #a0aec0;
    border-bottom-color: #4a5568;
}

.share-option {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 15px;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--grid-border, #e2e8f0);
}

.share-option:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

body.dark .share-option {
    border-bottom-color: #4a5568;
}

.share-option-text {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.share-option-label {
    font-size: 0.95em;
    font-weight: 600;
    color: var(--text-color, #1a202c);
    cursor: pointer;
}

body.dark .share-option-label {
    color: #e2e8f0;
}

.share-option-desc {
    font-size: 0.8em;
    color: var(--text-secondary, #718096);
    line-height: 1.4;
}

body.dark .share-option-desc {
    color: #a0aec0;
}

/* Toggle Switch Styles */
.share-toggle {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
    cursor: pointer;
}

.share-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.share-toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #cbd5e1;
    transition: .3s;
    border-radius: 24px;
}

body.dark .share-toggle-slider {
    background-color: #475569;
}

.share-toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

input:checked + .share-toggle-slider {
    background-color: var(--success, #10b981);
}

input:focus + .share-toggle-slider {
    box-shadow: 0 0 1px var(--success, #10b981);
}

input:checked + .share-toggle-slider:before {
    transform: translateX(20px);
}

.instructions {
    background: #f0f4ff;
    padding: 15px;
    border-left: 4px solid var(--accent);
    border-radius: var(--radius-sm);
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 25px;
    cursor: pointer;
}

.instructions strong {
    color: var(--accent);
}

/* Modal Prompt (Popups and Alerts) */
.ui-modal-overlay.z-top {
    z-index: 10001;
}

.ui-modal-content.ui-modal-prompt {
    max-width: 400px;
    text-align: center;
}

.ui-modal-prompt h2 {
    margin-bottom: 15px;
}

.ui-modal-prompt p {
    margin-bottom: 20px;
}

.ui-modal-prompt-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.ui-modal-prompt-actions .btn {
    flex: 1;
    justify-content: center;
}

.ui-btn-close {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.05);
    border: none;
    font-size: 20px;
    color: var(--text-muted, #777);
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-full, 9999px);
    transition: all 0.2s;
    z-index: 10;
}

.ui-btn-close:hover {
    background: rgba(0, 0, 0, 0.1);
    color: var(--error, #ef4444);
    transform: rotate(90deg) scale(1.1);
}

body.dark .ui-btn-close {
    background: rgba(255, 255, 255, 0.08);
    color: #f7fafc;
}

body.dark .ui-btn-close:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* UI Panels (Side Drawers) */
.ui-panel-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    backdrop-filter: blur(5px);
}

.ui-panel-overlay.active {
    opacity: 1;
    visibility: visible;
}

.ui-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: 400px;
    height: 100vh;
    background: var(--card-bg, #ffffff);
    z-index: 9999;
    box-shadow: -5px 0 25px rgba(0, 0, 0, 0.5);
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
    color: var(--text-main, #333);
}

@media (max-width: 600px) {
    .ui-panel {
        width: 100%;
        right: -100%;
    }
}

.ui-panel.active {
    right: 0;
}

.ui-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid var(--grid-border, #e2e8f0);
    flex-shrink: 0;
}

.ui-panel-header h2 {
    margin: 0;
    font-size: 24px;
}

.btn-preset {
    background: var(--bg-color, #f7fafc);
    border: 1px solid var(--grid-border, #e2e8f0);
    color: var(--text-color, #1a202c);
    padding: 10px;
    border-radius: var(--radius-md);
    transition: all 0.2s;
    font-weight: 500;
}

body.dark .btn-preset {
    background: #2d3748;
    border-color: #4a5568;
    color: #f7fafc;
}

.btn-preset:hover {
    background: var(--grid-border, #e2e8f0);
    transform: translateY(-2px);
}

body.dark .btn-preset:hover {
    background: #4a5568;
}

.badge-specific {
    font-size: 0.8em;
    color: var(--btn-primary-bg, #667eea);
    cursor: help;
    font-weight: bold;
}


/* Override pour les icones personnalisées border-all et border-all-slash */
body .fa-border-all-slash path.fa-secondary,
body .fa-border-all path.fa-secondary {
    opacity: 1;
    fill: currentColor;
}

/* ============================================================
   Guide d'installation PWA (iOS, Mac, Desktop)
   ============================================================ */
.pwa-install-modal {
    max-width: 520px;
    width: 92%;
    padding: 28px 24px 22px;
}

.pwa-modal-header {
    display: flex;
    gap: 16px;
    align-items: center;
    margin-bottom: 20px;
    padding-right: 32px;
}

.pwa-modal-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg, 12px);
    background: var(--primary, #a52a23);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(165, 42, 35, 0.25);
}

.pwa-modal-header h2 {
    margin: 0 0 4px 0;
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-main, #0f172a);
    letter-spacing: -0.01em;
}

.pwa-modal-subtitle {
    margin: 0;
    font-size: 0.88rem;
    color: var(--text-light, #64748b);
    line-height: 1.4;
}

.pwa-tabs {
    display: flex;
    gap: 6px;
    margin-bottom: 20px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border, #e2e8f0);
    overflow-x: auto;
}

.pwa-tab-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    border-radius: var(--radius-pill, 30px);
    border: 1px solid transparent;
    background: transparent;
    color: var(--text-light, #64748b);
    font-size: 0.88rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    min-height: 38px;
}

.pwa-tab-btn:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--text-main, #0f172a);
}

.pwa-tab-btn.active {
    background: var(--primary, #a52a23);
    color: #ffffff;
    border-color: var(--primary, #a52a23);
    box-shadow: 0 2px 8px rgba(165, 42, 35, 0.25);
}

.pwa-tab-panel {
    display: none;
}

.pwa-tab-panel.active {
    display: block;
    animation: fadeInModalTab 0.25s ease forwards;
}

@keyframes fadeInModalTab {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.pwa-steps {
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-bottom: 20px;
}

.pwa-step {
    display: flex;
    gap: 14px;
    align-items: flex-start;
}

.pwa-step-num {
    width: 28px;
    height: 28px;
    border-radius: var(--radius-full, 50%);
    background: var(--badge-bg, #fee2e1);
    color: var(--primary, #a52a23);
    font-size: 0.88rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.pwa-step-body {
    flex: 1;
    font-size: 0.92rem;
    line-height: 1.45;
    color: var(--text-main, #0f172a);
}

.pwa-step-body p {
    margin: 0 0 6px 0;
}

.pwa-badge-action {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: var(--radius-md, 8px);
    background: rgba(0, 0, 0, 0.05);
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-main, #0f172a);
    border: 1px solid var(--border, #e2e8f0);
}

.pwa-inline-chip {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.06);
    font-size: 0.82rem;
    font-weight: 600;
}

.pwa-tip {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-lg, 12px);
    background: rgba(165, 42, 35, 0.08);
    border-left: 4px solid var(--primary, #a52a23);
    margin-bottom: 20px;
    font-size: 0.86rem;
    color: var(--text-main, #0f172a);
    line-height: 1.4;
}

.pwa-tip svg {
    flex-shrink: 0;
    color: var(--primary, #a52a23);
}

.pwa-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

.pwa-modal-actions .btn {
    min-width: 130px;
    justify-content: center;
}

/* Dark Mode Overrides */
body.dark .pwa-modal-header h2 {
    color: #f8fafc;
}

body.dark .pwa-modal-subtitle {
    color: #94a3b8;
}

body.dark .pwa-tab-btn {
    color: #94a3b8;
}

body.dark .pwa-tab-btn:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #f8fafc;
}

body.dark .pwa-tab-btn.active {
    background: var(--primary, #cc362d);
    color: #ffffff;
    border-color: var(--primary, #cc362d);
}

body.dark .pwa-step-body {
    color: #e2e8f0;
}

body.dark .pwa-step-num {
    background: var(--badge-bg, #7f1d1d);
    color: var(--badge-text, #fca5a5);
}

body.dark .pwa-badge-action {
    background: rgba(255, 255, 255, 0.08);
    border-color: #334155;
    color: #f8fafc;
}

body.dark .pwa-inline-chip {
    background: rgba(255, 255, 255, 0.12);
    color: #f8fafc;
}

body.dark .pwa-tip {
    background: rgba(204, 54, 45, 0.18);
    border-left-color: var(--primary, #cc362d);
    color: #e2e8f0;
}

body.dark .pwa-tip svg {
    color: var(--primary, #cc362d);
}
