/*
 * HAM-D Demo - Estilos específicos
 * Escala de Depresión de Hamilton
 * Compatible con el sistema de temas del proyecto Psi.Co.Di.Na.M.& C.
 * @author Dr. Mauricio Villamandos
 * @version 2.0
 */

/* === VARIABLES CSS ESPECÍFICAS PARA HAM-D === */
:root {
    /* Colores específicos de la escala */
    --ham-d-primary: #3498db;
    --ham-d-secondary: #2ecc71;
    --ham-d-warning: #f39c12;
    --ham-d-danger: #e74c3c;
    --ham-d-info: #17a2b8;
    
    /* Animaciones */
    --ham-d-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Tamaños */
    --ham-d-border-radius: 12px;
    --ham-d-shadow: 0 4px 20px rgba(0,0,0,0.1);
}

/* === ESTILOS PRINCIPALES === */
.ham-d-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

.section {
    margin-bottom: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--ham-d-border-radius);
    transition: var(--ham-d-transition);
    padding: 1.5rem;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    box-shadow: var(--ham-d-shadow);
}

.section:hover {
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    transform: translateY(-2px);
}

/* Compatibilidad con glass-card del sistema */
.glass-card {
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--ham-d-border-radius);
    box-shadow: var(--ham-d-shadow);
    padding: 1.5rem;
}

/* Contenedor principal con glass-card */
.ham-d-main-container {
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(30px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--ham-d-border-radius);
    padding: 2rem;
    margin: 2rem auto;
    max-width: 900px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.1);
}

/* === TÍTULOS DE ÍTEMS === */
.item-title {
    color: var(--bs-primary, var(--ham-d-primary));
    font-weight: 600;
    margin-bottom: 1rem;
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: color 0.3s ease;
}

.item-title i {
    color: var(--ham-d-primary);
    font-size: 1.2rem;
}

/* === CONTENEDOR DE ÍTEMS === */
.item {
    padding: 1rem 0;
}

.item:not(:last-child) {
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 1rem;
    padding-bottom: 1rem;
}

/* === ESTILOS GENERALES DE TEXTO === */
.section-title {
    color: inherit;
    transition: color 0.3s ease;
}

/* === OPCIONES DE RESPUESTA === */
.options-container {
    display: grid;
    gap: 0.75rem;
}

.options {
    display: grid;
    gap: 0.75rem;
}

.option-item, .option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    transition: var(--ham-d-transition);
    cursor: pointer;
    background: rgba(255, 255, 255, 0.05);
}

.option-text {
    flex: 1;
    line-height: 1.5;
}

.option-score {
    font-weight: 600;
    color: var(--ham-d-secondary);
    white-space: nowrap;
    font-size: 0.9rem;
}

.option-item:hover, .option:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--ham-d-primary);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.option-item input[type="radio"], .option input[type="radio"] {
    margin: 0;
    transform: scale(1.2);
    accent-color: var(--ham-d-primary);
}

.option-item input[type="radio"]:checked, .option input[type="radio"]:checked {
    accent-color: var(--ham-d-secondary);
}

.option-item label, .option label {
    cursor: pointer;
    flex: 1;
    line-height: 1.5;
    margin: 0;
    font-size: 0.95rem;
    color: inherit;
    transition: color 0.3s ease;
}

/* Opción seleccionada */
.option-item:has(input:checked), .option:has(input:checked) {
    background: rgba(46, 204, 113, 0.15);
    border-color: var(--ham-d-secondary);
    box-shadow: 0 4px 16px rgba(46, 204, 113, 0.3);
}

/* === CONTENEDOR DE PROGRESO === */
.progress-container {
    position: sticky;
    top: 20px;
    z-index: 10;
    margin-bottom: 2rem;
    display: none;
}

.progress-container .card {
    backdrop-filter: blur(20px);
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.progress-container .progress {
    height: 8px;
    border-radius: 10px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.1);
}

.progress-container .progress-bar {
    border-radius: 10px;
    transition: var(--ham-d-transition);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.8; }
    100% { opacity: 1; }
}

/* === BOTÓN DE CÁLCULO === */
.calculate-btn-container {
    text-align: center;
    margin: 3rem 0;
}

#calculateBtn {
    background: linear-gradient(135deg, var(--ham-d-primary), var(--ham-d-secondary));
    border: none;
    padding: 1rem 3rem;
    border-radius: var(--ham-d-border-radius);
    font-weight: 600;
    font-size: 1.1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: var(--ham-d-transition);
    box-shadow: 0 4px 15px rgba(52, 152, 219, 0.3);
}

#calculateBtn:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(52, 152, 219, 0.4);
    background: linear-gradient(135deg, var(--ham-d-secondary), var(--ham-d-primary));
}

#calculateBtn:active {
    transform: translateY(-1px);
}

#calculateBtn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* === RESULTADOS === */
.result-card {
    background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.05));
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: var(--ham-d-border-radius);
    backdrop-filter: blur(20px);
    margin-top: 2rem;
}

.score-display {
    text-align: center;
    padding: 2rem;
}

