/* =============================================================
   Sistema de Evaluaciones Psicométricas v5.0
   Estilos principales
   ============================================================= */

:root {
    --primary: #1a365d;
    --primary-light: #2c5282;
    --primary-lighter: #ebf4ff;
    --accent: #dd6b20;
    --accent-light: #ed8936;
    --success: #38a169;
    --success-light: #c6f6d5;
    --warning: #d69e2e;
    --warning-light: #fefcbf;
    --danger: #e53e3e;
    --danger-light: #fed7d7;
    --info: #3182ce;
    --info-light: #bee3f8;
    --gray-50: #f7fafc;
    --gray-100: #edf2f7;
    --gray-200: #e2e8f0;
    --gray-300: #cbd5e0;
    --gray-400: #a0aec0;
    --gray-500: #718096;
    --gray-600: #4a5568;
    --gray-700: #2d3748;
    --gray-800: #1a202c;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--gray-50);
    color: var(--gray-700);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
}

/* ---- LAYOUT ---- */
.app-wrapper { display: flex; min-height: 100vh; }

.sidebar {
    width: 260px;
    background: var(--primary);
    color: #fff;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    overflow-y: auto;
    z-index: 100;
    transition: transform .3s;
}

.sidebar-inner {
    display: flex;
    flex-direction: column;
    min-height: 100%;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,.1);
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: .5px;
}

.sidebar-header small {
    opacity: .6;
    font-size: 12px;
}

.sidebar-nav { padding: 16px 0; flex: 1; }

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 20px;
    color: rgba(255,255,255,.75);
    text-decoration: none;
    font-size: 14px;
    transition: all .2s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover, .sidebar-nav a.active {
    background: rgba(255,255,255,.1);
    color: #fff;
    border-left-color: var(--accent);
}

.sidebar-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }

.sidebar-nav .nav-section {
    padding: 20px 20px 8px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: .4;
    font-weight: 600;
}

.sidebar-version {
    padding: 16px 20px;
    font-size: 10px;
    color: rgba(255,255,255,.2);
    text-align: center;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: 400;
    width: 100%;
    font-weight: 500;
}

.main-content {
    flex: 1;
    margin-left: 260px;
    min-height: 100vh;
}

.top-bar {
    background: #fff;
    padding: 16px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-bar h1 { font-size: 20px; color: var(--primary); font-weight: 700; }

.top-bar-actions { display: flex; align-items: center; gap: 16px; }

.page-content { padding: 32px; }

/* ---- CARDS ---- */
.card {
    background: #fff;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 { font-size: 16px; font-weight: 600; color: var(--gray-800); }
.card-body { padding: 24px; }
.card-footer { padding: 16px 24px; border-top: 1px solid var(--gray-100); background: var(--gray-50); }

/* ---- STAT CARDS ---- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: #fff;
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: flex-start;
    gap: 16px;
}

.stat-icon {
    width: 48px; height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon.blue { background: var(--primary-lighter); color: var(--primary); }
.stat-icon.green { background: var(--success-light); color: var(--success); }
.stat-icon.orange { background: #feebc8; color: var(--accent); }
.stat-icon.red { background: var(--danger-light); color: var(--danger); }

.stat-info h4 { font-size: 28px; font-weight: 700; color: var(--gray-800); line-height: 1.2; }
.stat-info p { font-size: 13px; color: var(--gray-500); margin-top: 2px; }

/* ---- TABLES ---- */
.table-wrapper { overflow-x: auto; }

table.data-table {
    width: 100%;
    border-collapse: collapse;
}

table.data-table thead th {
    background: var(--gray-50);
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--gray-500);
    border-bottom: 2px solid var(--gray-200);
    white-space: nowrap;
}

table.data-table tbody td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 14px;
    vertical-align: middle;
}

table.data-table tbody tr:hover { background: var(--gray-50); }

/* ---- BADGES ---- */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
}

