/* Variables CSS para Settings */
:root {
    --settings-bg: #f8f9fa;
    --card-bg: #ffffff;
    --text-primary: #0056A4;
    --text-secondary: #6c757d;
    --border-color: #e0e0e0;
    --shadow-light: 0 2px 10px rgba(0, 0, 0, 0.1);
    --primary-color: #0056A4;
    --danger-color: #dc3545;
}

/* Tema oscuro - paleta unificada (estilo login), sin negros */
[data-theme="dark"] {
    --settings-bg: #111827;
    --card-bg: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border-color: #334155;
    --shadow-light: 0 2px 12px rgba(0, 0, 0, 0.25);
    --primary-color: #0056A4;
    --danger-color: #ef4444;
}

[data-theme="dark"] .settings-section {
    background: #1e293b;
    border-color: #334155;
}

[data-theme="dark"] .settings-header {
    background: linear-gradient(135deg, #0056A4 0%, #003E78 45%, #0f172a 100%) !important;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 4px 28px rgba(0, 86, 164, 0.45), 0 2px 8px rgba(0, 0, 0, 0.25);
}

/* Back: mismo tono que el título; hover/active alineados con Home (.home-header-icon-btn) */
[data-theme="dark"] .settings-header .back-button:hover {
    background: rgba(255, 255, 255, 0.12) !important;
    color: var(--app-header-title-color) !important;
}

[data-theme="dark"] .settings-header .back-button:active {
    background: rgba(255, 255, 255, 0.18) !important;
}

/* Contenedor principal */
.settings-container {
    width: 100vw;
    max-width: 100%;
    min-height: 100vh;
    background: var(--settings-bg);
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* overflow-x:hidden recortaba cabeceras full-width anteriores; aquí ocultaba el área del atrás */
    overflow-x: visible;
}

/* Header: alto/título alineados con --app-header-*.
   NO usar --app-header-pad-x aquí: es calc(50vw - 50% + …) para barras a todo el ancho;
   dentro de .settings-container (max 800px centrado) ese cálculo rompe el padding y en
   modo claro parece que “no hay” botón atrás (área útil ~0 o contenido recortado). */
.settings-header {
    width: 100%;
    max-width: 100%;
    margin-left: 0;
    margin-right: 0;
    box-sizing: border-box;
    padding-left: max(var(--app-header-pad-x-page, 1rem), env(safe-area-inset-left, 0px));
    padding-right: max(var(--app-header-pad-x-page, 1rem), env(safe-area-inset-right, 0px));
    padding-top: var(--app-header-pad-top);
    padding-bottom: var(--app-header-pad-bottom);
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    gap: var(--app-header-row-gap);
    border-radius: 0;
    background: var(--app-header-surface-bg) !important;
    box-shadow: var(--app-header-surface-shadow) !important;
    border-bottom: var(--app-header-surface-border);
    min-height: calc(var(--app-header-title-size) * 1.25 + var(--app-header-pad-top) + var(--app-header-pad-bottom));
}

.settings-header .back-button {
    flex-shrink: 0;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    color: #0b3f70 !important;
    padding: 0.35rem 0.6rem 0.35rem 0 !important;
    min-width: 2.75rem !important;
    min-height: 2.75rem !important;
    width: auto !important;
    height: auto !important;
    font-size: 1rem !important;
    line-height: 1 !important;
    align-self: center !important;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.settings-header .back-button i {
    font-size: 1.4rem;
    line-height: 1;
    color: inherit;
}

.settings-header .back-button:hover {
    background: rgba(0, 86, 164, 0.08) !important;
    border: none !important;
    box-shadow: none !important;
    transform: none !important;
    color: #083a6d !important;
}

.settings-header .back-button:active {
    background: rgba(0, 86, 164, 0.14) !important;
}

.settings-header .back-button:focus-visible {
    outline: 2px solid rgba(0, 86, 164, 0.45);
    outline-offset: 2px;
}

[data-theme="dark"] .settings-header .back-button:focus-visible {
    outline-color: rgba(248, 250, 252, 0.45);
}

[data-theme="dark"] .settings-header .back-button {
    color: #f8fafc !important;
}

[data-theme="dark"] .settings-header .back-button:hover {
    color: #ffffff !important;
}

.settings-title {
    font-size: var(--app-header-title-size) !important;
    font-weight: var(--app-header-title-weight);
    color: var(--app-header-title-color) !important;
    margin: 0;
    letter-spacing: 0.02em;
    text-shadow: none;
    line-height: 1.25;
}

/* Content */
.settings-content {
    flex: 1;
    width: 100%;
    padding: 1rem;
    overflow-x: hidden;
    overflow-y: auto;
    box-sizing: border-box;
}

.settings-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: var(--shadow-light);
    border: 1px solid var(--border-color);
    width: 100%;
    box-sizing: border-box;
}

.section-title {
    font-size: 1.2rem;
    color: var(--text-primary);
    margin: 0 0 1rem 0;
    font-weight: 600;
}

/* Theme Options */
.theme-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.theme-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.theme-option:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}

.theme-option.active {
    border-color: var(--primary-color);
    background: rgba(0, 86, 164, 0.08);
}

[data-theme="dark"] .theme-option.active {
    background: rgba(59, 130, 246, 0.12);
}

.theme-preview {
    width: 60px;
    height: 40px;
    border-radius: 6px;
    border: 2px solid var(--border-color);
}

