/* --- IMPOSTAZIONI OVERLAY --- */
.settings-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 3000; /* Sopra tutto */
    display: flex; align-items: center; justify-content: center;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.2s ease;
}

.settings-window {
    width: 90vw;
    height: 90vh;
    max-width: 900px;
    max-height: 600px;
    background: #1f1f1f;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.8);
    display: flex;
    overflow: hidden;
    border: 1px solid #333;
    position: relative;
}

/* Sidebar Categorie */
.settings-sidebar {
    width: 280px;
    background: #141414;
    border-right: 1px solid #333;
    display: flex; flex-direction: column;
}

.settings-header {
    padding: 25px;
    font-size: 1.375rem; font-weight: bold; color: white;
    border-bottom: 1px solid #333;
    letter-spacing: 1px;
}

.settings-nav {
    flex: 1; overflow-y: auto; padding: 15px 0;
}

.settings-nav-btn {
    width: 100%; text-align: left; padding: 12px 20px;
    background: none; border: none; color: #aaa;
    cursor: pointer; font-size: 1rem; transition: all 0.2s;
    font-weight: 500;
}
.settings-nav-btn:hover, .settings-nav-btn:focus {
    background: rgba(255,255,255,0.08); color: white; outline: none;
}
.settings-nav-btn.active {
    background: rgba(33, 150, 243, 0.15); color: #2196F3; border-left: 4px solid #2196F3;
}

/* Contenuto Principale */
.settings-content {
    flex: 1; padding: 20px 30px; overflow-y: auto;
    position: relative;
    background: #1f1f1f;
}

.settings-title {
    font-size: 1.75rem; color: white; margin: 0 0 30px 0; 
    border-bottom: 1px solid #333; padding-bottom: 15px;
}

.setting-item {
    display: flex; justify-content: space-between; align-items: center;
    padding: 12px 15px; background: rgba(255,255,255,0.03);
    margin-bottom: 8px; border-radius: 8px; cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    border: 1px solid transparent;
}

/* --- FOCUS PERSONALIZZATO (Azzurrino, no zoom, no bordo rosso) --- */
.setting-item:focus, .settings-nav-btn:focus, .back-btn:focus {
    outline: none !important;
    box-shadow: none !important;
    background-color: rgba(33, 150, 243, 0.5) !important; /* Azzurrino */
    transform: none !important;
    border-color: rgba(33, 150, 243, 0.5);
}

.setting-item:hover, .settings-nav-btn:hover {
    background: rgba(255,255,255,0.08);
}

.setting-label { 
    color: #eee; font-size: 1rem; font-weight: 500; 
    flex-shrink: 0; /* Non far restringere l'etichetta */
}
.setting-control {
    min-width: 0; /* Permette al figlio di essere troncato */
    flex-grow: 1;
    display: flex;
    justify-content: flex-end;
    align-items: center;
}
.setting-value-text {
    color: #888; font-size: 0.875rem;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    text-align: right;
}
.setting-value-input {
    background: transparent;
    border: 1px solid transparent;
    color: #888;
    font-size: 0.875rem;
    text-align: right;
    width: 100%;
    outline: none;
    padding: 2px 5px;
    border-radius: 4px;
}
.setting-value-input:not(:disabled) {
    background: #333;
    border-color: #555;
    color: white;
    cursor: text;
}

.value-display {
    color: white; font-weight: bold; font-size: 1rem;
}

/* --- CONTROLLI UI --- */

/* Toggle Switch */
.toggle-switch {
    width: 50px; height: 26px;
    background: #444;
    border-radius: 13px;
    position: relative;
    transition: background-color 0.2s;
}
.toggle-switch.active {
    background: #2196F3;
}
.toggle-knob {
    width: 20px; height: 20px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 3px; left: 3px;
    transition: transform 0.2s cubic-bezier(0.4, 0.0, 0.2, 1);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
.toggle-switch.active .toggle-knob {
    transform: translateX(24px);
}

/* Slider */
.slider-container {
    display: flex; align-items: center; gap: 15px;
    min-width: 200px; justify-content: flex-end;
}
.slider-value {
    color: #2196F3; font-weight: bold; min-width: 30px; text-align: right;
}
.slider-track {
    width: 120px; height: 6px;
    background: #444;
    border-radius: 3px;
    position: relative;
    overflow: hidden;
}
.slider-fill {
    height: 100%;
    background: #2196F3;
    border-radius: 3px;
}
/* Evidenzia lo slider quando la riga ha il focus */
.setting-item:focus .slider-track {
    background: #555;
}
.setting-item:focus .slider-fill {
    background: #64b5f6;
}

/* Finestra Sovrapposta (Nested) */
.nested-settings-overlay {
    position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: #1f1f1f;
    z-index: 10;
    display: flex; flex-direction: column;
    animation: slideInRight 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes slideInRight {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

.nested-header {
    padding: 20px 30px; border-bottom: 1px solid #333;
    display: flex; align-items: center; gap: 20px; background: #141414;
}
.back-btn {
    background: none; border: none; color: white; font-size: 1.5rem; cursor: pointer;
    padding: 5px 10px; border-radius: 4px;
}
.back-btn:hover { background: rgba(255,255,255,0.1); }
.nested-title { margin: 0; font-size: 1.25rem; color: white; }

@media (max-width: 950px), (max-height: 650px) {
    .settings-window {
        width: 100vw;
        height: 100vh;
        max-width: 100vw;
        max-height: 100vh;
        border-radius: 0;
    }

    .settings-sidebar {
        width: 220px;
    }

    .settings-nav-btn {
        padding: 15px 20px;
        font-size: 0.9375rem;
    }

    .settings-content {
        padding: 25px;
    }
    .setting-item {
        padding: 15px;
    }
}
