/**
 * Settings UI - Design Professionnel et Sobre
 * Composants réutilisables pour les modals de paramètres
 */

/* ============================================
   SETTINGS OVERLAY & PANEL
   ============================================ */

/* Page plein écran (pas un modal) */
.settings-overlay {
    position: fixed;
    inset: 0;
    background: #0d1117;
    z-index: 9998;
    display: none;
    justify-content: center;
    align-items: stretch;
    overflow: hidden;
    animation: settingsFadeIn 0.2s ease-out;
}

.settings-overlay.active {
    display: flex;
}

/* Focus visible — navigation clavier / manette */
.settings-overlay button:focus,
.settings-overlay input:focus,
.settings-overlay select:focus,
.settings-overlay summary:focus,
.settings-overlay [tabindex]:focus {
    outline: 2px solid rgba(255, 255, 255, 0.85);
    outline-offset: 2px;
}

.settings-panel {
    position: relative; /* ancre la sous-page (sons individuels) en absolute */
    background: transparent;
    border: none;
    border-radius: 0;
    width: 100%;
    max-width: 820px;
    height: 100vh;
    max-height: none;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: none;
    animation: settingsSlideUp 0.3s ease-out;
}

/* ============================================
   HEADER
   ============================================ */

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    background: rgba(255, 255, 255, 0.02);
}

.settings-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #f0f6fc;
    letter-spacing: -0.3px;
}

.settings-close {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: #8b949e;
    font-size: 20px;
    cursor: pointer;
    border-radius: 8px;
    transition: all 0.15s ease;
}

.settings-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #f0f6fc;
}

/* ============================================
   BODY & SECTIONS
   ============================================ */

.settings-body {
    padding: 16px 24px 24px;
    overflow-y: auto;
    flex: 1;
}

.settings-section {
    padding: 20px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}

.settings-section:first-child {
    padding-top: 8px;
}

.settings-section:last-child {
    border-bottom: none;
    padding-bottom: 8px;
}

.settings-section-title {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 0 16px 0;
    font-size: 13px;
    font-weight: 600;
    color: #8b949e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.settings-section-icon {
    display: inline-flex;
    align-items: center;
    color: var(--text-secondary);
}

.settings-section-icon svg {
    width: 16px;
    height: 16px;
}

/* ============================================
   SLIDERS (VOLUME)
   ============================================ */

.settings-slider-group {
    margin-bottom: 16px;
}

.settings-slider-group:last-child {
    margin-bottom: 0;
}

.settings-slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.settings-slider-label {
    font-size: 14px;
    color: #c9d1d9;
    font-weight: 500;
}

.settings-slider-value {
    font-family: var(--font-mono);
    font-size: 14px;
    font-weight: 700;
    color: var(--text-primary);
    font-variant-numeric: tabular-nums;
    min-width: 40px;
    text-align: right;
}

.settings-slider-value.master {
    color: var(--text-primary);
}

.settings-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    border-radius: 3px;
    background: #21262d;
    outline: none;
    cursor: pointer;
    transition: background 0.15s ease;
}

.settings-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #58a6ff;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(88, 166, 255, 0.3);
    transition: all 0.15s ease;
}

.settings-slider::-webkit-slider-thumb:hover {
    transform: scale(1.1);
    box-shadow: 0 2px 12px rgba(88, 166, 255, 0.5);
}

.settings-slider::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #58a6ff;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(88, 166, 255, 0.3);
}

.settings-slider.master::-webkit-slider-thumb {
    background: #58a6ff;
    box-shadow: 0 2px 8px rgba(240, 136, 62, 0.3);
}

.settings-slider.master::-moz-range-thumb {
    background: #58a6ff;
    box-shadow: 0 2px 8px rgba(240, 136, 62, 0.3);
}

/* ============================================
   BUTTONS
   ============================================ */

.settings-btn-group {
    display: flex;
    gap: 10px;
    margin-top: 12px;
}

.settings-btn {
    flex: 1;
    padding: 10px 16px;
    background: #21262d;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #c9d1d9;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.settings-btn:hover {
    background: #30363d;
    border-color: rgba(255, 255, 255, 0.15);
}

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

.settings-btn.primary {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(255, 255, 255, 0.2);
    color: var(--text-primary);
}

.settings-btn.primary:hover {
    background: rgba(255, 255, 255, 0.14);
    border-color: rgba(255, 255, 255, 0.3);
}

/* ============================================
   TOGGLE SWITCH
   ============================================ */

.settings-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
}

.settings-toggle-label {
    font-size: 14px;
    color: #c9d1d9;
    font-weight: 500;
}

.settings-toggle {
    position: relative;
    width: 44px;
    height: 24px;
}

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

.settings-toggle-track {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #21262d;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    transition: all 0.2s ease;
}

.settings-toggle-track::before {
    content: "";
    position: absolute;
    height: 18px;
    width: 18px;
    left: 2px;
    bottom: 2px;
    background: #8b949e;
    border-radius: 50%;
    transition: all 0.2s ease;
}

.settings-toggle input:checked + .settings-toggle-track {
    background: rgba(88, 166, 255, 0.2);
    border-color: #58a6ff;
}