.theme-preview.light-theme {
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
}

.theme-preview.dark-theme {
    background: linear-gradient(135deg, #1e2433 0%, #111827 100%);
}

.theme-option span {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* User Info */
.user-info {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-color);
}

.info-item:last-child {
    border-bottom: none;
}

.info-item .label {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
}

.info-item .value {
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
}

/* Notificaciones / Sonido */
.notif-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.notif-info {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    flex: 1;
    min-width: 0;
}

.notif-icon {
    width: 42px;
    height: 42px;
    flex-shrink: 0;
    background: linear-gradient(135deg, rgba(0, 86, 164, 0.12), rgba(0, 112, 208, 0.18));
    color: var(--primary-color);
    border-radius: 10px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 1.05rem;
}

[data-theme="dark"] .notif-icon {
    background: rgba(59, 130, 246, 0.18);
    color: #93c5fd;
}

.notif-text {
    display: flex;
    flex-direction: column;
    gap: 0.18rem;
    min-width: 0;
}

.notif-title {
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.98rem;
}

.notif-desc {
    color: var(--text-secondary);
    font-size: 0.82rem;
    line-height: 1.35;
}

.notif-switch {
    width: 52px;
    height: 28px;
    border-radius: 999px;
    border: none;
    cursor: pointer;
    position: relative;
    transition: background 0.22s ease;
    flex-shrink: 0;
    padding: 0;
}

.notif-switch.off {
    background: #cbd5e1;
}

[data-theme="dark"] .notif-switch.off {
    background: #334155;
}

.notif-switch.on {
    background: linear-gradient(135deg, #16a34a, #22c55e);
}

.notif-switch-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: #ffffff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.18);
    transition: transform 0.22s ease;
}

.notif-switch.on .notif-switch-thumb {
    transform: translateX(24px);
}

.notif-test-btn {
    margin-top: 0.85rem;
    width: 100%;
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--primary-color);
    border-radius: 8px;
    padding: 0.6rem;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all 0.18s ease;
}

.notif-test-btn:hover {
    background: rgba(0, 86, 164, 0.06);
    border-color: var(--primary-color);
}

[data-theme="dark"] .notif-test-btn:hover {
    background: rgba(59, 130, 246, 0.10);
}

/* Logout Button */
.logout-button {
    width: 100%;
    background: var(--danger-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 1rem;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.logout-button:hover {
    background: #c82333;
    transform: translateY(-1px);
    box-shadow: var(--shadow-light);
}

.logout-icon {
    font-size: 1.2rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .settings-header {
        padding-left: var(--app-header-pad-x-page);
        padding-right: var(--app-header-pad-x-page);
        padding-top: var(--app-header-pad-top);
        padding-bottom: var(--app-header-pad-bottom);
        margin: 0;
    }

    .settings-content {
        padding: 0.75rem;
    }
    
    .settings-section {
        padding: 1rem;
    }
    
    .theme-options {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .settings-content {
        padding: 0.5rem;
    }
    
    .settings-section {
        padding: 0.75rem;
    }
    
    .section-title {
        font-size: 1.1rem;
    }
}

/* Tablet landscape — mismo estándar de header (sin cambiar tamaño de título) */
@media (min-width: 769px) and (max-width: 1180px) and (orientation: landscape) {
    .settings-header {
        padding-top: var(--app-header-pad-y);
        padding-bottom: var(--app-header-pad-y);
        padding-left: max(var(--app-header-pad-x-page, 1.25rem), env(safe-area-inset-left, 0px));
        padding-right: max(var(--app-header-pad-x-page, 1.25rem), env(safe-area-inset-right, 0px));
        margin-bottom: 1.5rem;
    }
}

/* Estilos para escritorio */
@media (min-width: 769px) {
    .settings-container {
        max-width: 800px;
        margin: 0 auto;
        padding: 0 2rem;
    }

    .settings-header {
        padding-left: max(var(--app-header-pad-x-page, 1.25rem), env(safe-area-inset-left, 0px));
        padding-right: max(var(--app-header-pad-x-page, 1.25rem), env(safe-area-inset-right, 0px));
        padding-top: var(--app-header-pad-y);
        padding-bottom: var(--app-header-pad-y);
        margin-bottom: 2rem;
    }
    
    .settings-content {
        padding: 0 2rem 2rem 2rem;
    }
    
    .settings-section {
        padding: 2rem;
        border-radius: 16px;
        margin-bottom: 1.5rem;
    }
    
    .section-title {
        font-size: 1.4rem;
        margin-bottom: 1.5rem;
    }
    
    .theme-options {
        grid-template-columns: 1fr 1fr;
        gap: 1.5rem;
    }
    
    .theme-option {
        padding: 1.5rem;
        border-radius: 12px;
    }
    
    .theme-preview {
        width: 80px;
        height: 50px;
    }
    
    .theme-option span {
        font-size: 1rem;
    }
    
    .info-item {
        padding: 1rem 0;
    }
    
    .info-item .label {
        font-size: 1rem;
    }
    
    .info-item .value {
        font-size: 1rem;
    }
    
    .logout-button {
        padding: 1.25rem;
        font-size: 1.1rem;
        border-radius: 12px;
    }
}

/* Estilos para pantallas muy grandes */
@media (min-width: 1200px) {
    .settings-container {
        max-width: 1400px;
    }
    
    .settings-section {
        padding: 2.5rem;
    }
}
