/* ─────────────────────────────────────────────────────────────────────────────
   style.css — Cuestionarios Clínicos
   Paleta: clara, luminosa, perfectamente legible
   Tipografía: Inter (Google Fonts)
   ─────────────────────────────────────────────────────────────────────────── */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* ─── Tokens ──────────────────────────────────────────────────────────────── */
:root {
    /* Superficie */
    --bg:          #F0F4F8;
    --surface:     #FFFFFF;
    --surface-alt: #F8FAFC;
    --border:      #E2E8F0;
    --border-focus:#0D9488;

    /* Texto */
    --text-primary:   #1E293B;
    --text-secondary: #475569;
    --text-muted:     #94A3B8;

    /* Acento */
    --teal:        #0D9488;
    --teal-dark:   #0F766E;
    --teal-light:  #CCFBF1;

    /* Estados clínicos */
    --success:     #059669;
    --success-bg:  #ECFDF5;
    --warning:     #D97706;
    --warning-bg:  #FFFBEB;
    --danger:      #DC2626;
    --danger-bg:   #FEF2F2;
    --muted:       #64748B;
    --muted-bg:    #F1F5F9;

    /* Badges de estado de evaluación */
    --estado-no-gen:   #94A3B8; /* gris — No generado */
    --estado-no-ini:   #3B82F6; /* azul — No iniciado */
    --estado-iniciado: #F59E0B; /* ámbar — Iniciado */
    --estado-terminado:#059669; /* verde — Terminado */

    /* Layout */
    --radius:   10px;
    --radius-sm: 6px;
    --shadow:   0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md:0 4px 12px rgba(0,0,0,.08), 0 2px 4px rgba(0,0,0,.05);
}

/* ─── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

/* ─── Layout: Auth Pages ──────────────────────────────────────────────────── */
.auth-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.auth-card {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    padding: 40px;
    width: 100%;
    max-width: 420px;
    border: 1px solid var(--border);
}

.auth-logo {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
}

.auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
    text-align: center;
    margin-bottom: 6px;
}

.auth-subtitle {
    color: var(--text-secondary);
    text-align: center;
    font-size: .9rem;
    margin-bottom: 28px;
}

/* ─── Layout: Admin Panel ─────────────────────────────────────────────────── */
.admin-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 24px 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 100;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px 24px;
    border-bottom: 1px solid var(--border);
    text-decoration: none;
}

.sidebar-brand-icon {
    width: 36px; height: 36px;
    background: var(--teal);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
}

.sidebar-brand span {
    font-size: .9rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.2;
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-size: .9rem;
    font-weight: 500;
    transition: background .15s, color .15s;
    margin-bottom: 2px;
}

.nav-item:hover, .nav-item.active {
    background: var(--teal-light);
    color: var(--teal-dark);
}

.sidebar-footer {
    padding: 16px 20px 0;
    border-top: 1px solid var(--border);
}

.logout-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--danger);
    font-size: .875rem;
    font-weight: 500;
    text-decoration: none;
    padding: 8px 0;
}

.logout-btn:hover { text-decoration: underline; }

/* Main content */
.admin-main {
    margin-left: 240px;
    flex: 1;
    padding: 32px;
    max-width: 1100px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 28px;
    gap: 16px;
    flex-wrap: wrap;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary);
}

.page-subtitle {
    font-size: .9rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

/* ─── Cards ───────────────────────────────────────────────────────────────── */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    overflow: hidden;
}

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

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.card-body {
    padding: 24px;
}

/* ─── Tablas ──────────────────────────────────────────────────────────────── */
.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
}

th {
    background: var(--surface-alt);
    color: var(--text-secondary);
    font-weight: 600;
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .04em;
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
    color: var(--text-primary);
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }

tr:hover td { background: var(--surface-alt); }

.table-empty {
    text-align: center;
    padding: 48px 24px;
    color: var(--text-muted);
    font-size: .9rem;
}

/* ─── Badges de Estado ────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: .78rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 999px;
    white-space: nowrap;
}

.badge::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    opacity: .7;
}

.badge-no-gen   { background: #F1F5F9; color: var(--estado-no-gen); }
.badge-no-ini   { background: #EFF6FF; color: var(--estado-no-ini); }
.badge-iniciado { background: #FFFBEB; color: var(--estado-iniciado); }
.badge-terminado{ background: var(--success-bg); color: var(--estado-terminado); }
.badge-riesgo   { background: var(--danger-bg); color: var(--danger); }

/* ─── Formularios ─────────────────────────────────────────────────────────── */
.auth-form, .form { display: flex; flex-direction: column; gap: 18px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }

label {
    font-size: .875rem;
    font-weight: 500;
    color: var(--text-secondary);
}

label small { font-weight: 400; color: var(--text-muted); }

input[type="text"],
input[type="email"],
input[type="password"],
input[type="date"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .9rem;
    color: var(--text-primary);
    background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
    outline: none;
}

input:focus, select:focus, textarea:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(13,148,136,.12);
}

