/**
 * Estilos del modal de Ajustes del Sistema (Perfil, Apariencia, Información, Cuenta).
 * Separado de dashboard.css para que el modal se vea igual en todas las páginas
 * (dashboard, horarios, etc.) cuando se inyecta desde el layout.
 */

/* Selector de alta especificidad para sobrescribir estilos generales de .modal-content */
#profileSettingsOverlay .profile-settings-modal,
#profileSettingsOverlay .modal-content.profile-settings-modal,
#layoutProfileSettingsWrap #profileSettingsOverlay .profile-settings-modal,
#layoutProfileSettingsWrap #profileSettingsOverlay .modal-content.profile-settings-modal,
.modal-content.profile-settings-modal {
    width: min(1200px, 96vw) !important;
    height: min(85vh, 92vh);
    max-height: 85vh;
    border-radius: 20px;
    box-shadow: 0 30px 60px rgba(0,0,0,0.3);
}

/* Mantener compatibilidad con selector original */
.profile-settings-modal {
    width: min(1200px, 96vw) !important;
    height: min(85vh, 92vh);
    max-height: 85vh;
    border-radius: 20px;
    box-shadow: 0 30px 60px rgba(0,0,0,0.3);
}

.profile-settings-modal .modal-body {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
    padding: 0;
    flex: 1;
    height: 100%;
}

/* Tabs: ocultar inactivos y mostrar activo (crítico para que se vea el contenido fuera de dashboard).
   Selector por ID para ganar a cualquier .tab-content genérico de otros CSS (dashboard, reportes, etc.). */
#profileSettingsOverlay .profile-settings-modal .tab-content,
#layoutProfileSettingsWrap #profileSettingsOverlay .profile-settings-modal .tab-content {
    display: none !important;
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
    padding: 24px;
}

#profileSettingsOverlay .profile-settings-modal .tab-content.active,
#layoutProfileSettingsWrap #profileSettingsOverlay .profile-settings-modal .tab-content.active {
    display: flex !important;
    flex-direction: column;
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
    animation: profileTabIn 0.22s cubic-bezier(0.2, 0.9, 0.2, 1);
}

