/* ════════════════════════════════════════════════════════════
   Estética compartida — clonada del index.html de referencia
   (glassmorphism, gradiente animado, acentos índigo/violeta)
   ════════════════════════════════════════════════════════════ */
:root {
    --bg-color: #0a0a0f;
    --card-color: rgba(26, 26, 35, 0.7);
    --text-color: #f0f0f0;
    --accent-color: #6366f1;
    --accent-secondary: #8b5cf6;
    --input-bg: rgba(34, 34, 42, 0.6);
    --border-color: rgba(99, 102, 241, 0.2);
    --error-color: #ff5c5c;
    --success-color: #10b981;
    --warn-color: #f59e0b;
    --highlight-bg: rgba(99, 102, 241, 0.1);
    --shadow-color: rgba(99, 102, 241, 0.3);
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    background: linear-gradient(135deg, #0a0a0f 0%, #1a1a2e 50%, #16213e 100%);
    background-size: 400% 400%;
    animation: gradientShift 15s ease infinite;
    color: var(--text-color);
    font-family: "Open Sans", sans-serif;
    min-height: 100vh;
    padding: 15px;
    overflow-x: hidden;
}
body.centered { display: flex; justify-content: center; align-items: center; }
@keyframes gradientShift { 0% { background-position: 0% 50%; } 50% { background-position: 100% 50%; } 100% { background-position: 0% 50%; } }

.container {
    background: var(--card-color);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    padding: 40px;
    border-radius: 24px;
    border: 1px solid var(--border-color);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5), 0 0 60px var(--shadow-color);
    width: 100%;
    max-width: 600px;
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 480px;
    overflow: hidden;
    animation: containerEntry 0.8s;
}
@keyframes containerEntry { from { opacity: 0; transform: translateY(30px) scale(0.95); } to { opacity: 1; transform: translateY(0) scale(1); } }

.logo-container { display: flex; flex-direction: column; align-items: center; margin-bottom: 25px; }
.logo-container img { max-width: 200px; filter: brightness(0) invert(1) drop-shadow(0 0 20px rgba(99, 102, 241, 0.5)); }
.logo-container.large-logo img { max-width: 300px; }

.steps-wrapper { position: relative; flex-grow: 1; overflow: hidden; z-index: 2; }
.step { display: none; width: 100%; animation-duration: 0.5s; animation-fill-mode: forwards; }
.step.active { display: block; animation-name: slideInRight; }
@keyframes slideInRight { from { opacity: 0; transform: translateX(40px); } to { opacity: 1; transform: translateX(0); } }

