/* ==================== HEADER MODERNE ==================== */
.header-modern {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-sm) var(--spacing-md);
    background: var(--header-bg);
    box-shadow: var(--header-shadow);
    position: relative;
    z-index: var(--z-header);
    height: var(--header-height);
    flex-shrink: 0;
}

.header-logo img {
    height: 40px;
    display: block;
}

.header-clef {
    display: flex;
    gap: var(--spacing-sm);
}

.clef-btn {
    background: var(--color-gray-100);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    padding: var(--spacing-xs) 12px;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.clef-btn:hover {
    background: var(--color-gray-200);
}

.clef-btn.active,
.clef-btn.highLight {
    background: var(--color-primary-light);
    border-color: var(--color-primary);
}

.clef-btn img {
    height: 28px;
    display: block;
}

/* Options rapides dans le header */
.header-options {
    display: flex;
    align-items: center;
    gap: 20px;
}

.header-option {
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.header-option img {
    height: 28px;
    width: auto;
    opacity: 0.7;
}

.header-option:has(input:checked) img {
    opacity: 1;
}

/* Select compact dans le header */
.header-option select {
    padding: 4px 8px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--surface-color);
    font-size: 0.85rem;
    cursor: pointer;
    max-width: 120px;
}

.header-option select:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Switch toggle moderne */
.switch {
    position: relative;
    display: inline-block;
    width: var(--switch-width);
    height: var(--switch-height);
    flex-shrink: 0;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.switch-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--switch-bg);
    transition: var(--transition-slow);
    border-radius: var(--radius-pill);
}

.switch-slider:before {
    position: absolute;
    content: "";
    height: var(--switch-thumb-size);
    width: var(--switch-thumb-size);
    left: 3px;
    bottom: 3px;
    background-color: var(--color-white);
    transition: var(--transition-slow);
    border-radius: var(--radius-round);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.switch input:checked + .switch-slider {
    background-color: var(--switch-bg-active);
}

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

.switch input:focus + .switch-slider {
    box-shadow: 0 0 1px var(--color-success);
}

/* Indicateur MIDI */
.midi-indicator {
    padding-left: var(--spacing-sm);
}

.midi-indicator img {
    height: 24px;
    opacity: 0.5;
    transition: opacity var(--transition-normal);
}

.midi-indicator img[src*="vert"] {
    opacity: 1;
}

.header-actions {
    display: flex;
    gap: var(--spacing-sm);
}

.btn-start,
.btn-stop {
    padding: var(--btn-padding-y) var(--btn-padding-x);
    border: none;
    border-radius: var(--btn-radius);
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.btn-start {
    background: var(--color-success);
    color: var(--color-white);
}

.btn-start:hover {
    background: var(--color-success-dark);
}

.btn-stop {
    background: var(--color-error);
    color: var(--color-white);
}

.btn-stop:hover {
    background: var(--color-error-dark);
}

/* Bouton aide */
.btn-help {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 2px solid var(--color-primary);
    border-radius: var(--radius-round);
    background: var(--color-white);
    color: var(--color-primary);
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-bold);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.btn-help:hover {
    background: var(--color-primary);
    color: var(--color-white);
}

/* Bouton hamburger */
.menu-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: none;
    border: none;
    cursor: pointer;
    padding: var(--spacing-sm);
    border-radius: var(--radius-md);
    transition: background var(--transition-normal);
    color: var(--color-text);
}

.menu-toggle:hover {
    background: var(--color-gray-100);
}

.menu-toggle svg {
    width: 24px;
    height: 24px;
    transition: transform var(--transition-normal);
}

.menu-toggle:hover svg {
    transform: rotate(30deg);
}

/* ==================== DRAWER ==================== */
.drawer-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-slow);
    z-index: var(--z-overlay);
}

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

.drawer {
    position: fixed;
    top: 0;
    right: -320px;
    width: var(--drawer-width);
    max-width: 85vw;
    height: 100%;
    background: var(--drawer-bg);
    box-shadow: -4px 0 16px rgba(0, 0, 0, 0.1);
    transition: right var(--transition-slow);
    z-index: var(--z-drawer);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.drawer.active {
    right: 0;
}

.drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) 20px;
    border-bottom: 1px solid var(--color-border-light);
    flex-shrink: 0;
}

