/* ============================================================
   CellView — viewer.css
   ============================================================ */

/* --- Layout principal --- */
.viewer-layout {
    display: grid;
    grid-template-columns: 1fr 460px;
    grid-template-rows: calc(100vh - 64px);
    height: calc(100vh - 64px);
    margin-top: 64px;
    padding-top: 0;
}

/* --- Stage 3D --- */
.viewer-stage {
    position: relative;
    background: var(--navy);
    overflow: hidden;
}

.viewer-stage__embed {
    position: absolute;
    inset: 0;
}
.viewer-stage__embed iframe {
    width: 100%;
    height: 100%;
    border: none;
}

/* Overlay de carga */
.viewer-stage__loading {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    background: var(--navy);
    z-index: 10;
    transition: opacity var(--t-slow);
}
.viewer-stage__loading.hidden { opacity: 0; pointer-events: none; }
.viewer-stage__loading p { font-size: .875rem; color: var(--gray-500); }

/* Breadcrumb flotante */
.viewer-breadcrumb {
    position: absolute;
    top: 1rem;
    left: 1rem;
    z-index: 20;
    display: flex;
    align-items: center;
    gap: .4rem;
    font-size: .75rem;
    color: var(--gray-500);
    background: rgba(11,23,54,.75);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: .35rem .75rem;
    border-radius: 100px;
    border: 1px solid rgba(255,255,255,.08);
}
.viewer-breadcrumb a { color: var(--gray-500); }
.viewer-breadcrumb a:hover { color: var(--sky); }
.viewer-breadcrumb span { color: var(--gray-300); }

/* ── QUIZ OVERLAY ──────────────────────────────────────────── */
.quiz-overlay {
    position: absolute;
    inset: 0;
    z-index: 30;
    display: flex;
    flex-direction: column;
    opacity: 0;
    pointer-events: none;
    transform: translateY(12px);
    transition: opacity .25s ease, transform .25s ease;
    background: rgba(11, 23, 54, 0.72);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
}

.quiz-overlay.active {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0);
}

.quiz-overlay__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.1rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,.08);
    background: rgba(255,255,255,.04);
    flex-shrink: 0;
}

.quiz-overlay__meta {
    display: flex;
    align-items: center;
    gap: .85rem;
}

.quiz-overlay__emoji {
    font-size: 1.75rem;
    line-height: 1;
}

.quiz-overlay__titulo {
    font-size: 1rem;
    font-weight: 800;
    color: var(--white);
    line-height: 1.2;
}

.quiz-overlay__subtitulo {
    font-size: .75rem;
    color: var(--gray-500);
    margin-top: .15rem;
}

.quiz-overlay__close {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255,255,255,.07);
    border: 1px solid rgba(255,255,255,.1);
    color: var(--gray-300);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background .15s, color .15s;
    flex-shrink: 0;
}
.quiz-overlay__close:hover { background: rgba(255,80,80,.15); color: #f87171; border-color: rgba(255,80,80,.3); }

.quiz-overlay__body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem 2rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,.1) transparent;
}
.quiz-overlay__body::-webkit-scrollbar       { width: 4px; }
.quiz-overlay__body::-webkit-scrollbar-track { background: transparent; }
.quiz-overlay__body::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 999px; }

/* --- Panel lateral --- */
.viewer-panel {
    background: var(--navy-mid);
    border-left: 1px solid var(--gray-700);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}


/* Header del panel */
.panel-header {
    padding: 1.25rem 1.5rem 1rem;
    border-bottom: 1px solid var(--gray-700);
    flex-shrink: 0;
    max-height: 35%;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--gray-700) transparent;
}
.panel-header::-webkit-scrollbar       { width: 4px; }
.panel-header::-webkit-scrollbar-track { background: transparent; }
.panel-header::-webkit-scrollbar-thumb { background: var(--gray-700); border-radius: 2px; }
.panel-header__cat   { margin-bottom: .4rem; }
.panel-header__title { font-size: 1.3rem; font-weight: 800; color: var(--white); margin-bottom: .5rem; line-height: 1.25; }
.panel-header__desc  { font-size: .82rem; color: var(--gray-500); line-height: 1.5; }