h1, h2 {
    background: linear-gradient(135deg, var(--accent-color), var(--accent-secondary));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text;
    font-weight: 700;
}
h1 { font-size: 1.9rem; margin-bottom: 10px; }
h2 { font-size: 1.5rem; margin-bottom: 18px; line-height: 1.3; }
.subtitle { color: #b8b8c8; font-size: 1rem; margin-bottom: 22px; font-style: italic; }

.intro-text p { line-height: 1.6; margin-bottom: 14px; color: #ccc; font-size: 0.95rem; }
.block-tag { display: inline-block; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase;
    color: var(--accent-secondary); background: var(--highlight-bg); padding: 5px 12px; border-radius: 20px; margin-bottom: 14px; font-weight: 600; }
.help-text { color: #9a9aac; font-size: 0.88rem; margin-bottom: 14px; }

label { display: block; margin: 16px 0 6px; font-weight: 500; font-size: 1rem; }
input, select, textarea {
    width: 100%; padding: 15px; border-radius: 12px; border: 2px solid var(--border-color);
    background: var(--input-bg); color: white; font-size: 1rem; font-family: "Open Sans", sans-serif;
    outline: none; transition: 0.3s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent-color); background: rgba(34, 34, 42, 0.85); }
textarea { resize: vertical; min-height: 110px; }
.char-count { text-align: right; font-size: 0.78rem; color: #888; margin-top: 4px; }

.btn-group { margin-top: 28px; display: flex; justify-content: space-between; gap: 15px; }
button {
    padding: 15px 30px; border: none; border-radius: 12px; cursor: pointer; font-weight: 600; font-size: 1rem;
    font-family: "Open Sans", sans-serif; transition: 0.3s; position: relative; z-index: 10;
}
button.next, button.primary { background: linear-gradient(135deg, var(--accent-color), var(--accent-secondary)); color: white; flex-grow: 2; }
button.prev, button.ghost { background: rgba(255, 255, 255, 0.08); border: 2px solid var(--border-color); color: #ccc; flex-grow: 1; }
button:hover { transform: translateY(-3px); box-shadow: 0 8px 20px var(--shadow-color); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.progress-container { background: rgba(255, 255, 255, 0.05); height: 6px; border-radius: 10px; margin-bottom: 22px; overflow: hidden; }
.progress-fill { background: linear-gradient(90deg, var(--accent-color), var(--accent-secondary)); width: 0%; height: 100%; transition: width 0.5s; }
.page-counter { text-align: right; font-size: 0.82rem; color: #888; margin-bottom: 6px; height: 16px; }

.validation-message { color: var(--error-color); font-size: 0.85rem; margin-top: 10px; display: none; padding: 9px; background: rgba(255,92,92,0.1); border-radius: 8px; }
.validation-message.show { display: block; }
.input-error { border-color: var(--error-color) !important; }

/* Opciones (radio / checkbox) */
.option-grid { display: grid; gap: 10px; max-height: 52vh; overflow-y: auto; padding-right: 4px; }
.option-card { display: flex; align-items: center; gap: 12px; padding: 13px 15px; border: 2px solid var(--border-color);
    background: rgba(34,34,42,0.45); border-radius: 14px; cursor: pointer; transition: 0.2s; }
.option-card:hover { border-color: rgba(99,102,241,0.5); background: rgba(34,34,42,0.65); }
.option-card.selected { border-color: var(--accent-color); background: rgba(99,102,241,0.18); }
.option-card input { width: 19px; height: 19px; margin: 0; flex: 0 0 auto; accent-color: var(--accent-color); }
.option-card.disabled { opacity: 0.4; pointer-events: none; }
.counter-badge { font-size: 0.85rem; color: var(--accent-secondary); margin-bottom: 10px; font-weight: 600; }
.other-input { margin-top: 10px; }

/* Rejilla de edad */
.age-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.age-cell { text-align: center; padding: 12px 0; border: 2px solid var(--border-color); border-radius: 10px; cursor: pointer; transition: 0.2s; font-weight: 600; }
.age-cell:hover { border-color: var(--accent-color); }
.age-cell.selected { background: linear-gradient(135deg, var(--accent-color), var(--accent-secondary)); border-color: transparent; }

/* Escala 0–10 / 1–5 */
.scale-wrap { margin-top: 10px; }
.scale-btns { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; }
.scale-btn { width: 46px; height: 46px; border-radius: 10px; border: 2px solid var(--border-color); background: var(--input-bg);
    color: #ddd; cursor: pointer; font-weight: 600; transition: 0.2s; }
.scale-btn:hover { border-color: var(--accent-color); }
.scale-btn.selected { background: linear-gradient(135deg, var(--accent-color), var(--accent-secondary)); border-color: transparent; color: #fff; transform: scale(1.08); }
.scale-labels { display: flex; justify-content: space-between; font-size: 0.8rem; color: #999; margin-top: 8px; }

/* Matriz */
.matrix { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
.matrix th { color: #b8b8c8; font-weight: 500; padding: 6px 4px; text-align: center; font-size: 0.78rem; }
.matrix td { padding: 8px 4px; text-align: center; border-top: 1px solid var(--border-color); }
.matrix td.row-label { text-align: left; font-weight: 500; color: #e8e8f0; }
.matrix input { width: 18px; height: 18px; accent-color: var(--accent-color); }
.matrix-scale-row { display: flex; align-items: center; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border-color); }
.matrix-scale-row .lbl { flex: 1; font-weight: 500; }
.matrix-scale-row .val { width: 38px; text-align: center; color: var(--accent-secondary); font-weight: 700; }
.matrix-scale-row input[type=range] { flex: 2; accent-color: var(--accent-color); }

/* Mensajes globales */
.message-box { text-align: center; padding: 20px; }
.message-box .big { font-size: 1.5rem; font-weight: 700; margin-bottom: 10px; }

.consent-box { background: rgba(34,34,42,0.5); border: 1px solid var(--border-color); border-radius: 14px; padding: 16px; margin-top: 16px; }
.consent-box label { display: flex; gap: 10px; align-items: flex-start; font-size: 0.9rem; font-weight: 400; margin: 12px 0 0; cursor: pointer; }
.consent-box input { width: 20px; height: 20px; flex: 0 0 auto; accent-color: var(--accent-color); margin-top: 2px; }

@media (max-width: 600px) {
    .container { padding: 22px; }
    .btn-group { flex-direction: column-reverse; }
    .age-grid { grid-template-columns: repeat(4, 1fr); }
}

/* ════════ Panel admin / dashboard ════════ */
body.admin { display: block; padding: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 14px 28px;
    background: rgba(16,16,24,0.85); backdrop-filter: blur(14px); border-bottom: 1px solid var(--border-color);
    position: sticky; top: 0; z-index: 50; }
.topbar img { height: 34px; filter: brightness(0) invert(1); }
.topbar .links { display: flex; gap: 8px; flex-wrap: wrap; }
.tab { padding: 9px 16px; border-radius: 10px; cursor: pointer; color: #bbb; font-weight: 500; font-size: 0.92rem; border: 1px solid transparent; }
.tab:hover { background: rgba(255,255,255,0.06); }
.tab.active { background: var(--highlight-bg); color: #fff; border-color: var(--border-color); }
.wrap { max-width: 1200px; margin: 0 auto; padding: 26px; }
.panel { display: none; }
.panel.active { display: block; animation: slideInRight 0.4s; }

.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 26px; }
.card { background: var(--card-color); border: 1px solid var(--border-color); border-radius: 18px; padding: 22px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3); }
.card .num { font-size: 2.4rem; font-weight: 700;
    background: linear-gradient(135deg, var(--accent-color), var(--accent-secondary));
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.card .lbl { color: #aaa; font-size: 0.9rem; margin-top: 4px; }
.live-dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; background: var(--success-color); margin-right: 6px; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.3; } }

.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: end; margin-bottom: 18px; }
.toolbar .fld { display: flex; flex-direction: column; gap: 4px; }
.toolbar label { margin: 0; font-size: 0.8rem; color: #999; }
.toolbar input, .toolbar select { padding: 9px 11px; font-size: 0.9rem; width: auto; min-width: 130px; }
.toolbar button { padding: 10px 16px; font-size: 0.9rem; }

table.data { width: 100%; border-collapse: collapse; background: var(--card-color); border-radius: 14px; overflow: hidden; font-size: 0.88rem; }
table.data th { background: rgba(99,102,241,0.18); padding: 12px 14px; text-align: left; font-weight: 600; }
table.data td { padding: 11px 14px; border-top: 1px solid var(--border-color); }
table.data tbody tr { cursor: pointer; transition: 0.15s; }
table.data tbody tr:hover { background: rgba(99,102,241,0.1); }
.pager { display: flex; gap: 10px; align-items: center; justify-content: center; margin-top: 18px; }

.modal-bg { position: fixed; inset: 0; background: rgba(0,0,0,0.7); display: none; align-items: center; justify-content: center; z-index: 100; padding: 20px; }
.modal-bg.show { display: flex; }
.modal { background: #14141c; border: 1px solid var(--border-color); border-radius: 18px; max-width: 700px; width: 100%; max-height: 85vh; overflow-y: auto; padding: 28px; }
.modal h3 { margin-bottom: 16px; color: var(--accent-secondary); }
.modal .qa { padding: 10px 0; border-bottom: 1px solid var(--border-color); }
.modal .qa .q { font-size: 0.8rem; color: #999; }
.modal .qa .a { font-size: 0.98rem; margin-top: 2px; }

.chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 20px; }
.chart-box { background: var(--card-color); border: 1px solid var(--border-color); border-radius: 18px; padding: 20px; }
.chart-box h4 { font-size: 0.95rem; margin-bottom: 14px; color: #ddd; font-weight: 600; }
.chart-box canvas { max-height: 280px; }
.switch { display: inline-flex; align-items: center; gap: 10px; }
.badge-priv { padding: 5px 12px; border-radius: 20px; font-size: 0.8rem; font-weight: 600; }
.badge-priv.public { background: rgba(16,185,129,0.18); color: var(--success-color); }
.badge-priv.private { background: rgba(245,158,11,0.18); color: var(--warn-color); }


/* ════════ Subtítulo de marca + reanudar + animaciones direccionales ════════ */
.brand-subtitle { text-align: center; color: var(--accent-secondary); font-weight: 600;
    font-size: 0.92rem; margin-top: -12px; margin-bottom: 18px; letter-spacing: 0.02em; }

.resume-banner { background: var(--highlight-bg); border: 1px solid var(--border-color);
    border-radius: 14px; padding: 14px 16px; margin-bottom: 18px; font-size: 0.92rem; color: #e8e8f0; }
.resume-banner .resume-actions { display: flex; gap: 10px; margin-top: 12px; }
.resume-banner button { padding: 10px 16px; font-size: 0.9rem; flex: 1; }

/* Transición entre pasos según dirección (adelante / atrás) */
.step.active { animation-name: slideInRight; }
.step.active.dir-back { animation-name: slideInLeft; }
@keyframes slideInLeft { from { opacity: 0; transform: translateX(-40px); } to { opacity: 1; transform: translateX(0); } }

/* Progreso con numeración centrada */
.page-counter { text-align: center; font-weight: 600; color: var(--accent-secondary); }

/* ════════ Mejoras específicas para MÓVIL ════════ */
@media (max-width: 600px) {
    body { padding: 0; }
    body.centered { align-items: stretch; }
    .container { padding: 20px 18px 0; border-radius: 0; min-height: 100vh; max-width: 100%; box-shadow: none; }
    .logo-container.large-logo img { max-width: 220px; }
    h1 { font-size: 1.5rem; }
    h2 { font-size: 1.25rem; }
    /* Inputs grandes para dedos y SIN zoom en iOS (font-size >= 16px) */
    input, select, textarea, button { font-size: 16px; }
    .option-card { padding: 15px; }
    .option-grid { max-height: none; }            /* el scroll lo lleva el paso */
    .age-grid { grid-template-columns: repeat(4, 1fr); gap: 7px; }
    .scale-btn { width: 42px; height: 42px; }
    .matrix { font-size: 0.8rem; }
    .step { max-height: calc(100vh - 230px); overflow-y: auto; -webkit-overflow-scrolling: touch; }
    /* Botones fijos abajo, fáciles de pulsar */
    .btn-group { position: sticky; bottom: 0; background: linear-gradient(to top, var(--bg-color) 70%, transparent);
        padding: 12px 0 16px; margin-top: 18px; flex-direction: row; }
    button.next, button.primary { flex-grow: 2; }
    button.prev { flex-grow: 1; }
}