.drawer-header h2 {
    margin: 0;
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
}

.drawer-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--color-text-secondary);
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color var(--transition-normal);
}

.drawer-close:hover {
    color: var(--color-text);
}

.drawer-content {
    flex: 1;
    overflow-y: auto;
    padding: var(--spacing-md) 20px;
}

/* ==================== SECTIONS ==================== */
.drawer-section {
    margin-bottom: var(--spacing-lg);
}

/* Navigation inter-modules */
.drawer-nav {
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--color-border-light);
}

/* Section Mon Parcours */
.drawer-journey,
.drawer-mode {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    padding-bottom: var(--spacing-md);
    border-bottom: 1px solid var(--color-border-light);
}

.journey-link {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-sm) var(--spacing-md);
    background: linear-gradient(135deg, #00d4ff 0%, #0066ff 100%);
    color: white;
    text-decoration: none;
    font-weight: var(--font-weight-semibold);
    border-radius: var(--radius-md);
    transition: all var(--transition-normal);
}

.journey-link:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 102, 255, 0.4);
}

.journey-icon {
    font-size: 1.2rem;
}

/* Toggle mode petit format */
.mode-toggle-small {
    display: flex;
    background: var(--color-gray-100);
    border-radius: var(--radius-md);
    padding: 3px;
    gap: 3px;
}

.mode-btn-small {
    flex: 1;
    padding: var(--spacing-xs) var(--spacing-sm);
    border: none;
    background: transparent;
    color: var(--color-text-muted);
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-medium);
    border-radius: calc(var(--radius-md) - 2px);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.mode-btn-small:hover {
    color: var(--color-text);
}

.mode-btn-small.active {
    background: var(--color-primary);
    color: white;
}

/* Sélecteur de module */
.module-selector {
    width: auto;
    min-width: 0;
    padding: var(--spacing-sm) 12px;
    border: 2px solid var(--color-primary);
    border-radius: var(--radius-md);
    background: var(--color-primary-light);
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold);
    color: var(--color-primary-dark);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.module-selector:hover {
    background: var(--color-primary);
    color: var(--color-white);
}

.module-selector:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

.drawer-section h3 {
    font-size: var(--font-size-sm);
    font-weight: var(--font-weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-muted);
    margin: 0 0 12px 0;
    padding-bottom: var(--spacing-sm);
    border-bottom: 1px solid var(--color-border-light);
}

/* Boutons langue */
.lang-buttons {
    display: flex;
    gap: var(--spacing-sm);
}

.lang-btn {
    flex: 1;
    padding: 10px;
    border: 2px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-white);
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.lang-btn:hover {
    border-color: var(--color-gray-400);
}

.lang-btn.active,
.lang-btn.highLight {
    background: var(--color-primary);
    border-color: var(--color-primary);
    color: var(--color-white);
}

/* Lignes de réglage */
.setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--color-gray-100);
}

.setting-row:last-child {
    border-bottom: none;
}

.setting-row label {
    font-size: var(--font-size-md);
    color: var(--color-text);
}

.setting-row select,
.setting-row input[type="number"] {
    padding: var(--spacing-sm) 12px;
    border: 1px solid var(--color-border);
    border-radius: 6px;
    font-size: var(--font-size-md);
    background: var(--color-white);
    min-width: 100px;
}

.setting-row input[type="number"] {
    width: 70px;
    text-align: center;
}

/* Toggle switch */
.setting-row input[type="checkbox"].toggle {
    appearance: none;
    -webkit-appearance: none;
    width: 48px;
    height: 26px;
    background: var(--color-border);
    border-radius: 13px;
    position: relative;
    cursor: pointer;
    transition: background var(--transition-slow);
}