@keyframes profileTabIn {
    from { opacity: 0; transform: translateX(10px); }
    to { opacity: 1; transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
    .profile-settings-modal .tab-content.active { animation: none; }
}

.profile-settings-modal .modal-header {
    padding: 20px 24px;
    border-bottom: 2px solid var(--bg-tertiary);
}

.profile-settings-modal .modal-header h3 {
    font-size: 1.4rem;
    font-weight: 700;
}

.profile-settings-modal .modal-tabs {
    display: flex;
    background: var(--bg-tertiary);
    border-radius: 12px;
    padding: 5px;
    margin: 4px 12px 20px;
    border: none;
    gap: 4px;
}

.profile-settings-modal .tab-btn {
    flex: 1;
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.2s ease;
    background: transparent;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
}

.profile-settings-modal .tab-btn.active {
    background: var(--bg-secondary);
    color: var(--primary);
    border: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.profile-settings-modal .info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 14px;
}

.profile-settings-modal .info-item {
    background: var(--bg-tertiary);
    border: none;
    padding: 12px 16px;
    transition: transform 0.2s ease;
    border-radius: var(--radius-md, 12px);
}

.profile-settings-modal .info-item:hover {
    transform: translateY(-2px);
    background: var(--bg-secondary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.profile-settings-modal .info-icon {
    background: var(--bg-secondary);
    width: 36px;
    height: 36px;
    font-size: 1rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.profile-settings-modal .modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.profile-settings-modal .action-btn {
    padding: 12px 24px;
    border-radius: 12px;
    font-size: 1.05rem;
    font-weight: 600;
}

/* Tema / Apariencia (scoped para el modal) */
.profile-settings-modal .theme-options {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.profile-settings-modal .theme-opt {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: 12px;
    padding: 12px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    transition: all 0.2s ease;
}

.profile-settings-modal .theme-opt:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.profile-settings-modal .theme-opt:hover {
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover, 0 4px 12px rgba(0,0,0,0.08));
}

.profile-settings-modal .theme-opt.active {
    border-color: var(--primary);
    background: var(--bg-tertiary);
}

.profile-settings-modal .theme-opt-header {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.profile-settings-modal .theme-opt-icon {
    width: 36px;
    height: 36px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--primary);
    flex: 0 0 auto;
}

.profile-settings-modal .theme-opt[data-theme-val="light"] .theme-opt-icon { color: #f59e0b; }
.profile-settings-modal .theme-opt[data-theme-val="dark"] .theme-opt-icon { color: #818cf8; }
.profile-settings-modal .theme-opt[data-theme-val="deep-dark"] .theme-opt-icon { color: #cbd5e1; }
.profile-settings-modal .theme-opt[data-theme-val="claude"] .theme-opt-icon { color: #d97706; }
.profile-settings-modal .theme-opt[data-theme-val="claude-dark"] .theme-opt-icon { color: #f59e0b; }
.profile-settings-modal .theme-opt[data-theme-val="aurora"] .theme-opt-icon { color: #22c55e; }
.profile-settings-modal .theme-opt[data-theme-val="cobalt"] .theme-opt-icon { color: #2563eb; }
.profile-settings-modal .theme-opt[data-theme-val="rose"] .theme-opt-icon { color: #ec4899; }

.profile-settings-modal .theme-opt-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.profile-settings-modal .theme-opt-title {
    font-size: 1.05rem;
    font-weight: 800;
    color: var(--text-primary);
    line-height: 1.2;
    letter-spacing: -0.2px;
}

.profile-settings-modal .theme-opt-subtitle {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-secondary);
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-settings-modal .theme-opt-check {
    margin-left: auto;
    width: 22px;
    height: 22px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex: 0 0 auto;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.profile-settings-modal .theme-opt-check i {
    font-size: 0.7rem;
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.profile-settings-modal .theme-opt.active .theme-opt-check {
    background: var(--primary);
    border-color: var(--primary);
}

.profile-settings-modal .theme-opt.active .theme-opt-check i {
    opacity: 1;
    transform: scale(1);
}

.profile-settings-modal .theme-preview {
    width: 100%;
    height: 50px;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.1);
}

.profile-settings-modal .theme-preview::before,
.profile-settings-modal .theme-preview::after {
    content: '';
    position: absolute;
}

.profile-settings-modal .theme-preview.light { background-color: #f8fafc; }
.profile-settings-modal .theme-preview.light::before { width: 30%; height: 100%; background: #ffffff; left: 0; }
.profile-settings-modal .theme-preview.light::after { width: 70%; height: 15%; background: #06b6d4; top: 8px; right: 4px; border-radius: 3px; }

.profile-settings-modal .theme-preview.dark { background-color: #0f172a; }
.profile-settings-modal .theme-preview.dark::before { width: 30%; height: 100%; background: #1e293b; left: 0; }
.profile-settings-modal .theme-preview.dark::after { width: 70%; height: 15%; background: #22d3ee; top: 8px; right: 4px; border-radius: 3px; }

.profile-settings-modal .theme-preview.deep-dark { background-color: #020617; }
.profile-settings-modal .theme-preview.deep-dark::before { width: 30%; height: 100%; background: #0f172a; left: 0; }
.profile-settings-modal .theme-preview.deep-dark::after { width: 70%; height: 15%; background: #818cf8; top: 8px; right: 4px; border-radius: 3px; }

.profile-settings-modal .theme-preview.claude { background-color: #f5f5f0; }
.profile-settings-modal .theme-preview.claude::before { width: 30%; height: 100%; background: #ffffff; left: 0; }
.profile-settings-modal .theme-preview.claude::after { width: 70%; height: 15%; background: #d97706; top: 8px; right: 4px; border-radius: 3px; }

.profile-settings-modal .theme-preview.claude-dark { background-color: #0b1220; }
.profile-settings-modal .theme-preview.claude-dark::before { width: 30%; height: 100%; background: #121a2b; left: 0; }
.profile-settings-modal .theme-preview.claude-dark::after { width: 70%; height: 15%; background: #f59e0b; top: 8px; right: 4px; border-radius: 3px; }

.profile-settings-modal .theme-preview.aurora { background: linear-gradient(135deg, #071a17 0%, #0b2d25 55%, #0b1220 100%); }
.profile-settings-modal .theme-preview.aurora::before { width: 30%; height: 100%; background: rgba(255,255,255,0.06); left: 0; }
.profile-settings-modal .theme-preview.aurora::after { width: 70%; height: 15%; background: linear-gradient(90deg, #22c55e 0%, #06b6d4 55%, #a78bfa 100%); top: 8px; right: 4px; border-radius: 3px; }

.profile-settings-modal .theme-preview.cobalt { background-color: #f1f7ff; }
.profile-settings-modal .theme-preview.cobalt::before { width: 30%; height: 100%; background: #ffffff; left: 0; }
.profile-settings-modal .theme-preview.cobalt::after { width: 70%; height: 15%; background: #2563eb; top: 8px; right: 4px; border-radius: 3px; }

.profile-settings-modal .theme-preview.rose { background-color: #fff1f5; }
.profile-settings-modal .theme-preview.rose::before { width: 30%; height: 100%; background: #ffffff; left: 0; }
.profile-settings-modal .theme-preview.rose::after { width: 70%; height: 15%; background: #ec4899; top: 8px; right: 4px; border-radius: 3px; }

/* Form (pestaña Perfil y Cuenta) */
.profile-settings-modal .form-group {
    margin-bottom: 1rem;
}

.profile-settings-modal .form-label {
    display: block;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.profile-settings-modal .form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md, 12px);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 1rem;
}

.profile-settings-modal .radio-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Cropper de foto */
.profile-settings-modal .profile-photo-section {
    display: grid;
    gap: 24px;
}

.profile-settings-modal .profile-photo-main {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 20px;
    align-items: center;
}

.profile-settings-modal #profilePhotoPreview {
    width: 200px;
    height: 200px;
    background: transparent;
    border: none;
    display: grid;
    place-items: center;
}

.profile-settings-modal #profilePhotoCropper {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    border: 3px solid var(--border-color);
    overflow: hidden;
    position: relative;
    display: grid;
    place-items: center;
    user-select: none;
    touch-action: none;
    cursor: grab;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.profile-settings-modal #profilePhotoCropper:hover {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

.profile-settings-modal #profilePhotoCropper:active { cursor: grabbing; }

.profile-settings-modal #profilePhotoPreview.empty #profilePhotoCropper::before {
    content: "\f007";
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    font-size: 4rem;
    color: var(--text-muted);
    opacity: 0.3;
}

.profile-settings-modal #profilePhotoCropper::after {
    content: "";
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
}

.profile-settings-modal #profilePreview {
    position: absolute;
    top: 50%;
    left: 50%;
    max-width: none;
    max-height: none;
    width: auto;
    height: auto;
    transform: translate(calc(-50% + var(--tx, 0px)), calc(-50% + var(--ty, 0px))) scale(var(--scale, 1));
    transform-origin: center;
    will-change: transform;
    display: none;
    pointer-events: none;
}

.profile-settings-modal #profilePhotoPreview.has-image #profilePreview { display: block; }

.profile-settings-modal .profile-photo-upload-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: flex-start;
}

.profile-settings-modal .profile-upload-btn {
    padding: 16px 32px;
    background: var(--primary);
    color: white;
    border-radius: var(--radius-md, 12px);
    font-weight: 600;
    font-size: 1.05rem;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.3s ease;
    border: 2px solid var(--primary);
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.2);
}

.profile-settings-modal .profile-upload-btn:hover {
    background: var(--primary-dark, #4338ca);
    border-color: var(--primary-dark, #4338ca);
    box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
    transform: translateY(-2px);
}

.profile-settings-modal .profile-upload-btn:active {
    transform: translateY(0);
}

.profile-settings-modal .profile-upload-btn i {
    font-size: 1.1rem;
}

.profile-settings-modal .profile-upload-hint {
    font-size: 0.95rem;
    color: var(--text-muted);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.profile-settings-modal .profile-upload-hint i {
    color: var(--primary);
}

.profile-settings-modal .photo-crop-controls-wrapper {
    background: var(--bg-secondary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-lg, 16px);
    padding: 20px;
    box-shadow: var(--shadow-soft, 0 2px 8px rgba(0,0,0,0.06));
}

.profile-settings-modal .crop-controls-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-color);
}

.profile-settings-modal .crop-controls-header h4 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.profile-settings-modal .crop-controls-header h4 i {
    color: var(--primary);
}

.profile-settings-modal .btn-icon-reset {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md, 12px);
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.profile-settings-modal .btn-icon-reset:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.2);
}

.profile-settings-modal .photo-crop-controls {
    display: grid;
    gap: 20px;
}

.profile-settings-modal .crop-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.profile-settings-modal .crop-label i {
    color: var(--primary);
    font-size: 0.85rem;
}

.profile-settings-modal .photo-crop-zoom {
    display: grid;
    gap: 8px;
}

.profile-settings-modal .zoom-slider-wrapper {
    display: grid;
    grid-template-columns: 24px 1fr 24px;
    align-items: center;
    gap: 12px;
    color: var(--text-secondary);
}

.profile-settings-modal .zoom-slider-wrapper i {
    font-size: 0.95rem;
    transition: color 0.2s ease;
}

.profile-settings-modal .zoom-slider-wrapper i:hover {
    color: var(--primary);
}

.profile-settings-modal .photo-crop-pan {
    display: grid;
    gap: 12px;
}

.profile-settings-modal .photo-crop-pan-row {
    display: grid;
    grid-template-columns: 20px 1fr auto;
    align-items: center;
    gap: 12px;
}

.profile-settings-modal .photo-crop-pan-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--primary);
    text-align: center;
    background: var(--bg-tertiary);
    width: 20px;
    height: 20px;
    border-radius: 4px;
    display: grid;
    place-items: center;
}

.profile-settings-modal .pan-buttons {
    display: flex;
    gap: 6px;
}

.profile-settings-modal .photo-crop-nudge {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md, 12px);
    border: 1px solid var(--border-color);
    background: var(--bg-tertiary);
    color: var(--text-primary);
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: all 0.2s ease;
}

.profile-settings-modal .photo-crop-nudge:hover {
    border-color: var(--primary);
    background: var(--primary);
    color: white;
    box-shadow: 0 2px 8px rgba(79, 70, 229, 0.2);
    transform: translateY(-1px);
}

.profile-settings-modal .photo-crop-nudge:active {
    transform: translateY(0);
}

.profile-settings-modal .photo-crop-nudge:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.profile-settings-modal .photo-crop-hint {
    font-size: 0.85rem;
    color: var(--text-muted);
    font-weight: 500;
    text-align: center;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md, 12px);
    margin-top: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.profile-settings-modal .photo-crop-hint i {
    color: var(--primary);
}

@media (max-width: 600px) {
    .profile-settings-modal {
        width: 100vw;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
        margin: 0;
    }
}

@media (max-width: 768px) {
    .profile-settings-modal .profile-photo-main {
        grid-template-columns: 1fr;
        justify-items: center;
        gap: 20px;
    }

    .profile-settings-modal .profile-photo-upload-section {
        align-items: center;
        text-align: center;
    }
}

@media (max-width: 500px) {
    .profile-settings-modal #profilePhotoPreview,
    .profile-settings-modal #profilePhotoCropper {
        width: 160px;
        height: 160px;
    }

    .profile-settings-modal .photo-crop-controls-wrapper {
        padding: 16px;
    }

    .profile-settings-modal .photo-crop-pan-row {
        grid-template-columns: 20px 1fr;
        gap: 10px;
    }

    .profile-settings-modal .pan-buttons {
        grid-column: 1 / -1;
        justify-content: center;
        margin-top: 8px;
    }
}