input::placeholder { color: var(--text-muted); }

/* ─── Radio Groups (cuestionarios) ───────────────────────────────────────── */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 4px;
}

.radio-option {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: border-color .15s, background .15s;
}

.radio-option:hover { border-color: var(--teal); background: var(--teal-light); }

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

.radio-option.selected {
    border-color: var(--teal);
    background: var(--teal-light);
}

.radio-label {
    font-size: .875rem;
    color: var(--text-primary);
    line-height: 1.4;
}

/* Pregunta del cuestionario */
.question-block {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px 24px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.question-block.unanswered { border-color: var(--danger); }

.question-number {
    font-size: .8rem;
    font-weight: 600;
    color: var(--teal);
    text-transform: uppercase;
    letter-spacing: .05em;
    margin-bottom: 6px;
}

.question-text {
    font-size: .95rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 14px;
    line-height: 1.5;
}

/* ─── Progress Bar ────────────────────────────────────────────────────────── */
.progress-bar-container {
    background: var(--border);
    border-radius: 999px;
    height: 6px;
    margin-bottom: 24px;
    overflow: hidden;
}

.progress-bar-fill {
    background: var(--teal);
    height: 100%;
    border-radius: 999px;
    transition: width .3s ease;
}

.progress-label {
    font-size: .8rem;
    color: var(--text-muted);
    text-align: right;
    margin-top: 4px;
}

/* ─── Botones ─────────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: .9rem;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background .15s, transform .1s, box-shadow .15s;
    white-space: nowrap;
}

.btn:active { transform: scale(.98); }

.btn-primary {
    background: var(--teal);
    color: #fff;
    box-shadow: 0 2px 6px rgba(13,148,136,.3);
}
.btn-primary:hover { background: var(--teal-dark); box-shadow: 0 4px 10px rgba(13,148,136,.4); }

.btn-secondary {
    background: var(--surface-alt);
    color: var(--text-primary);
    border: 1.5px solid var(--border);
}
.btn-secondary:hover { background: var(--border); }

.btn-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1.5px solid #FECACA;
}
.btn-danger:hover { background: #FEE2E2; }

.btn-sm { padding: 6px 12px; font-size: .8rem; }

.btn-full { width: 100%; }

/* ─── Alertas ─────────────────────────────────────────────────────────────── */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    font-weight: 500;
    margin-bottom: 16px;
    line-height: 1.5;
}
.alert-error   { background: var(--danger-bg);  color: var(--danger);  border: 1px solid #FECACA; }
.alert-success { background: var(--success-bg); color: var(--success); border: 1px solid #A7F3D0; }
.alert-warning { background: var(--warning-bg); color: var(--warning); border: 1px solid #FDE68A; }
.alert-info    { background: #EFF6FF; color: #1D4ED8; border: 1px solid #BFDBFE; }

/* ─── Código de link copiable ─────────────────────────────────────────────── */
.copybox {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface-alt);
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 10px 12px;
    font-family: 'Courier New', monospace;
    font-size: .8rem;
    color: var(--text-secondary);
    word-break: break-all;
}

.copybox button {
    flex-shrink: 0;
    background: var(--teal);
    color: white;
    border: none;
    border-radius: 4px;
    padding: 4px 10px;
    font-size: .75rem;
    cursor: pointer;
    font-family: inherit;
    transition: background .15s;
}

.copybox button:hover { background: var(--teal-dark); }

/* ─── Search ──────────────────────────────────────────────────────────────── */
.search-box {
    position: relative;
    max-width: 320px;
}

.search-box input {
    padding-left: 36px;
}

.search-box::before {
    content: '🔍';
    position: absolute;
    left: 10px;
    top: 50%;
    transform: translateY(-50%);
    font-size: .85rem;
    pointer-events: none;
}

/* ─── Stats Row ───────────────────────────────────────────────────────────── */
.stats-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 16px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: .8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-desc {
    font-size: .8rem;
    color: var(--text-muted);
    margin-top: 2px;
}

/* ─── Modal (generador de links) ─────────────────────────────────────────── */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.35);
    backdrop-filter: blur(3px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s;
}

.modal-overlay.open {
    opacity: 1;
    pointer-events: all;
}

.modal {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.15);
    padding: 32px;
    width: 100%;
    max-width: 480px;
    transform: translateY(16px);
    transition: transform .2s;
}

.modal-overlay.open .modal { transform: translateY(0); }

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 20px;
    color: var(--text-primary);
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* ─── Cuestionario Page ───────────────────────────────────────────────────── */
.form-page {
    min-height: 100vh;
    background: var(--bg);
    padding: 32px 16px;
}

.form-container {
    max-width: 720px;
    margin: 0 auto;
}

.form-header {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 24px 28px;
    margin-bottom: 24px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.form-header h1 {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.form-header p {
    font-size: .9rem;
    color: var(--text-secondary);
}

/* ─── Gracias page ────────────────────────────────────────────────────────── */
.thank-you {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 24px;
}

.thank-you-card {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    padding: 48px 40px;
    text-align: center;
    max-width: 480px;
    width: 100%;
    border: 1px solid var(--border);
}

.thank-you-icon {
    font-size: 3.5rem;
    margin-bottom: 20px;
}

.thank-you-card h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--success);
    margin-bottom: 12px;
}

.thank-you-card p {
    color: var(--text-secondary);
    line-height: 1.6;
}

/* ─── Informe Clínico / Print ─────────────────────────────────────────────── */
.report-section { margin-bottom: 32px; }

.report-section h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--teal-dark);
    border-bottom: 2px solid var(--teal-light);
    padding-bottom: 8px;
    margin-bottom: 16px;
}