.setting-row input[type="checkbox"].toggle::before {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: var(--color-white);
    border-radius: var(--radius-round);
    transition: transform var(--transition-slow);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.setting-row input[type="checkbox"].toggle:checked {
    background: var(--color-success);
}

.setting-row input[type="checkbox"].toggle:checked::before {
    transform: translateX(22px);
}

/* Toggle désactivé (mode guidé) */
.setting-row input[type="checkbox"].toggle:disabled,
.setting-row input[type="checkbox"].toggle.locked {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.setting-row input[type="checkbox"].toggle:disabled::before,
.setting-row input[type="checkbox"].toggle.locked::before {
    background: #ccc;
}

/* Boutons secondaires */
.btn-secondary {
    width: 100%;
    padding: 12px;
    margin-bottom: var(--spacing-sm);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: var(--color-white);
    font-size: var(--font-size-md);
    cursor: pointer;
    transition: all var(--transition-normal);
}

.btn-secondary:hover {
    background: var(--color-gray-100);
    border-color: var(--color-gray-400);
}

.btn-secondary:last-child {
    margin-bottom: 0;
}

/* MIDI status */
.midi-status img {
    height: 20px;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 768px) {
    .header-modern {
        padding: var(--spacing-sm) 12px;
        gap: var(--spacing-sm);
    }

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

    .clef-btn {
        padding: var(--spacing-xs) var(--spacing-sm);
    }

    .clef-btn img {
        height: 24px;
    }

    .header-options {
        gap: 12px;
    }

    .header-option {
        gap: 6px;
    }

    .header-option img {
        height: 24px;
    }

    .switch {
        width: 38px;
        height: 20px;
    }

    .switch-slider:before {
        height: 14px;
        width: 14px;
    }

    .switch input:checked + .switch-slider:before {
        transform: translateX(18px);
    }

    .btn-start,
    .btn-stop {
        padding: var(--spacing-sm) var(--spacing-md);
        font-size: var(--font-size-md);
    }

    .drawer {
        width: 280px;
    }
}

@media (max-width: 500px) {
    .header-clef {
        display: none;
    }

    .header-options {
        gap: var(--spacing-sm);
    }

    .header-option {
        gap: var(--spacing-xs);
    }

    .header-option img {
        height: 20px;
    }

    .switch {
        width: 34px;
        height: 18px;
    }

    .switch-slider:before {
        height: 12px;
        width: 12px;
        left: 3px;
        bottom: 3px;
    }

    .switch input:checked + .switch-slider:before {
        transform: translateX(16px);
    }

    .midi-indicator img {
        height: 20px;
    }

    .btn-start,
    .btn-stop {
        padding: 6px 12px;
        font-size: var(--font-size-sm);
    }
}

/* Slider row dans le drawer */
.slider-row {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
    max-width: 160px;
}

.drawer-slider {
    flex: 1;
    height: 8px;
}

.slider-value {
    font-size: 13px;
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
    min-width: 36px;
    text-align: right;
}

/* ==================== MODALE AIDE ==================== */
.help-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: var(--z-modal, 1000);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-slow);
}

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

.help-modal {
    width: 90%;
    height: 90%;
    max-width: 1200px;
    max-height: 90vh;
    background: var(--color-white);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.9);
    transition: transform var(--transition-slow);
}

.help-overlay.active .help-modal {
    transform: scale(1);
}

.help-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--spacing-md) var(--spacing-lg);
    border-bottom: 1px solid var(--color-border-light);
    background: var(--color-gray-50, #f9fafb);
    flex-shrink: 0;
}

.help-modal-header h2 {
    margin: 0;
    font-size: var(--font-size-xl);
    font-weight: var(--font-weight-semibold);
    color: var(--color-text);
}

.help-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    padding: 0;
    border: none;
    border-radius: var(--radius-round);
    background: transparent;
    color: var(--color-text-secondary);
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    transition: all var(--transition-normal);
}

.help-close:hover {
    background: var(--color-gray-100);
    color: var(--color-text);
}

.help-modal-content {
    flex: 1;
    overflow: hidden;
}