.badge.green { background: var(--success-light); color: #22543d; }
.badge.yellow { background: var(--warning-light); color: #744210; }
.badge.red { background: var(--danger-light); color: #742a2a; }
.badge.blue { background: var(--info-light); color: #2a4365; }
.badge.gray { background: var(--gray-100); color: var(--gray-600); }

/* ---- BUTTONS ---- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all .2s;
    text-decoration: none;
    white-space: nowrap;
    line-height: 1.4;
}

.btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn:active { transform: translateY(0); }

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-light); }

.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-light); }

.btn-success { background: var(--success); color: #fff; }
.btn-danger { background: var(--danger); color: #fff; }

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 2px solid var(--gray-200);
}
.btn-outline:hover { border-color: var(--primary); background: var(--primary-lighter); }

.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-lg { padding: 14px 28px; font-size: 16px; }

.btn-icon {
    width: 36px; height: 36px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

/* ---- FORMS ---- */
.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 6px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 14px;
    color: var(--gray-700);
    transition: border-color .2s;
    background: #fff;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,54,93,.1);
}

.form-control::placeholder { color: var(--gray-400); }

textarea.form-control { resize: vertical; min-height: 100px; }

select.form-control { cursor: pointer; }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-hint { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

/* ---- ALERTS / FLASH ---- */
.alert {
    padding: 14px 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: var(--success-light); color: #22543d; border-left: 4px solid var(--success); }
.alert-danger { background: var(--danger-light); color: #742a2a; border-left: 4px solid var(--danger); }
.alert-warning { background: var(--warning-light); color: #744210; border-left: 4px solid var(--warning); }
.alert-info { background: var(--info-light); color: #2a4365; border-left: 4px solid var(--info); }

/* ---- EXAM INTERFACE (Aspirante) ---- */
.exam-wrapper {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

.exam-header {
    background: var(--primary);
    color: #fff;
    padding: 32px;
    border-radius: var(--radius) var(--radius) 0 0;
    text-align: center;
}

.exam-header h1 { font-size: 22px; font-weight: 700; }
.exam-header p { opacity: .8; margin-top: 8px; font-size: 14px; }

.exam-progress {
    background: #fff;
    padding: 16px 32px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    gap: 16px;
}

.progress-bar {
    flex: 1;
    height: 8px;
    background: var(--gray-200);
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--accent));
    border-radius: 4px;
    transition: width .5s ease;
}

.progress-text { font-size: 13px; color: var(--gray-500); font-weight: 600; white-space: nowrap; }

.exam-section-title {
    background: var(--primary-lighter);
    padding: 20px 32px;
    border-bottom: 1px solid var(--gray-200);
}

.exam-section-title h2 { font-size: 18px; color: var(--primary); font-weight: 700; }
.exam-section-title p { color: var(--gray-600); font-size: 14px; margin-top: 4px; }

.exam-question {
    background: #fff;
    padding: 28px 32px;
    border-bottom: 1px solid var(--gray-100);
}

.question-number {
    display: inline-block;
    background: var(--primary);
    color: #fff;
    width: 28px; height: 28px;
    border-radius: 50%;
    text-align: center;
    line-height: 28px;
    font-size: 13px;
    font-weight: 700;
    margin-right: 12px;
}

.question-text {
    font-size: 15px;
    color: var(--gray-800);
    margin-bottom: 18px;
    line-height: 1.7;
}

.option-group { display: flex; flex-direction: column; gap: 10px; }

.option-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 16px;
    border: 2px solid var(--gray-200);
    border-radius: 10px;
    cursor: pointer;
    transition: all .2s;
    position: relative;
}

.option-item:hover { border-color: var(--primary-light); background: var(--primary-lighter); }

.option-item.selected {
    border-color: var(--primary);
    background: var(--primary-lighter);
    box-shadow: 0 0 0 3px rgba(26,54,93,.1);
}

.option-item input[type="radio"] {
    width: 18px; height: 18px;
    margin-top: 2px;
    flex-shrink: 0;
    accent-color: var(--primary);
}

.option-item label {
    font-size: 14px;
    color: var(--gray-700);
    cursor: pointer;
    line-height: 1.5;
}

.exam-footer {
    background: #fff;
    padding: 24px 32px;
    border-radius: 0 0 var(--radius) var(--radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-md);
}

.exam-timer {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
    font-weight: 700;
    color: var(--gray-600);
}

.exam-timer.warning { color: var(--warning); }
.exam-timer.danger { color: var(--danger); animation: pulse 1s infinite; }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .5; }
}

/* ---- TOKEN / REGISTRATION PAGE ---- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    padding: 20px;
}

.auth-card {
    background: #fff;
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 480px;
    overflow: hidden;
}

.auth-card-header {
    background: var(--primary);
    color: #fff;
    padding: 32px;
    text-align: center;
}

.auth-card-header h1 { font-size: 24px; font-weight: 700; }
.auth-card-header p { opacity: .8; margin-top: 6px; font-size: 14px; }

.auth-card-body { padding: 32px; }

.auth-card .logo {
    display: block;
    max-width: 180px;
    margin: 0 auto 16px;
}

/* ---- DASHBOARD CHARTS ---- */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 24px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px; }

/* ---- COMPARISON DASHBOARD ---- */
.comparison-card {
    border: 2px solid var(--gray-200);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    transition: all .3s;
}

.comparison-card.winner {
    border-color: var(--success);
    background: var(--success-light);
}

.comparison-card h4 { font-size: 16px; color: var(--gray-800); margin-bottom: 8px; }

.score-circle {
    width: 80px; height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    margin: 16px auto;
    color: #fff;
}

.score-circle.high { background: var(--success); }
.score-circle.medium { background: var(--warning); }
.score-circle.low { background: var(--danger); }

/* ---- PRINT STYLES ---- */
@media print {
    @page { size: A4 portrait; margin: 12mm 10mm 14mm 10mm; }
    
    /* Hide UI chrome — but NOT inline styled spans/badges */
    .sidebar, .top-bar, .no-print, nav,
    .sidebar-inner, .main-header { display: none !important; }
    
    /* Hide interactive elements specifically */
    button, input[type="submit"], input[type="button"] { display: none !important; }
    a.btn, .btn-primary, .btn-outline, .btn-sm { display: none !important; }
    form:not(.print-keep) { display: none !important; }
    
    /* Reset layout */
    .main-content { margin-left: 0 !important; padding: 0 !important; width: 100% !important; max-width: 100% !important; }
    .page-content { padding: 10px !important; max-width: 100% !important; }
    body { background: #fff !important; font-size: 9.5pt !important; color: #000 !important; margin: 0 !important; padding: 0 !important; }
    
    /* Force colors to print */
    * { -webkit-print-color-adjust: exact !important; print-color-adjust: exact !important; color-adjust: exact !important; }
    
    /* Cards */
    .card { box-shadow: none !important; border: 1px solid #ccc !important; break-inside: avoid; page-break-inside: avoid; margin-bottom: 10pt !important; }
    .card-header { border-bottom: 1px solid #ccc !important; }
    .mb-3 { margin-bottom: 10pt !important; }
    
    /* Text: SCOPED fix — only for text containers, NOT grid/flex parents */
    .card-body, p, span, td, th, li {
        overflow: visible !important;
        text-overflow: unset !important;
        word-wrap: break-word !important;
    }
    
    /* Grid layouts — class-based ones collapse, inline-style ones preserved by page CSS */
    .grid-2, .grid-3 { display: block !important; }
    .grid-2 > *, .grid-3 > * { width: 100% !important; margin-bottom: 8pt !important; }
    .stats-grid { display: grid !important; grid-template-columns: repeat(4, 1fr) !important; gap: 8px !important; }
    
    /* Inline grid/flex: preserve layout (each report adds specific overrides) */
    div[style*="display:grid"] { break-inside: avoid !important; }
    div[style*="display:flex"] { flex-wrap: wrap !important; }
    
    /* Links */
    a { text-decoration: none !important; color: inherit !important; }
    a[href]:after { content: none !important; }
    
    /* Charts: hide canvas, show print images */
    canvas { display: none !important; }
    .chart-print-img { display: block !important; max-width: 100% !important; height: auto !important; margin: 0 auto !important; }
    
    /* Page breaks */
    h3, h2 { page-break-after: avoid !important; }
    .footer { position: relative !important; page-break-before: avoid !important; }
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .page-content { padding: 20px; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .grid-2, .grid-3 { grid-template-columns: 1fr; }
    .exam-question { padding: 20px; }
    .form-row { grid-template-columns: 1fr; }
    .top-bar { padding: 12px 16px; }
    .top-bar h1 { font-size: 16px; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr; }
    .exam-header { padding: 24px 20px; }
    .auth-card { border-radius: 12px; }
}

/* ---- UTILITIES ---- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-muted { color: var(--gray-500); }
.text-small { font-size: 13px; }
.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mr-1 { margin-right: 8px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-1 { gap: 8px; }
.gap-2 { gap: 16px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }

/* Loading spinner */
.spinner {
    display: inline-block;
    width: 20px; height: 20px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Checkbox for comparison */
.compare-check {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
    cursor: pointer;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-400);
}

.empty-state svg { width: 64px; height: 64px; margin-bottom: 16px; opacity: .5; }
.empty-state h3 { color: var(--gray-500); margin-bottom: 8px; }