.score-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
}

.score-item {
    background: var(--surface-alt);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 14px 16px;
    text-align: center;
}

.score-dim  { font-size: .75rem; font-weight: 700; color: var(--text-muted); text-transform: uppercase; margin-bottom: 4px; }
.score-val  { font-size: 1.5rem; font-weight: 700; color: var(--text-primary); }
.score-t    { font-size: .8rem;  color: var(--text-secondary); }

.score-item.risk-high { border-color: var(--danger); background: var(--danger-bg); }
.score-item.risk-high .score-val { color: var(--danger); }

/* Estilos para el reporte detallado */
.report-alert-danger {
    background: var(--danger-bg);
    color: var(--danger);
    border: 1px solid #FECACA;
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 24px;
    font-weight: 600;
    font-size: 0.95rem;
}
.report-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 12px;
    font-size: 0.85rem;
    background: var(--surface);
}
.report-table th, .report-table td {
    padding: 10px 12px;
    border: 1px solid var(--border);
    text-align: left;
}
.report-table th {
    background: var(--surface-alt);
    font-weight: 600;
    color: var(--text-secondary);
}
.report-table tr:nth-child(even) {
    background: var(--surface-alt);
}
.score-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.75rem;
}
.score-badge-neutral { background: var(--border); color: var(--text-primary); }
.score-badge-positive { background: var(--teal-light); color: var(--teal-dark); }
.score-badge-alert { background: var(--danger-bg); color: var(--danger); }

.no-print-break {
    page-break-inside: avoid;
    break-inside: avoid;
}

@media print {
    .sidebar, .btn, .no-print { display: none !important; }
    .admin-main { margin-left: 0 !important; padding: 0 !important; max-width: 100% !important; }
    body { background: white; color: black; }
    .card { box-shadow: none; border: none; }
    .card-body { padding: 0; }
    .report-table { font-size: 0.75rem; }
    .report-table th, .report-table td { padding: 6px 8px; }
}

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar {
        width: 100%;
        height: auto;
        position: static;
        flex-direction: row;
        padding: 0;
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .sidebar-nav {
        display: flex;
        padding: 8px;
        overflow-x: auto;
    }

    .nav-item { white-space: nowrap; }

    .admin-main {
        margin-left: 0;
        padding: 20px 16px;
    }

    .form-row { grid-template-columns: 1fr; }

    .stats-row { grid-template-columns: 1fr 1fr; }

    .page-header { flex-direction: column; align-items: flex-start; }
}

/* ─── Wizard 1 Pregunta por Pantalla & Cuestionario UI ────────────────────── */
.wizard-container {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
}

.wizard-step {
    display: none;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}

.wizard-step.active {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.wizard-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px 28px;
    box-shadow: var(--shadow-md);
    margin-bottom: 24px;
}

.wizard-question-number {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--teal-dark);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

.wizard-question-text {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.45;
    margin-bottom: 28px;
}

.wizard-options-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
}

.wizard-option-btn {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    background: var(--surface-alt);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    color: var(--text-primary);
    transition: all 0.2s ease;
    user-select: none;
}

.wizard-option-btn:hover {
    border-color: var(--teal);
    background: var(--teal-light);
}

.wizard-option-btn.selected {
    border-color: var(--teal);
    background: var(--teal-light);
    color: var(--teal-dark);
    font-weight: 700;
    box-shadow: 0 0 0 3px rgba(13, 148, 136, 0.15);
}

.wizard-option-circle {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 2px solid var(--border-focus);
    margin-right: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.wizard-option-btn.selected .wizard-option-circle {
    background: var(--teal);
    border-color: var(--teal);
}

.wizard-option-btn.selected .wizard-option-circle::after {
    content: '';
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: white;
}

.wizard-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 24px;
    gap: 16px;
}

.camera-preview-box {
    position: fixed;
    bottom: 24px;
    left: 24px;
    width: 140px;
    height: 105px;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid var(--teal);
    box-shadow: var(--shadow-md);
    z-index: 1000;
}

.camera-preview-box video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.camera-badge {
    position: absolute;
    top: 6px;
    left: 6px;
    background: rgba(13, 148, 136, 0.85);
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.camera-dot {
    width: 6px;
    height: 6px;
    background: #22c55e;
    border-radius: 50%;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.2); }
    100% { opacity: 1; transform: scale(1); }
}
