/* ==========================================================================
   DESIGN SYSTEM & VARIABLES (Calculadora ISR Style)
   ========================================================================== */
:root {
    --bg-main: #090a10;
    --bg-surface: #111420;
    --bg-surface-elevated: #151828;
    --border-color: rgba(255, 255, 255, 0.06);
    --border-hover: rgba(255, 255, 255, 0.15);
    
    --text-primary: #ffffff;
    --text-secondary: #8f9bb3;
    --text-muted: #6b778c;
    
    /* GCS Theme Accent Gradients */
    --gradient-eye: linear-gradient(135deg, #3366ff 0%, #00d68f 100%);
    --gradient-verbal: linear-gradient(135deg, #8f00ff 0%, #ff3d71 100%);
    --gradient-motor: linear-gradient(135deg, #ff3d71 0%, #ffaa00 100%);
    --gradient-pupil: linear-gradient(135deg, #ff3d71 0%, #ff7e00 100%);
    --gradient-primary: linear-gradient(135deg, #3366ff 0%, #8f00ff 100%);
    
    /* Active Glowing Shadows */
    --glow-primary: rgba(51, 102, 255, 0.25);
    
    /* Severity Colors & Ambient Glows */
    --color-grave: #ff3d71;
    --color-moderado: #ffaa00;
    --color-leve: #00d68f;
    --color-nt: #8f9bb3;
    
    --glow-grave: rgba(255, 61, 113, 0.15);
    --glow-moderado: rgba(255, 170, 0, 0.15);
    --glow-leve: rgba(0, 214, 143, 0.15);
    --glow-nt: rgba(143, 155, 179, 0.15);
    
    /* Fonts & Borders */
    --font-sans: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;
    --radius-full: 9999px;
    
    --transition-fast: 0.15s ease-out;
    --transition-normal: 0.25s ease-out;
}

/* ==========================================================================
   BASE & RESET
   ========================================================================== */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    line-height: 1.4;
    -webkit-font-smoothing: antialiased;
}

/* Ambient glow in background */
body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 600px;
    height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(51, 102, 255, 0.08) 0%, rgba(0, 0, 0, 0) 70%);
    z-index: -1;
    pointer-events: none;
}

/* ==========================================================================
   TOP HEADER (NAVBAR - Calculadora ISR style)
   ========================================================================== */
.navbar {
    background-color: rgba(9, 11, 16, 0.85);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 99;
    backdrop-filter: blur(12px);
    width: 100%;
}
.navbar-content {
    max-width: 760px;
    margin: 0 auto;
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.brand-icon {
    width: 38px;
    height: 38px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    box-shadow: 0 4px 12px rgba(51, 102, 255, 0.3);
}
.brand-icon svg {
    width: 20px;
    height: 20px;
}
.brand h1 {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--text-primary);
    line-height: 1.1;
}
.brand-tagline {
    font-size: 0.65rem;
    color: var(--text-secondary);
    font-weight: 600;
    letter-spacing: 0.08em;
    margin-top: 1px;
}

/* Status Badge */
.status-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    padding: 5px 10px;
    border-radius: var(--radius-full);
}
.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background-color: var(--color-leve);
    box-shadow: 0 0 8px var(--color-leve);
}
.status-text {
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

/* ==========================================================================
   APP LAYOUT & CONTAINERS
   ========================================================================== */
.app-container {
    width: 100%;
    max-width: 760px;
    margin: 0 auto;
    padding: 1.5rem 1.25rem 130px 1.25rem; /* Large bottom padding for sticky result bar */
    flex: 1;
}

.main-content {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* Common Card Styles */
.patient-profile-card,
.assessment-section {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    transition: border-color var(--transition-fast);
}

.patient-profile-card:hover,
.assessment-section:hover {
    border-color: var(--border-hover);
}

/* ==========================================================================
   PATIENT PROFILE CARD
   ========================================================================== */
.patient-profile-card {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.profile-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.profile-icon {
    width: 18px;
    height: 18px;
    color: var(--text-secondary);
}
.patient-profile-card h2 {
    font-size: 0.9rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
}

/* Toggle Perfil (Calculadora ISR style) */
.toggle-container {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    padding: 4px;
    border-radius: var(--radius-md);
}
.toggle-btn {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    padding: 10px;
    border-radius: calc(var(--radius-md) - 2px);
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}
.toggle-btn .sub-label {
    font-size: 0.65rem;
    opacity: 0.7;
}
.toggle-btn:hover {
    color: var(--text-primary);
}
.toggle-btn.active {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.04);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ==========================================================================
   ASSESSMENT SECTIONS
   ========================================================================== */
.section-header {
    display: flex;
    align-items: flex-start;
    gap: 0.875rem;
    margin-bottom: 1.25rem;
}
.section-number {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: all var(--transition-normal);
}

.section-header h2 {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-primary);
}
.section-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 1px;
}
.header-optional {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
}

/* Section Complete Styling */
#section-eye.completed .section-number { background: var(--gradient-eye); color: white; border: none; box-shadow: 0 2px 8px rgba(51, 102, 255, 0.2); }
#section-verbal.completed .section-number { background: var(--gradient-verbal); color: white; border: none; box-shadow: 0 2px 8px rgba(143, 0, 255, 0.2); }
#section-motor.completed .section-number { background: var(--gradient-motor); color: white; border: none; box-shadow: 0 2px 8px rgba(255, 61, 113, 0.2); }
#section-pupil.completed .section-number { background: var(--gradient-pupil); color: white; border: none; box-shadow: 0 2px 8px rgba(255, 126, 0, 0.2); }

/* ==========================================================================
   OPTIONS GRID (Calculadora ISR Style)
   ========================================================================== */
.options-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
}