.help-modal-content iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Responsive modale aide */
@media (max-width: 768px) {
    .help-modal {
        width: 95%;
        height: 95%;
        border-radius: var(--radius-md);
    }

    .help-modal-header {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .help-modal-header h2 {
        font-size: var(--font-size-lg);
    }

    .help-close {
        width: 36px;
        height: 36px;
        font-size: 28px;
    }
}

@media (max-height: 500px) {
    .help-modal {
        width: 95%;
        height: 95%;
    }

    .help-modal-header {
        padding: var(--spacing-xs) var(--spacing-md);
    }

    .btn-help {
        width: 30px;
        height: 30px;
        font-size: var(--font-size-md);
    }
}

/* ==================== OVERRIDE ANCIEN STYLE ==================== */
/* Neutraliser l'ancien header */
header.header-modern {
    flex: none !important;
    width: 100%;
}

/* ==================== MODE GUIDÉ PÉDAGOGIQUE ==================== */

/* Barre indicateur mode guidé - sous le header, pleine largeur */
.guided-bar {
    display: none;
    position: fixed;
    top: var(--header-height, 56px); /* Sous le header */
    left: 0;
    right: 0;
    height: 30px;
    z-index: 98; /* Juste sous le header (z-header = 100) */
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 0 16px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    font-size: 13px;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s ease;
    white-space: nowrap;
    overflow: hidden;
}

.guided-bar:hover {
    background: linear-gradient(135deg, #5a6fd6 0%, #6a4190 100%);
}

.guided-bar-badge {
    font-weight: 600;
    padding: 2px 8px;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    font-size: 11px;
}

.guided-bar-info {
    font-weight: 500;
}

.guided-bar-rules {
    opacity: 0.85;
    font-size: 12px;
}

.guided-bar-back {
    margin-left: auto;
    opacity: 0.9;
    font-size: 12px;
}


/* Options verrouillées en mode guidé */
.drawer-option.locked {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}

.drawer-option.locked::after {
    content: '🔒';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 14px;
}

.setting-row.locked {
    opacity: 0.5;
    pointer-events: none;
}

.clef-btn:disabled,
.lang-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Slider tessiture verrouillé en mode guidé */
#slider.locked,
#slider[disabled] {
    opacity: 0.4;
    pointer-events: none;
    cursor: not-allowed;
}

#slider.locked .noUi-connect,
#slider[disabled] .noUi-connect {
    background: var(--text-disabled, #666);
}

#slider.locked .noUi-handle,
#slider[disabled] .noUi-handle {
    cursor: not-allowed;
    background: var(--bg-secondary, #444);
}

/* Notification de déblocage */
.unlock-notification {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.unlock-notification.visible {
    opacity: 1;
}

.unlock-content {
    text-align: center;
    color: white;
    animation: unlockPop 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes unlockPop {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.unlock-icon {
    font-size: 64px;
    margin-bottom: 16px;
    animation: unlockBounce 0.6s ease-in-out infinite alternate;
}

@keyframes unlockBounce {
    0% { transform: translateY(0); }
    100% { transform: translateY(-10px); }
}

.unlock-title {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    background: linear-gradient(90deg, #f59e0b, #fbbf24);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.unlock-subtitle {
    font-size: 18px;
    opacity: 0.8;
}

/* Responsive mode guidé */
@media (max-width: 768px) {
    .guided-bar {
        padding: 5px 10px;
        gap: 8px;
        font-size: 11px;
    }

    .guided-bar-badge {
        padding: 1px 6px;
        font-size: 10px;
    }

    .guided-bar-rules {
        font-size: 10px;
    }

    .guided-bar-back {
        font-size: 10px;
    }

    .unlock-icon {
        font-size: 48px;
    }

    .unlock-title {
        font-size: 22px;
    }

    .unlock-subtitle {
        font-size: 14px;
    }
}

/* Très petit écran : cacher les règles pour gagner de la place */
@media (max-width: 480px) {
    .guided-bar {
        gap: 6px;
        padding: 4px 8px;
    }

    .guided-bar-rules {
        display: none;
    }

    .guided-bar-back {
        font-size: 9px;
    }
}