.total-score {
    font-size: 4rem;
    font-weight: 700;
    color: var(--ham-d-primary);
    margin: 0;
    text-shadow: 2px 2px 4px rgba(0,0,0,0.3);
}

.max-score {
    font-size: 1.5rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* === INTERPRETACIÓN === */
.interpretation {
    padding: 1.5rem;
    border-radius: var(--ham-d-border-radius);
    margin: 1.5rem 0;
    font-weight: 600;
    font-size: 1.1rem;
    text-align: center;
    border: none;
    box-shadow: var(--ham-d-shadow);
}

.interpretation.alert-success {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: white;
}

.interpretation.alert-info {
    background: linear-gradient(135deg, #17a2b8, #138496);
    color: white;
}

.interpretation.alert-warning {
    background: linear-gradient(135deg, #f39c12, #e67e22);
    color: white;
}

.interpretation.alert-danger {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
    color: white;
}

.interpretation.alert-dark {
    background: linear-gradient(135deg, #34495e, #2c3e50);
    color: white;
}

/* === BARRA DE SEVERIDAD === */
.severity-container {
    margin: 2rem 0;
}

.severity-progress {
    height: 20px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.1);
    overflow: hidden;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.1);
}

#severityBar {
    height: 100%;
    border-radius: 10px;
    transition: var(--ham-d-transition);
    position: relative;
}

#severityBar::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.3), transparent);
    animation: shine 2s infinite;
}

@keyframes shine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* === BOTONES DE ACCIÓN === */
.action-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-top: 2rem;
    padding: 1.5rem;
}