/* Option Card styling */
.option-card {
    background-color: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 0.875rem 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.875rem;
    text-align: left;
    transition: all var(--transition-fast);
    outline: none;
    font-family: var(--font-sans);
}

.option-card:hover {
    background-color: rgba(255, 255, 255, 0.02);
    border-color: var(--border-hover);
    transform: translateY(-1px);
}

.option-score {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: all var(--transition-fast);
}

.option-desc {
    font-size: 0.825rem;
    font-weight: 600;
    color: var(--text-secondary);
    transition: var(--transition-fast);
    line-height: 1.25;
}

.option-card .section-desc {
    font-size: 0.7rem;
    color: var(--text-muted);
    margin-top: 1px;
}

/* Active Category Coloring */
.option-card.active {
    background-color: rgba(255, 255, 255, 0.04);
}
.option-card.active .option-desc {
    color: white;
}

#grid-eye .option-card.active { border-color: #3366ff; box-shadow: 0 0 10px rgba(51, 102, 255, 0.15); }
#grid-eye .option-card.active .option-score { background: #3366ff; border-color: #3366ff; color: white; }

#grid-verbal .option-card.active { border-color: #8f00ff; box-shadow: 0 0 10px rgba(143, 0, 255, 0.15); }
#grid-verbal .option-card.active .option-score { background: #8f00ff; border-color: #8f00ff; color: white; }

#grid-motor .option-card.active { border-color: #ff3d71; box-shadow: 0 0 10px rgba(255, 61, 113, 0.15); }
#grid-motor .option-card.active .option-score { background: #ff3d71; border-color: #ff3d71; color: white; }

#grid-pupil .option-card.active { border-color: #ffaa00; box-shadow: 0 0 10px rgba(255, 170, 0, 0.15); }
#grid-pupil .option-card.active .option-score { background: #ffaa00; border-color: #ffaa00; color: white; }

/* ==========================================================================
   STICKY RESULT FOOTER (Premium floating bar)
   ========================================================================== */
.result-bar {
    position: fixed;
    bottom: 1rem;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 2rem);
    max-width: 720px;
    background: rgba(17, 20, 32, 0.85);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 1px var(--border-color);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    z-index: 98;
    transition: var(--transition-normal);
}

/* Glow bar based on severity */
.result-bar::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 1.5rem;
    right: 1.5rem;
    height: 3px;
    border-radius: var(--radius-full);
    background: var(--text-muted);
    transition: var(--transition-normal);
}

.state-grave .result-bar { box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 20px var(--glow-grave); border-color: rgba(255, 61, 113, 0.15); }
.state-grave .result-bar::after { background: var(--color-grave); }

.state-moderado .result-bar { box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 20px var(--glow-moderado); border-color: rgba(255, 170, 0, 0.15); }
.state-moderado .result-bar::after { background: var(--color-moderado); }

.state-leve .result-bar { box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 20px var(--glow-leve); border-color: rgba(0, 214, 143, 0.15); }
.state-leve .result-bar::after { background: var(--color-leve); }

.state-nt .result-bar { box-shadow: 0 12px 40px rgba(0, 0, 0, 0.6), 0 0 20px var(--glow-nt); border-color: rgba(143, 155, 179, 0.15); }
.state-nt .result-bar::after { background: var(--color-nt); }