/* ── Section label — estilo app ───────────────────────────── */
.panel-section-label {
    padding: .55rem 1.25rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: .5rem;
    background: linear-gradient(180deg, rgba(59,158,204,.06) 0%, transparent 100%);
    border-bottom: 1px solid rgba(59,158,204,.12);
}
.panel-section-label span {
    font-size: .65rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--sky);
    opacity: .7;
}

/* ── Sub-tabs pill ────────────────────────────────────────── */
.panel-subtabs {
    display: flex;
    gap: .3rem;
    padding: .6rem 1rem;
    border-bottom: 1px solid var(--gray-700);
    flex-shrink: 0;
    background: rgba(0,0,0,.1);
}

.panel-subtab {
    padding: .3rem .85rem;
    border-radius: 999px;
    border: 1px solid var(--gray-700);
    background: transparent;
    color: var(--gray-500);
    font-family: inherit;
    font-size: .72rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}
.panel-subtab:hover:not(.panel-subtab--soon) { border-color: var(--sky); color: var(--gray-100); }
.panel-subtab.active { background: var(--sky); border-color: var(--sky); color: #fff; }
.panel-subtab--soon  { opacity: .35; cursor: default; font-style: italic; }

/* Contenido scrolleable */
.panel-content {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
    padding: 1.1rem 1.25rem;
    scrollbar-width: thin;
    scrollbar-color: var(--gray-700) transparent;
}
.panel-content::-webkit-scrollbar       { width: 4px; }
.panel-content::-webkit-scrollbar-track { background: transparent; }
.panel-content::-webkit-scrollbar-thumb { background: var(--gray-700); border-radius: 2px; }

.subtab-panel        { display: none; }
.subtab-panel.active { display: block; }

/* Empty state genérico del panel */
.panel-empty {
    font-size: .82rem;
    color: var(--gray-500);
    font-style: italic;
    padding: .5rem 0;
}

/* --- Tab: Partes --- */
.parts-list { display: flex; flex-direction: column; gap: .5rem; }

.part-item {
    padding: .8rem .95rem;
    background: rgba(255,255,255,.03);
    border: 1px solid rgba(255,255,255,.06);
    border-radius: var(--radius);
    transition: background var(--t-fast), border-color var(--t-fast);
}
.part-item:hover { background: rgba(59,158,204,.07); border-color: rgba(59,158,204,.2); }
.part-item__name { font-size: .875rem; font-weight: 700; color: var(--white); margin-bottom: .2rem; }
.part-item__desc { font-size: .75rem; color: var(--gray-500); line-height: 1.4; }

/* --- Quiz launchers (lista en subtab Quizes) --- */
.quiz-launcher {
    display: flex;
    align-items: center;
    gap: .85rem;
    padding: .9rem 1rem;
    background: rgba(255,255,255,.03);
    border: 1px solid rgba(255,255,255,.07);
    border-radius: var(--radius);
    cursor: pointer;
    transition: background .15s, border-color .15s, transform .15s;
    margin-bottom: .5rem;
}
.quiz-launcher:hover {
    background: rgba(59,158,204,.1);
    border-color: rgba(59,158,204,.3);
    transform: translateX(3px);
}
.quiz-launcher__emoji {
    font-size: 1.5rem;
    flex-shrink: 0;
    width: 2.4rem;
    text-align: center;
}
.quiz-launcher__info { flex: 1; min-width: 0; }
.quiz-launcher__titulo { font-size: .875rem; font-weight: 700; color: var(--white); }
.quiz-launcher__meta   { font-size: .72rem; color: var(--gray-500); margin-top: .1rem; }
.quiz-launcher__arrow  { color: var(--sky); font-size: .9rem; flex-shrink: 0; transition: transform .15s; }
.quiz-launcher:hover .quiz-launcher__arrow { transform: translateX(3px); }

/* --- Activity cards (labeling en partes) --- */
.activities-list { display: flex; flex-direction: column; gap: .75rem; }

.activity-card { border-radius: var(--radius); overflow: hidden; }
.activity-card__header {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: .85rem 1rem;
    background: rgba(255,255,255,.04);
    border: 1px solid rgba(255,255,255,.07);
    border-radius: var(--radius);
}
.activity-card.open .activity-card__header { border-radius: var(--radius) var(--radius) 0 0; border-bottom-color: transparent; }
.activity-card__icon  { width: 30px; height: 30px; border-radius: 8px; display: flex; align-items: center; justify-content: center; font-size: .9rem; flex-shrink: 0; }
.icon-quiz     { background: rgba(201,168,76,.18); }
.icon-labeling { background: rgba(59,158,204,.18); }
.icon-read     { background: rgba(26,140,91,.18);  }
.activity-card__title   { font-size: .85rem; font-weight: 700; color: var(--white); flex: 1; }
.activity-card__chevron { color: var(--gray-500); font-size: .7rem; transition: transform var(--t-fast); }
.activity-card.open .activity-card__chevron { transform: rotate(180deg); }
.activity-card__body {
    display: none;
    padding: 1rem;
    background: rgba(255,255,255,.02);
    border: 1px solid rgba(255,255,255,.07);
    border-top: none;
    border-radius: 0 0 var(--radius) var(--radius);
}
.activity-card.open .activity-card__body { display: block; }

/* Labeling */
.labeling-list { display: flex; flex-direction: column; gap: .4rem; }
.labeling-item { display: flex; align-items: center; gap: .6rem; font-size: .82rem; color: var(--gray-300); padding: .4rem 0; border-bottom: 1px solid rgba(255,255,255,.04); }
.labeling-item__num { width: 20px; height: 20px; border-radius: 50%; background: rgba(59,158,204,.15); color: var(--sky); font-size: .65rem; font-weight: 800; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }

/* Coming soon */
.coming-soon { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .5rem; padding: 3rem 1rem; text-align: center; color: var(--gray-500); }
.coming-soon span  { font-size: 2.2rem; opacity: .4; }
.coming-soon p     { font-size: .9rem; font-weight: 700; color: var(--gray-300); margin: 0; }
.coming-soon small { font-size: .75rem; line-height: 1.5; }

/* ── Panel footer ─────────────────────────────────────────── */
.panel-footer {
    padding: .9rem 1.25rem;
    border-top: 1px solid var(--gray-700);
    display: flex;
    gap: .6rem;
    flex-shrink: 0;
    background: rgba(0,0,0,.12);
}

.btn-complete {
    flex: 1;
    justify-content: center;
    background: var(--bio);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: .6rem 1rem;
    font-size: .82rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: opacity .15s, background .15s;
}
.btn-complete:hover   { opacity: .88; }
.btn-complete.done    { background: rgba(26,140,91,.25); color: #4ade80; cursor: default; }

.btn-read {
    display: flex;
    align-items: center;
    gap: .4rem;
    padding: .6rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--gray-700);
    background: transparent;
    color: var(--gray-300);
    font-size: .8rem;
    font-weight: 600;
    text-decoration: none;
    white-space: nowrap;
    transition: border-color .15s, color .15s, background .15s;
}
.btn-read:hover { border-color: var(--sky); color: var(--sky); background: rgba(59,158,204,.07); }

/* ── Quiz navegable (dentro del overlay) ─────────────────── */
.quiz-shell { display: flex; flex-direction: column; gap: .85rem; max-width: 640px; margin: 0 auto; }

.quiz-progress-bar {
    height: 4px;
    background: rgba(255,255,255,.08);
    border-radius: 2px;
    overflow: hidden;
}
.quiz-progress-bar__fill {
    height: 100%;
    background: linear-gradient(90deg, var(--sky), var(--bio));
    border-radius: 2px;
    transition: width .4s ease;
}

.quiz-counter { display: flex; align-items: baseline; gap: .2rem; font-size: .75rem; color: var(--gray-500); }
.quiz-counter__num   { font-size: 1rem; font-weight: 800; color: var(--white); }
.quiz-counter__sep   { color: rgba(255,255,255,.15); }
.quiz-counter__total { font-weight: 600; }

.quiz-question__text {
    font-size: 1rem;
    font-weight: 700;
    color: var(--white);
    line-height: 1.55;
    margin-bottom: .85rem;
}

.quiz-options { display: flex; flex-direction: column; gap: .45rem; }

.quiz-option {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .65rem 1rem;
    border-radius: 10px;
    border: 1.5px solid rgba(255,255,255,.1);
    background: rgba(255,255,255,.03);
    color: var(--gray-300);
    font-family: inherit;
    font-size: .85rem;
    font-weight: 600;
    cursor: pointer;
    text-align: left;
    transition: all .15s;
    width: 100%;
}
.quiz-option:hover:not(:disabled) { border-color: var(--sky); color: #fff; background: rgba(59,158,204,.1); }
.quiz-option.correct { border-color: var(--bio); background: rgba(26,140,91,.15); color: #4ade80; }
.quiz-option.wrong   { border-color: #ef4444; background: rgba(239,68,68,.1); color: #f87171; }
.quiz-option.disabled-opt { opacity: .45; }
.quiz-option:disabled { cursor: default; }

.quiz-option__letter {
    width: 24px; height: 24px;
    border-radius: 50%;
    background: rgba(255,255,255,.08);
    display: flex; align-items: center; justify-content: center;
    font-size: .72rem; font-weight: 800;
    flex-shrink: 0;
}

.quiz-feedback-inner {
    display: flex;
    align-items: flex-start;
    gap: .65rem;
    padding: .75rem 1rem;
    border-radius: 10px;
    font-size: .82rem;
    line-height: 1.5;
    margin-top: .5rem;
}
.quiz-feedback-inner.ok  { background: rgba(26,140,91,.15); color: #4ade80; border: 1px solid rgba(26,140,91,.3); }
.quiz-feedback-inner.err { background: rgba(239,68,68,.1);  color: #f87171; border: 1px solid rgba(239,68,68,.25); }
.quiz-feedback-inner p   { margin: .2rem 0 0; color: inherit; font-size: .78rem; opacity: .85; }
.quiz-feedback-icon      { font-size: .9rem; flex-shrink: 0; margin-top: .1rem; }

/* Nav del quiz */
.quiz-nav__inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding-top: .75rem;
    border-top: 1px solid rgba(255,255,255,.07);
}
.quiz-nav__dots { display: flex; gap: .35rem; flex-wrap: wrap; justify-content: center; flex: 1; }
.quiz-dot { width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,.12); cursor: pointer; transition: background .15s, transform .15s; }
.quiz-dot.active  { background: var(--sky); transform: scale(1.35); }
.quiz-dot.correct { background: var(--bio); }
.quiz-dot.wrong   { background: #ef4444; }

/* Resultados */
.quiz-results { display: flex; flex-direction: column; gap: 1rem; max-width: 640px; margin: 0 auto; }
.quiz-results__score {
    text-align: center;
    padding: 1.5rem;
    background: rgba(255,255,255,.03);
    border: 1px solid rgba(255,255,255,.08);
    border-radius: var(--radius);
}
.quiz-results__num     { font-size: 2.8rem; font-weight: 800; color: var(--white); line-height: 1; }
.quiz-results__num span{ font-size: 1.3rem; color: var(--gray-500); }
.quiz-results__pct     { font-size: 1.1rem; font-weight: 700; color: var(--sky); margin: .3rem 0; }
.quiz-results__grade   { font-size: .85rem; color: var(--gray-300); }
.quiz-results__summary { display: flex; flex-direction: column; gap: .3rem; }
.quiz-result-row { display: flex; align-items: flex-start; gap: .5rem; font-size: .78rem; padding: .4rem .6rem; border-radius: 6px; }
.quiz-result-row.ok  { background: rgba(26,140,91,.08); }
.quiz-result-row.err { background: rgba(239,68,68,.07); }
.quiz-result-row__icon   { flex-shrink: 0; margin-top: .05rem; }
.quiz-result-row__text   { flex: 1; color: var(--gray-300); line-height: 1.4; }
.quiz-result-row__answer { flex-shrink: 0; font-weight: 800; color: var(--gray-500); }

/* ── Pills filtro ────────────────────────────────────────── */
.parts-filter {
    display: flex;
    gap: .35rem;
    align-items: center;
    margin-bottom: .75rem;
}

.parts-pill {
    padding: .25rem .6rem;
    border-radius: 999px;
    border: 1px solid var(--gray-700);
    background: transparent;
    color: var(--gray-500);
    font-family: inherit;
    font-size: .75rem;
    font-weight: 700;
    cursor: pointer;
    transition: all .15s;
    line-height: 1;
}
.parts-pill:hover  { border-color: var(--sky); }
.parts-pill.active { background: rgba(59,158,204,.18); border-color: var(--sky); }
.parts-pill[data-nivel="todos"] { font-size: .68rem; letter-spacing: .04em; padding: .28rem .7rem; }

/* ── Part card ───────────────────────────────────────────── */
.parts-items { display: flex; flex-direction: column; gap: .4rem; }

.part-card {
    display: flex;
    align-items: center;
    gap: .55rem;
    padding: .65rem .85rem;
    border-radius: var(--radius);
    border: 1px solid rgba(255,255,255,.06);
    background: rgba(255,255,255,.03);
    transition: background var(--t-fast), border-color var(--t-fast);
}
.part-card:hover       { background: rgba(59,158,204,.07); border-color: rgba(59,158,204,.2); }
.part-card--done       { border-color: rgba(26,140,91,.2);  background: rgba(26,140,91,.05); }
.part-card--done .part-name { color: var(--gray-500); text-decoration: line-through; }

/* ── Nombre ──────────────────────────────────────────────── */
.part-name {
    flex: 1;
    font-size: .855rem;
    font-weight: 700;
    color: var(--white);
    line-height: 1.3;
}

/* ── Badge nivel (emoji) — a la derecha del nombre ──────── */
.part-nivel-badge {
    font-size: .8rem;
    flex-shrink: 0;
    line-height: 1;
    opacity: .85;
}

/* ── Botón lupa hint ─────────────────────────────────────── */
.part-hint-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--gray-700);
    background: transparent;
    color: var(--gray-500);
    cursor: pointer;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color .15s, background .15s, color .15s;
    padding: 0;
}
.part-hint-btn:hover,
.part-hint-btn--active {
    border-color: var(--sky);
    color: var(--sky);
    background: rgba(59,158,204,.15);
}

/* ── Checkbox ────────────────────────────────────────────── */
.part-check {
    display: flex;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0;
}
.part-check input { position: absolute; opacity: 0; width: 0; height: 0; }
.part-check__box {
    width: 16px;
    height: 16px;
    border-radius: 4px;
    border: 1.5px solid var(--gray-700);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color .15s, background .15s;
    flex-shrink: 0;
}
.part-check input:checked + .part-check__box {
    background: var(--bio);
    border-color: var(--bio);
}
.part-check input:checked + .part-check__box::after {
    content: '';
    width: 5px;
    height: 8px;
    border: 2px solid #fff;
    border-top: none;
    border-left: none;
    transform: rotate(45deg) translate(-1px,-1px);
    display: block;
}
.part-check:hover .part-check__box { border-color: var(--bio); }

/* ── Hint popup flotante (sobre el stage) ────────────────── */
.hint-popup {
    position: absolute;
    z-index: 25;
    width: 260px;
    padding: 1rem 1.1rem 1rem;
    border-radius: 16px;
    background: rgba(11,23,54,0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(59,158,204,.3);
    border-left: 3px solid var(--sky);
    box-shadow: 0 8px 32px rgba(0,0,0,.5);
    opacity: 0;
    pointer-events: none;
    transform: translateX(10px);
    transition: opacity .2s ease, transform .2s ease;
}
.hint-popup.active {
    opacity: 1;
    pointer-events: all;
    transform: translateX(0);
}
.hint-popup__label {
    font-size: .62rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: var(--sky);
    margin-bottom: .5rem;
}
.hint-popup__text {
    font-size: .8rem;
    color: var(--gray-300);
    line-height: 1.6;
    margin: 0;
}
.hint-popup__close {
    position: absolute;
    top: .6rem;
    right: .6rem;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,.08);
    color: var(--gray-500);
    font-size: .65rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .15s, color .15s;
}
.hint-popup__close:hover { background: rgba(255,80,80,.15); color: #f87171; }


/* --- Mobile --- */
@media (max-width: 900px) {
    .viewer-layout {
        grid-template-columns: 1fr;
        grid-template-rows: 55vw 1fr;
        height: auto;
        min-height: 100vh;
    }
    .viewer-stage { min-height: 55vw; }
    .viewer-panel {
        border-left: none;
        border-top: 1px solid var(--gray-700);
        height: 60vh;
        max-height: 60vh;
        min-height: 0;
    }
    .quiz-overlay__body { padding: 1rem; }
}