.action-btn {
    padding: 0.75rem 1.5rem;
    border-radius: var(--ham-d-border-radius);
    border: none;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: var(--ham-d-transition);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-export {
    background: linear-gradient(135deg, #3498db, #2980b9);
    color: white;
}

.btn-export:hover {
    background: linear-gradient(135deg, #2980b9, #3498db);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.4);
}

.btn-print {
    background: linear-gradient(135deg, #95a5a6, #7f8c8d);
    color: white;
}

.btn-print:hover {
    background: linear-gradient(135deg, #7f8c8d, #95a5a6);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(127, 140, 141, 0.4);
}

.btn-save {
    background: linear-gradient(135deg, #2ecc71, #27ae60);
    color: white;
}

.btn-save:hover {
    background: linear-gradient(135deg, #27ae60, #2ecc71);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(46, 204, 113, 0.4);
}

.btn-word {
    background: linear-gradient(135deg, #2980b9, #2574a9);
    color: white;
}

.btn-word:hover {
    background: linear-gradient(135deg, #2574a9, #2980b9);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(41, 128, 185, 0.4);
}

/* === ESTILOS DE IMPRESIÓN === */
@media print {
    .no-print {
        display: none !important;
    }
    
    .section {
        border: 1px solid #ddd !important;
        break-inside: avoid;
        margin-bottom: 1rem;
    }
    
    .glass-card {
        background: white !important;
        box-shadow: none !important;
        border: 1px solid #ddd !important;
    }
    
    .total-score {
        color: #333 !important;
        text-shadow: none !important;
    }
    
    .interpretation {
        background: #f8f9fa !important;
        color: #333 !important;
        border: 1px solid #ddd !important;
    }
    
    .progress-container {
        display: none !important;
    }
    
    /* Compactar gráfico para impresión */
    .chart-wrapper {
        height: 200px !important;
    }
    
    /* Ajustar tamaño de fuente para impresión */
    .score-display {
        padding: 1rem !important;
    }
    
    .total-score {
        font-size: 2.5rem !important;
    }
    
    .max-score {
        font-size: 1rem !important;
    }
    
    /* Ajustar interpretación */
    .interpretation {
        padding: 0.75rem !important;
        font-size: 0.9rem !important;
    }
    
    /* Ajustar barra de severidad */
    .severity-container {
        margin: 1rem 0 !important;
    }
    
    .severity-progress {
        height: 15px !important;
    }
    
    /* Ocultar elementos no necesarios en PDF */
    .action-buttons {
        display: none !important;
    }
    
    .alert {
        margin-bottom: 1rem !important;
    }
}

/* === ESTILOS PARA EXPORTACIÓN PDF === */
.pdf-export {
    max-width: 794px !important; /* Ancho A4 */
    margin: 0 auto !important;
    padding: 20px !important;
    background: white !important;
    box-shadow: none !important;
    border: none !important;
    font-size: 14px !important;
}

.pdf-export .score-display {
    padding: 20px !important;
    margin-bottom: 20px !important;
}

.pdf-export .total-score {
    font-size: 48px !important;
    margin: 10px 0 !important;
}

.pdf-export .max-score {
    font-size: 18px !important;
    margin-top: 10px !important;
}

.pdf-export .interpretation {
    padding: 15px !important;
    margin: 20px 0 !important;
    font-size: 16px !important;
    border-radius: 8px !important;
}

.pdf-export .severity-container {
    margin: 20px 0 !important;
}

.pdf-export .severity-progress {
    height: 20px !important;
    margin: 10px 0 !important;
}

.pdf-export .chart-wrapper {
    height: 500px !important; /* Mayor altura para el gráfico en PDF */
    margin: 20px 0 !important;
}

.pdf-export .alert {
    margin: 20px 0 !important;
    padding: 15px !important;
}

.pdf-export .glass-card {
    background: white !important;
    border: 1px solid #ddd !important;
    box-shadow: none !important;
    margin: 20px 0 !important;
}

.pdf-export .card-body {
    padding: 20px !important;
}

.pdf-export .card-title {
    font-size: 18px !important;
    margin-bottom: 15px !important;
}

/* === RESPONSIVIDAD === */
@media (max-width: 768px) {
    .ham-d-container {
        padding: 1rem 0.5rem;
    }
    
    .section {
        margin-bottom: 1.5rem;
    }
    
    .total-score {
        font-size: 3rem;
    }
    
    .action-buttons {
        grid-template-columns: 1fr;
    }
    
    .option-item,
    .option {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
    
    .option-item input[type="radio"],
    .option input[type="radio"] {
        align-self: flex-start;
        margin-top: 0.25rem;
    }
    
    .option-score {
        font-size: 0.85rem;
    }
}

@media (max-width: 480px) {
    .total-score {
        font-size: 2.5rem;
    }
    
    #calculateBtn {
        padding: 0.75rem 2rem;
        font-size: 1rem;
    }
    
    .item-title {
        font-size: 1rem;
    }
    
    .option-item label {
        font-size: 0.9rem;
    }
}

/* === ANIMACIONES ESPECÍFICAS === */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate__fadeInUp {
    animation: fadeInUp 0.6s ease-out;
}

/* === COMPATIBILIDAD CON TEMA OSCURO === */
[data-theme="dark"] .section {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.02);
}

[data-theme="dark"] .option-item:hover, [data-theme="dark"] .option:hover {
    background: rgba(255, 255, 255, 0.08);
}

[data-theme="dark"] .option-item:has(input:checked), [data-theme="dark"] .option:has(input:checked) {
    background: rgba(46, 204, 113, 0.15);
    border-color: var(--ham-d-secondary);
}

[data-theme="dark"] .item-title {
    color: var(--text-strong) !important;
}

[data-theme="dark"] .option label, [data-theme="dark"] .option-item label {
    color: var(--text-strong) !important;
}

[data-theme="dark"] .section-title {
    color: var(--text-strong) !important;
}

[data-theme="dark"] .total-score {
    color: var(--ham-d-primary) !important;
}

/* === COMPATIBILIDAD CON TEMA CLARO === */
[data-theme="light"] .section {
    border-color: rgba(0, 0, 0, 0.1);
    background: rgba(255, 255, 255, 0.7);
}

[data-theme="light"] .option-item:hover, [data-theme="light"] .option:hover {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="light"] .option-item:has(input:checked), [data-theme="light"] .option:has(input:checked) {
    background: rgba(46, 204, 113, 0.1);
}

[data-theme="light"] .item-title {
    color: var(--text-strong) !important;
}

[data-theme="light"] .option label, [data-theme="light"] .option-item label {
    color: var(--text-strong) !important;
}

[data-theme="light"] .section-title {
    color: var(--text-strong) !important;
}

[data-theme="light"] .total-score {
    color: var(--ham-d-primary) !important;
}

[data-theme="light"] .glass-card {
    background: rgba(255, 255, 255, 0.4) !important;
    border: 1px solid rgba(0, 0, 0, 0.1) !important;
}

/* === TEMA POR DEFECTO (SIN ATRIBUTO) === */
body:not([data-theme]) .section {
    border-color: rgba(255, 255, 255, 0.1);
    background: rgba(255, 255, 255, 0.02);
}

body:not([data-theme]) .item-title {
    color: var(--text-strong) !important;
}

body:not([data-theme]) .option label, body:not([data-theme]) .option-item label {
    color: var(--text-strong) !important;
}

body:not([data-theme]) .section-title {
    color: var(--text-strong) !important;
}

body:not([data-theme]) .total-score {
    color: var(--ham-d-primary) !important;
}

/* === TOOLTIPS PERSONALIZADOS === */
.custom-tooltip {
    position: relative;
    cursor: help;
}

.custom-tooltip::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.8rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
    z-index: 1000;
}

.custom-tooltip:hover::after {
    opacity: 1;
}

/* === INDICADORES DE ESTADO === */
.completion-indicator {
    position: absolute;
    top: 1rem;
    right: 1rem;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--ham-d-secondary);
    display: none;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 0.8rem;
    animation: bounceIn 0.5s;
}

.section:has(input:checked) .completion-indicator {
    display: flex;
}

@keyframes bounceIn {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.05); }
    70% { transform: scale(0.9); }
    100% { transform: scale(1); opacity: 1; }
}

/* === MEJORAS DE ACCESIBILIDAD === */
.option-item:focus-within {
    outline: 2px solid var(--ham-d-primary);
    outline-offset: 2px;
}

.option-item input[type="radio"]:focus {
    outline: none;
}

/* Mejora para usuarios que prefieren movimiento reducido */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