.result-bar-content {
    padding: 0.875rem 1.25rem 1.125rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

/* Result Info Area */
.result-info {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}
.score-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.score-item {
    display: flex;
    align-items: flex-end;
}
.score-label {
    font-size: 0.6rem;
    font-weight: 800;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-right: 4px;
    margin-bottom: 2px;
}
.score-val-wrap {
    display: flex;
    align-items: baseline;
}
.score-value {
    font-size: 1.65rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -0.02em;
}
.score-max {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
}

/* GCS-P score divider */
.gcs-p-item {
    border-left: 1px solid var(--border-color);
    padding-left: 0.75rem;
    display: flex;
    align-items: flex-end;
}
.score-value-gcsp {
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1.1;
    color: var(--text-primary);
}

.score-badge {
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 0.65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    transition: var(--transition-normal);
}

.state-grave .score-badge { background: rgba(255, 61, 113, 0.15); color: var(--color-grave); }
.state-moderado .score-badge { background: rgba(255, 170, 0, 0.15); color: var(--color-moderado); }
.state-leve .score-badge { background: rgba(0, 214, 143, 0.15); color: var(--color-leve); }
.state-nt .score-badge { background: rgba(143, 155, 179, 0.15); color: var(--color-nt); }

/* Equation line */
.equation-display {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    font-family: monospace;
    font-size: 0.75rem;
    color: var(--text-secondary);
}
.eq-term {
    font-weight: 700;
}
.eq-term.selected {
    color: var(--text-primary);
}
.eq-operator {
    color: var(--text-muted);
}

/* Result Actions */
.result-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.action-btn {
    border: none;
    background: transparent;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    transition: all var(--transition-fast);
    outline: none;
}
.action-btn .icon {
    width: 14px;
    height: 14px;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: 0 4px 10px rgba(51, 102, 255, 0.25);
}
.btn-primary:hover:not(:disabled) {
    box-shadow: 0 6px 14px rgba(51, 102, 255, 0.4);
    transform: translateY(-1px);
}
.btn-primary:disabled {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.04);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}
.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-primary);
}

/* ==========================================================================
   TOAST & UTILITIES
   ========================================================================== */
.toast {
    position: fixed;
    bottom: 5.5rem; /* Positioned just above the sticky result bar */
    left: 50%;
    transform: translateX(-50%) translateY(50px);
    background: var(--bg-surface-elevated);
    border: 1px solid var(--border-color);
    padding: 10px 20px;
    border-radius: var(--radius-full);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    z-index: 100;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-primary);
    opacity: 0;
    transition: transform 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.25s ease;
    pointer-events: none;
}
.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* Warning Banner for NT criteria */
.warning-banner {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    background-color: rgba(255, 170, 0, 0.04);
    border: 1px solid rgba(255, 170, 0, 0.25);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-top: 1rem;
    animation: warningFadeIn 0.3s ease-out;
}
.warning-icon {
    width: 24px;
    height: 24px;
    color: var(--color-moderado);
    flex-shrink: 0;
    margin-top: 2px;
}
.warning-content h3 {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--color-moderado);
    margin-bottom: 0.25rem;
}
.warning-content p {
    font-size: 0.8rem;
    color: var(--text-secondary);
    line-height: 1.45;
}
.warning-content strong {
    color: var(--text-primary);
}

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

/* Legend Card */
.legend-card {
    background-color: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    margin-top: 1.5rem;
}
.legend-card h3 {
    font-size: 0.8rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-secondary);
    margin-bottom: 0.75rem;
}
.legend-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 0.75rem;
}
.legend-item {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    font-size: 0.75rem;
}
.legend-term {
    font-weight: 700;
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-family: monospace;
}
.legend-def {
    color: var(--text-secondary);
}

/* ==========================================================================
   MOBILE & RESPONSIVENESS
   ========================================================================== */
@media (max-width: 600px) {
    .app-container {
        padding-top: 1rem;
        padding-left: 0.75rem;
        padding-right: 0.75rem;
    }
    .options-grid {
        grid-template-columns: 1fr; /* Full width option stack on very narrow phones */
        gap: 0.6rem;
    }
    .option-card {
        padding: 0.75rem 0.875rem;
    }
    .result-bar-content {
        padding: 0.75rem 1rem 0.95rem 1rem;
        gap: 0.5rem;
    }
    .score-value {
        font-size: 1.4rem;
    }
    .score-value-gcsp {
        font-size: 1.15rem;
    }
    .action-btn {
        padding: 8px 10px;
        font-size: 0.75rem;
    }
    .action-btn span {
        display: none; /* Hide button text on mobile, icons only to avoid overflow */
    }
    .action-btn .icon {
        width: 16px;
        height: 16px;
        margin: 0;
    }
    .toast {
        bottom: 5.25rem;
    }
}
