/* ============================================================
   INFORME DE RESULTADOS
   La pantalla que sale al terminar un examen. Antes era un confirm()
   del navegador: el alumno acababa su diagnostico y lo unico que veia
   era "1 of 20 (5%)" en una caja gris del sistema. Este es el momento
   en que mas le importa el resultado, asi que aqui va el analisis
   completo y, si todavia no tiene plan, la oferta.
   Usa los mismos tokens de marca que style.css / shell.css.
   ============================================================ */

#results-screen.rp {
    display: none;
    overflow-y: auto;
    padding: 0;
    align-items: flex-start;
}
#results-screen.rp.active { display: block; }

.rp-wrap {
    width: 100%;
    max-width: 1180px;
    margin: 0 auto;
    padding: clamp(1rem, 3vw, 2.4rem) clamp(1rem, 3vw, 2rem) 4rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

/* --- veredicto --- */
.rp-hero {
    position: relative; overflow: hidden;
    display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 2rem;
    padding: clamp(1.5rem, 3vw, 2.4rem);
    border-radius: 24px;
    color: #fff;
    background:
        linear-gradient(rgba(255,255,255,0.045) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.045) 1px, transparent 1px),
        radial-gradient(60% 90% at 90% 20%, rgba(30,143,91,0.42), transparent 60%),
        radial-gradient(50% 80% at 10% 110%, rgba(46,110,158,0.55), transparent 60%),
        linear-gradient(135deg, #173a5e 0%, #10294a 60%, #0e2a3f 100%);
    background-size: 32px 32px, 32px 32px, auto, auto, auto;
    box-shadow: 0 24px 50px -28px rgba(13, 33, 54, 0.75);
}
.rp-hero::after {
    content: ''; position: absolute; right: -60px; bottom: -80px; width: 260px; height: 260px;
    border-radius: 50%; border: 1px dashed rgba(255,255,255,0.12); pointer-events: none;
}
.rp-eyebrow { font-family: var(--font-mono); font-size: 0.68rem; letter-spacing: 0.16em; text-transform: uppercase; color: #9fc0dc; }
.rp-verdict {
    font-family: var(--font-display); font-weight: 800; letter-spacing: -0.02em;
    font-size: clamp(1.7rem, 3.4vw, 2.5rem); margin: 0.4rem 0 0.55rem; text-wrap: balance;
}
.rp-lede { color: #c9d8e6; font-size: 1rem; line-height: 1.6; max-width: 58ch; }
.rp-lede strong { color: #fff; }
.rp-gauge { position: relative; width: 230px; text-align: center; flex: none; }
.rp-gauge svg { width: 100%; height: auto; overflow: visible; }

/* barra contra el 70% */
.rp-bench { margin-top: 1.4rem; max-width: 58ch; }
.rp-bench-track {
    position: relative; height: 10px; border-radius: 999px;
    background: rgba(255,255,255,0.14); overflow: visible;
}
.rp-bench-fill {
    height: 100%; border-radius: 999px;
    background: linear-gradient(90deg, #6aa6d6, #7fd6aa);
    transition: width 0.9s cubic-bezier(0.22, 1, 0.36, 1);
}
.rp-bench-fill.is-low { background: linear-gradient(90deg, #d98b6a, #e0b15f); }
.rp-bench-mark {
    position: absolute; top: -5px; width: 2px; height: 20px;
    background: #f0cf8a; border-radius: 2px;
}
.rp-bench-labels {
    display: flex; justify-content: space-between; margin-top: 0.5rem;
    font-family: var(--font-mono); font-size: 0.66rem; letter-spacing: 0.08em; color: #9fc0dc;
}

/* --- cifras --- */
.rp-kpis { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 0.9rem; }
.rp-kpi {
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: 16px;
    padding: 1.1rem 1.2rem; display: flex; flex-direction: column; gap: 0.3rem;
}
.rp-kpi-label { font-family: var(--font-mono); font-size: 0.64rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-muted); }
.rp-kpi-value {
    font-family: var(--font-display); font-weight: 800; font-size: 1.9rem; color: var(--text-main);
    letter-spacing: -0.02em; font-variant-numeric: tabular-nums;
}
.rp-kpi-value small { font-size: 0.95rem; font-weight: 700; color: var(--text-muted); margin-left: 0.1rem; }
.rp-kpi-sub { font-size: 0.78rem; color: var(--text-muted); }
.rp-kpi-sub.good { color: var(--success); font-weight: 600; }
.rp-kpi-sub.bad { color: var(--error); font-weight: 600; }

/* --- paneles --- */
.rp-cols { display: grid; grid-template-columns: 1.35fr 1fr; gap: 1.25rem; align-items: start; }
.rp-panel {
    background: var(--bg-panel); border: 1px solid var(--border); border-radius: 20px;
    padding: 1.4rem 1.5rem;
}
.rp-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 0.35rem; }
.rp-panel-head h2 { font-family: var(--font-display); font-size: 1.1rem; font-weight: 800; color: var(--text-main); letter-spacing: -0.01em; }
.rp-panel-sub { font-size: 0.84rem; color: var(--text-muted); line-height: 1.55; margin-bottom: 1.1rem; max-width: 62ch; }
.rp-chip {
    font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.12em; text-transform: uppercase;
    padding: 0.3rem 0.6rem; border-radius: 999px; white-space: nowrap;
    background: var(--panel-soft); border: 1px solid var(--border); color: var(--text-muted);
}
.rp-chip.bad { background: #fdeceb; border-color: rgba(198,67,63,0.25); color: var(--error); }
.rp-chip.good { background: var(--accent-soft); border-color: rgba(30,143,91,0.25); color: var(--success); }

/* filas de tema */
.rp-row { display: flex; align-items: center; gap: 0.85rem; padding: 0.7rem 0; border-top: 1px solid var(--border); }
.rp-row:first-child { border-top: none; }
.rp-rank {
    flex: none; width: 26px; height: 26px; border-radius: 8px;
    display: grid; place-items: center;
    font-family: var(--font-mono); font-size: 0.72rem; font-weight: 700;
    background: var(--primary); color: #fff;
}
.rp-row.is-strong .rp-rank { background: var(--accent-soft); color: var(--success); }
.rp-row-body { flex: 1; min-width: 0; }
.rp-row-name { font-weight: 700; font-size: 0.88rem; color: var(--text-main); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-row-meta { font-size: 0.74rem; color: var(--text-muted); margin-top: 0.12rem; }
.rp-row-pct {
    flex: none; font-family: var(--font-display); font-weight: 800; font-size: 1.05rem;
    color: var(--text-main); font-variant-numeric: tabular-nums;
}
.rp-row-pct.bad { color: var(--error); }
.rp-row-pct.good { color: var(--success); }
.rp-bar { margin-top: 0.4rem; height: 5px; border-radius: 999px; background: var(--panel-soft); overflow: hidden; }
.rp-bar span { display: block; height: 100%; border-radius: 999px; background: var(--secondary); }
.rp-bar span.bad { background: var(--error); }
.rp-bar span.good { background: var(--success); }
.rp-empty { font-size: 0.84rem; color: var(--text-muted); line-height: 1.55; padding: 0.6rem 0; }

/* --- tabla --- */
.rp-table-wrap { overflow-x: auto; margin-top: 0.9rem; }
/* Igual que en disciplina.css: el table{display:block} global de
   style.css impide que las celdas se repartan el ancho. */
.rp-table { display: table; white-space: normal; width: 100%; border-collapse: collapse; font-size: 0.84rem; min-width: 620px; }
.rp-table th {
    text-align: left; padding: 0.55rem 0.7rem; border-bottom: 1px solid var(--border-strong);
    font-family: var(--font-mono); font-size: 0.62rem; letter-spacing: 0.12em;
    text-transform: uppercase; color: var(--text-muted); font-weight: 600; white-space: nowrap;
}
.rp-table td { padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--border); color: var(--text-main); }
.rp-table td:not(:first-child) { font-variant-numeric: tabular-nums; white-space: nowrap; }
.rp-table tr.is-weak td:first-child { font-weight: 700; }
.rp-table tr.is-weak { background: rgba(198, 67, 63, 0.045); }
.rp-table .rp-td-acc { font-weight: 700; }
.rp-table .rp-td-acc.bad { color: var(--error); }
.rp-table .rp-td-acc.good { color: var(--success); }
.rp-table .rp-td-none { color: var(--text-muted); font-style: italic; }
/* el "x de y" solo hace falta cuando se ocultan las columnas de detalle */
.rp-td-sub { display: none; }

/* --- la oferta --- */
.rp-offer {
    display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 1.5rem;
    border-radius: 22px; padding: clamp(1.4rem, 3vw, 2.1rem);
    color: #fff; position: relative; overflow: hidden;
    background:
        radial-gradient(70% 120% at 85% 0%, rgba(184,135,47,0.35), transparent 60%),
        linear-gradient(135deg, #142f4d 0%, #0e2440 100%);
    border: 1px solid rgba(240, 207, 138, 0.22);
    box-shadow: 0 24px 50px -30px rgba(13, 33, 54, 0.8);
}
.rp-offer-tag {
    display: inline-block; font-family: var(--font-mono); font-size: 0.62rem;
    letter-spacing: 0.16em; text-transform: uppercase; color: #f0cf8a;
    border: 1px solid rgba(240,207,138,0.35); border-radius: 999px; padding: 0.3rem 0.7rem;
}
.rp-offer h2 {
    font-family: var(--font-display); font-weight: 800; letter-spacing: -0.02em;
    font-size: clamp(1.3rem, 2.4vw, 1.75rem); margin: 0.75rem 0 0.5rem; text-wrap: balance;
}
.rp-offer p { color: #c9d8e6; font-size: 0.93rem; line-height: 1.6; max-width: 54ch; }
.rp-offer-list { list-style: none; margin: 1.1rem 0 0; display: flex; flex-direction: column; gap: 0.5rem; }
.rp-offer-list li { display: flex; align-items: flex-start; gap: 0.55rem; font-size: 0.88rem; color: #dce7f1; }
.rp-offer-list li::before { content: '✓'; color: #7fd6aa; font-weight: 700; flex: none; }
.rp-offer-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 0.85rem; margin-top: 1.4rem; }
.rp-btn-gold {
    border: none; cursor: pointer; border-radius: 12px; padding: 0.85rem 1.4rem;
    font-family: var(--font-body); font-weight: 700; font-size: 0.92rem;
    background: linear-gradient(135deg, #f0cf8a, #d8a84e); color: #22160a;
    box-shadow: 0 12px 26px -12px rgba(216, 168, 78, 0.85);
    transition: transform 0.2s, box-shadow 0.2s;
}
.rp-btn-gold:hover { transform: translateY(-1px); box-shadow: 0 16px 30px -12px rgba(216,168,78,0.95); }
.rp-offer-note { font-size: 0.78rem; color: #9fc0dc; }

.rp-offer-side { display: flex; flex-direction: column; gap: 0.6rem; justify-content: center; }
.rp-gap {
    background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12);
    border-radius: 14px; padding: 0.8rem 0.95rem;
}
.rp-gap-name { font-weight: 700; font-size: 0.85rem; color: #fff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rp-gap-meta { font-family: var(--font-mono); font-size: 0.68rem; color: #9fc0dc; margin-top: 0.2rem; letter-spacing: 0.04em; }

/* --- acciones --- */
.rp-actions { display: flex; flex-wrap: wrap; gap: 0.85rem; justify-content: center; margin-top: 0.5rem; }
.rp-btn-main, .rp-btn-ghost {
    display: inline-flex; align-items: center; justify-content: center; gap: 0.55rem;
    padding: 0.9rem 1.5rem; border-radius: 12px; cursor: pointer;
    font-family: var(--font-body); font-weight: 700; font-size: 0.92rem;
    transition: transform 0.2s, background 0.2s;
}
.rp-btn-main { background: var(--primary); color: #fff; border: none; }
.rp-btn-main .ico { width: 16px; height: 16px; fill: currentColor; stroke: none; }
.rp-btn-main:hover { background: var(--primary-hover); transform: translateY(-1px); }
.rp-btn-ghost { background: transparent; color: var(--text-main); border: 1px solid var(--border-strong); }
.rp-btn-ghost:hover { background: var(--panel-soft); }

/* --- angosto --- */
@media (max-width: 900px) {
    .rp-hero { grid-template-columns: 1fr; }
    .rp-gauge { width: 200px; margin: 0 auto; }
    .rp-kpis { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .rp-cols { grid-template-columns: 1fr; }
    .rp-offer { grid-template-columns: 1fr; }
}
/* En movil la tabla no cabe entera. Arrastrar de lado esconde justo la
   columna que importa (Accuracy), asi que se recortan las de detalle y
   el "x de y" pasa a la celda del tema. */
@media (max-width: 700px) {
    .rp-col-opt { display: none; }
    .rp-table { min-width: 0; }
    .rp-table-wrap { overflow-x: visible; }
    .rp-td-sub {
        display: block; margin-top: 0.15rem;
        font-family: var(--font-mono); font-size: 0.66rem; color: var(--text-muted); white-space: nowrap;
    }
    .rp-table td:first-child { white-space: normal; }
}
@media (max-width: 520px) {
    .rp-kpis { grid-template-columns: 1fr 1fr; }
    .rp-actions { flex-direction: column; }
    .rp-btn-main, .rp-btn-ghost { width: 100%; }
    .rp-btn-main { text-align: left; }
}

/* ---------------------------------------------------------------
   Estado del pago al volver de Stripe.
   Flota sobre cualquier pantalla porque el cliente puede aterrizar en
   la portada o en el panel, y este aviso es lo primero que necesita
   leer: si su dinero llego y si ya tiene lo que compro.
   --------------------------------------------------------------- */
.pay-status {
    position: fixed;
    z-index: 1200;                 /* por encima del paywall (1000) */
    top: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    width: min(540px, calc(100vw - 2rem));
    box-sizing: border-box;
    padding: 1.15rem 1.35rem;
    border-radius: 14px;
    border: 1px solid var(--border);
    border-left: 5px solid var(--primary);
    background: var(--card, #fff);
    box-shadow: 0 18px 48px rgba(15, 23, 42, 0.22);
    text-align: left;
    animation: pay-entra 0.28s ease-out;
}
@keyframes pay-entra {
    from { opacity: 0; transform: translate(-50%, -12px); }
    to   { opacity: 1; transform: translate(-50%, 0); }
}
.pay-status[hidden] { display: none; }
.pay-status h3 { margin: 0 0 0.4rem; font-size: 1.08rem; line-height: 1.3; }
.pay-status p  { margin: 0 0 0.5rem; font-size: 0.92rem; line-height: 1.5; color: var(--text-muted, #475569); }
.pay-status .pay-ref { font-size: 0.8rem; }
.pay-status .pay-ref code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 0.76rem;
    word-break: break-all;
    background: rgba(15, 23, 42, 0.06);
    padding: 0.12rem 0.35rem;
    border-radius: 5px;
}
.pay-status .pay-acciones { display: flex; gap: 0.6rem; flex-wrap: wrap; margin-top: 0.75rem; }
.pay-status .pay-acciones button { flex: 1 1 auto; min-width: 150px; }

.pay-status.is-ok   { border-left-color: var(--success, #16a34a); }
.pay-status.is-wait { border-left-color: var(--primary, #2563eb); }
.pay-status.is-bad  { border-left-color: var(--error, #dc2626); }

@media (max-width: 600px) {
    .pay-status { top: 0.75rem; padding: 1rem; }
}