.settings-toggle input:checked + .settings-toggle-track::before {
    transform: translateX(20px);
    background: #58a6ff;
}

/* ============================================
   LANGUAGE SELECTOR
   ============================================ */

.settings-lang-group {
    display: flex;
    gap: 10px;
}

.settings-lang-btn {
    flex: 1;
    padding: 12px 16px;
    background: #21262d;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #8b949e;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.settings-lang-btn:hover {
    background: #30363d;
    color: #c9d1d9;
}

.settings-lang-btn.active {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.35);
    color: var(--text-primary);
}

/* ============================================
   KEYBOARD SHORTCUTS CARD
   ============================================ */

.settings-shortcuts-card {
    background: #161b22;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
    padding: 14px 16px;
    margin-bottom: 10px;
}

.settings-shortcuts-card:last-child {
    margin-bottom: 0;
}

.settings-shortcuts-title {
    font-size: 13px;
    font-weight: 600;
    color: #c9d1d9;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-shortcuts-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.settings-shortcut-item {
    font-size: 13px;
    color: #8b949e;
    display: flex;
    align-items: center;
    gap: 8px;
}

.settings-kbd {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 24px;
    height: 22px;
    padding: 0 6px;
    background: #0d1117;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    font-family: var(--font-mono, 'SF Mono', 'Consolas', monospace);
    font-size: 11px;
    font-weight: 500;
    color: #c9d1d9;
}

/* Indicateurs de cubes : couleurs conservées (sémantiques = quel cube) */
.settings-kbd.red { color: #f87171; }
.settings-kbd.blue { color: #60a5fa; }
.settings-kbd.green { color: #4ade80; }
.settings-kbd.violet { color: #c084fc; }

/* ============================================
   DETAILS/ACCORDION
   ============================================ */

/* Bouton d'ouverture de la sous-page (sons individuels) */
.settings-subpage-open {
    width: 100%;
    margin-top: 12px;
    justify-content: space-between;
}

.settings-subpage-chevron {
    display: inline-flex;
    align-items: center;
    color: var(--text-secondary);
}

.settings-subpage-chevron svg {
    width: 16px;
    height: 16px;
}

/* Sous-page : couvre le panneau (header retour + corps scrollable) */
.settings-subpage {
    position: absolute;
    inset: 0;
    z-index: 5;
    background: #0d1117;
    display: flex;
    flex-direction: column;
    animation: settingsSlideUp 0.25s ease-out;
}

.settings-subpage[hidden] {
    display: none;
}

/* ============================================
   SCROLLBAR
   ============================================ */

.settings-body::-webkit-scrollbar {
    width: 8px;
}

.settings-body::-webkit-scrollbar-track {
    background: transparent;
}

.settings-body::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.settings-body::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.15);
}

/* Firefox */
.settings-body {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes settingsFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes settingsSlideUp {
    from { 
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============================================
   ACCOUNT SECTION
   ============================================ */

.settings-account-status {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #161b22;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
}

.settings-account-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #58a6ff 0%, #3b82f6 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: white;
    font-weight: 600;
}

.settings-account-info {
    flex: 1;
}

.settings-account-name {
    font-size: 14px;
    font-weight: 600;
    color: #f0f6fc;
}

.settings-account-email {
    font-size: 12px;
    color: #8b949e;
    margin-top: 2px;
}

/* ============================================
   HELPER TEXT
   ============================================ */

.settings-helper {
    font-size: 12px;
    color: #6e7681;
    margin-top: 8px;
    display: flex;
    align-items: flex-start;
    gap: 6px;
}

.settings-helper-icon {
    flex-shrink: 0;
}

/* Changement de mot de passe */
.settings-password-card {
    margin: 0 0 16px;
    padding: 16px;
    background: #161b22;
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 10px;
}

.settings-password-title {
    margin: 0 0 12px;
    color: #f0f6fc;
    font-size: 14px;
    font-weight: 600;
}

.settings-password-input {
    width: 100%;
    box-sizing: border-box;
    margin-bottom: 10px;
    padding: 11px 12px;
    color: #f0f6fc;
    background: #0d1117;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 7px;
}

.settings-password-input:focus {
    outline: none;
    border-color: #58a6ff;
}

.settings-password-hint {
    margin: 0 0 12px;
    color: #8b949e;
    font-size: 12px;
}

.settings-password-submit {
    width: 100%;
    padding: 11px 12px;
    color: #ffffff;
    background: #2563eb;
    border: 0;
    border-radius: 7px;
    cursor: pointer;
    font-weight: 600;
}

.settings-password-submit:disabled {
    cursor: wait;
    opacity: 0.55;
}

.settings-password-message {
    min-height: 18px;
    margin: 10px 0 0;
    font-size: 12px;
}

.settings-password-message[data-state="success"] { color: #8fe3a0; }
.settings-password-message[data-state="error"] { color: #ff8f8f; }

/* ============================================
   RESPONSIVE
   ============================================ */

@media (max-width: 480px) {
    .settings-panel {
        max-width: 100%;
        max-height: 100%;
        border-radius: 0;
    }
    
    .settings-header {
        padding: 16px 20px;
    }
    
    .settings-body {
        padding: 12px 20px 20px;
    }
    
    .settings-lang-group {
        flex-direction: column;
    }
}
