/**
 * NEXTIUSPLAYER — carcasa del reproductor de lecciones
 * Patron documentado en random/DOCUMENTACION/NEXTIUSPLAYER_CUSTOM.md
 *
 * Todo va con el prefijo nx-: dentro del admin de Perfex, nombres como .player,
 * .bar, .poster o .time chocarian con Bootstrap 3 y con el tema.
 *
 * Los colores NO se escriben aqui: los inyecta el helper como --nx-brand y
 * --nx-fg en el style del contenedor, con lo que se configura en
 * Academia > Configuracion > Reproductor.
 */

.nx-player {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    outline: none;
    color: var(--nx-fg, #fff);
    /* Sin esto, en Safari/iOS los controles heredan la fuente del CRM y bailan */
    font-family: inherit;
}
.nx-player:fullscreen { border-radius: 0; }
/* Durante la reproduccion, tras 2.6 s quietos: fuera barra y fuera cursor */
.nx-player.nx-idle { cursor: none; }

/* ---------------------------------------------------------------
   Capa 0 — el medio
   --------------------------------------------------------------- */
.nx-player .nx-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

/* Estrategia A (YouTube/Vimeo): iframe recortado. pointer-events:none SIEMPRE */
.nx-stage { position: absolute; inset: 0; overflow: hidden; }
.nx-stage iframe {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    border: 0;
    pointer-events: none;
}
/* El recorte: iframe al 200 % de alto desplazado -25 %. El titulo (arriba) y la
   barra con el logo (abajo) quedan fisicamente fuera del area visible. */
.nx-player.nx-cropped .nx-stage iframe { height: 200%; transform: translateY(-25%); }

/* Fallback a iframe (Komodo/OK.ru): ahi mandan sus controles, no los nuestros */
.nx-player.nx-fallback > iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
}
.nx-player.nx-fallback .nx-bar,
.nx-player.nx-fallback .nx-topbar { display: none; }

/* Capa 2 — escudo: se queda TODOS los clics, ninguno llega al iframe */
.nx-shield { position: absolute; inset: 0; z-index: 2; }

/* ---------------------------------------------------------------
   Capa 3 — poster propio (tapa el player ajeno en pausa y al final)
   --------------------------------------------------------------- */
.nx-poster {
    position: absolute;
    inset: 0;
    z-index: 3;
    background: #000 center/cover no-repeat;
    display: grid;
    place-items: center;
    cursor: pointer;
    transition: opacity .25s;
}
.nx-poster.nx-hidden { opacity: 0; pointer-events: none; }
.nx-poster::after { content: ""; position: absolute; inset: 0; background: rgba(0,0,0,.25); }
.nx-big-play {
    position: relative;
    z-index: 1;
    width: 84px;
    height: 84px;
    border-radius: 50%;
    border: 0;
    background: var(--nx-brand, #2a78d6);
    color: #fff;
    cursor: pointer;
    display: grid;
    place-items: center;
    box-shadow: 0 8px 30px rgba(0,0,0,.6);
    transition: transform .15s;
    padding: 0;
}
.nx-poster:hover .nx-big-play { transform: scale(1.08); }
.nx-big-play svg { width: 36px; height: 36px; fill: #fff; display: block; margin-left: 4px; }

/* ---------------------------------------------------------------
   Capa 4 — marca propia arriba
   --------------------------------------------------------------- */
.nx-topbar {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    z-index: 4;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: none;
    background: linear-gradient(rgba(0,0,0,.6), transparent);
    transition: opacity .25s;
}
.nx-chip {
    background: var(--nx-brand, #2a78d6);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 1px;
    text-transform: uppercase;
    padding: 4px 8px;
    border-radius: 4px;
    white-space: nowrap;
}
.nx-chip-logo { max-height: 26px; max-width: 140px; }
/* El favicon es cuadrado: se le da el alto del chip para que no domine la barra */
.nx-chip-favicon { max-height: 24px; max-width: 24px; border-radius: 4px; }
.nx-lesson {
    font-size: 14px;
    font-weight: 600;
    text-shadow: 0 1px 3px rgba(0,0,0,.8);
    /* Titulos largos: una linea con puntos suspensivos, nunca dos filas */
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---------------------------------------------------------------
   Capa 4 — barra de controles
   --------------------------------------------------------------- */
.nx-bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    background: linear-gradient(transparent, rgba(0,0,0,.85));
    opacity: 0;
    transition: opacity .25s;
}
.nx-player:hover .nx-bar,
.nx-player.nx-paused .nx-bar,
.nx-player:focus-within .nx-bar { opacity: 1; }
.nx-player.nx-idle .nx-bar,
.nx-player.nx-idle .nx-topbar { opacity: 0; }

/* !important en color y background: el tema del CRM estiliza button a fondo */
.nx-bar .nx-btn {
    background: none !important;
    border: 0;
    color: var(--nx-fg, #fff) !important;
    font-size: 17px;
    cursor: pointer;
    width: 32px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    padding: 0;
    flex: none;
}
.nx-bar .nx-btn:hover { background: rgba(255,255,255,.15) !important; }
.nx-bar .nx-btn svg { width: 20px; height: 20px; fill: currentColor; display: block; }

.nx-seekwrap { flex: 1; display: flex; align-items: center; position: relative; min-width: 60px; }
.nx-player input.nx-seek {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 5px;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
    background: rgba(255,255,255,.2);
    margin: 0;
    padding: 0;
    border: 0;
}
.nx-player input.nx-seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--nx-brand, #2a78d6); border: 0;
}
.nx-player input.nx-seek::-moz-range-thumb {
    width: 14px; height: 14px; border-radius: 50%;
    background: var(--nx-brand, #2a78d6); border: 0;
}
.nx-time {
    color: var(--nx-fg, #fff);
    font: 12px/1 ui-monospace, "SFMono-Regular", Menlo, monospace;
    white-space: nowrap;
}

.nx-volwrap { display: flex; align-items: center; gap: 6px; }
.nx-player input.nx-vol {
    -webkit-appearance: none;
    appearance: none;
    width: 0;
    height: 4px;
    border-radius: 2px;
    background: rgba(255,255,255,.3);
    outline: none;
    cursor: pointer;
    transition: width .2s;
    margin: 0; padding: 0; border: 0;
}
.nx-volwrap:hover input.nx-vol, .nx-player input.nx-vol:focus { width: 70px; }
.nx-player input.nx-vol::-webkit-slider-thumb {
    -webkit-appearance: none; width: 12px; height: 12px;
    border-radius: 50%; background: #fff; border: 0;
}
.nx-player input.nx-vol::-moz-range-thumb {
    width: 12px; height: 12px; border-radius: 50%; background: #fff; border: 0;
}

.nx-speedwrap, .nx-qualitywrap { position: relative; }
.nx-speedmenu, .nx-qualitymenu {
    position: absolute;
    bottom: 42px;
    right: 0;
    background: rgba(20,22,28,.97);
    border: 1px solid #2a2f3a;
    border-radius: 8px;
    padding: 6px;
    display: none;
    min-width: 90px;
    z-index: 5;
}
.nx-speedmenu.nx-open, .nx-qualitymenu.nx-open { display: block; }
.nx-speedmenu button, .nx-qualitymenu button {
    width: 100%;
    padding: 7px 10px;
    font-size: 13px;
    display: flex;
    justify-content: flex-start;
    background: none !important;
    border: 0;
    color: #fff !important;
    border-radius: 4px;
    cursor: pointer;
}
.nx-speedmenu button:hover, .nx-qualitymenu button:hover { background: rgba(255,255,255,.12) !important; }
.nx-speedmenu button.nx-active, .nx-qualitymenu button.nx-active { color: var(--nx-brand, #2a78d6) !important; font-weight: 700; }
.nx-bar .nx-speedbtn, .nx-bar .nx-qualitybtn { font-size: 12px; font-weight: 700; width: auto; padding: 0 8px; }

/* Marcadores de capitulo (Komodo) sobre la barra de progreso */
.nx-markers { position: absolute; left: 0; right: 0; top: 50%; transform: translateY(-50%); pointer-events: none; }
.nx-marker {
    position: absolute;
    width: 8px; height: 8px;
    margin-left: -4px;
    border-radius: 50%;
    background: rgba(255,255,255,.85);
    box-shadow: 0 0 0 1px rgba(0,0,0,.4);
    top: -4px;
}

/* ---------------------------------------------------------------
   Capa 4 — spinner de buffering
   --------------------------------------------------------------- */
.nx-spinner {
    position: absolute;
    left: 50%; top: 50%;
    z-index: 4;
    width: 54px; height: 54px;
    margin: -27px 0 0 -27px;
    border: 4px solid rgba(255,255,255,.25);
    border-top-color: var(--nx-brand, #2a78d6);
    border-radius: 50%;
    display: none;
    animation: nx-spin .8s linear infinite;
}
.nx-player.nx-buffering .nx-spinner { display: block; }
@keyframes nx-spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------
   Capa 5 — pantalla final propia (nunca los sugeridos del proveedor)
   --------------------------------------------------------------- */
.nx-endscreen {
    position: absolute;
    inset: 0;
    z-index: 5;
    background: rgba(0,0,0,.88);
    display: none;
    place-items: center;
    text-align: center;
    padding: 16px;
}
.nx-endscreen.nx-visible { display: grid; }
.nx-endscreen h3 { font-size: 20px; margin: 0 0 18px; color: #fff; }
.nx-endrow { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.nx-endscreen button {
    padding: 12px 22px;
    border-radius: 8px;
    border: 0;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}
/* Cuenta atrás para la siguiente lección: solo se ve cuando está corriendo */
.nx-autonext {
    display: none;
    margin: 0 0 14px;
    font-size: 14px;
    color: #cfd4dc;
}
.nx-autonext.nx-visible { display: block; }
.nx-endscreen .nx-cancel-next { display: none; background: transparent !important;
    color: #cfd4dc !important; border: 1px solid #3a4150 !important; }
.nx-endscreen .nx-cancel-next.nx-visible { display: inline-block; }
.nx-endscreen .nx-cancel-next:hover { color: #fff !important; border-color: #5a6274 !important; }

.nx-endscreen .nx-replay { background: #2a2f3a !important; color: #fff !important; }
.nx-endscreen .nx-next { background: var(--nx-brand, #2a78d6) !important; color: #fff !important; }

/* ---------------------------------------------------------------
   Capa 6 — toast ("Reanudando en 4:12")
   --------------------------------------------------------------- */
.nx-toast {
    position: absolute;
    left: 50%;
    bottom: 70px;
    transform: translateX(-50%);
    z-index: 6;
    background: rgba(20,22,28,.95);
    color: #fff;
    font-size: 13px;
    padding: 8px 14px;
    border-radius: 20px;
    opacity: 0;
    transition: opacity .3s;
    pointer-events: none;
    max-width: 90%;
    text-align: center;
}
.nx-toast.nx-visible { opacity: 1; }

/* ---------------------------------------------------------------
   Capitulos de Komodo, bajo el reproductor
   El marco, la cabecera y la flecha los pone el acordeon del CRM
   (crm-accordion + academy-toc-heading/body): aqui solo va la lista.
   --------------------------------------------------------------- */
.academy-nx-chapters { margin-top: 10px; }
/* El cuerpo del acordeon trae padding lateral pensado para el temario; los
   capitulos ocupan la fila entera y su aire lo pone cada <li>. */
.academy-nx-chapters .academy-toc-body { padding: 0; }

.nx-chapter-list {
    list-style: none;
    margin: 0;
    padding: 0;
    /* Una grabacion larga trae muchos: la lista scrollea y no empuja la pagina */
    max-height: 220px;
    overflow-y: auto;
}
.nx-chapter-list li {
    display: flex;
    gap: 10px;
    padding: 8px 14px;
    cursor: pointer;
    font-size: 13px;
    border-bottom: 1px solid #f0f2f4;
}
.nx-chapter-list li:last-child { border-bottom: 0; }
.nx-chapter-list li:hover { background: #f6f7f9; }
.nx-chapter-list li.nx-active { background: #eef4fd; font-weight: 600; }
.nx-chapter-list .nx-ts {
    font: 12px/1.5 ui-monospace, "SFMono-Regular", Menlo, monospace;
    color: #7b8494;
    flex: none;
}

/* ---------------------------------------------------------------
   Movil: la barra se aprieta y hay dedos, no raton
   --------------------------------------------------------------- */
@media (max-width: 767px) {
    .nx-bar { gap: 8px; padding: 8px 10px; }
    .nx-bar .nx-btn { width: 30px; height: 30px; }
    /* El volumen se controla con los botones del telefono: la barra estorba */
    .nx-volwrap { display: none; }
    .nx-topbar { padding: 10px 12px; }
    .nx-lesson { font-size: 12px; }
    .nx-big-play { width: 64px; height: 64px; }
    .nx-big-play svg { width: 28px; height: 28px; }
    /* Sin hover en tactil: la barra se ve mientras el JS no la esconda */
    .nx-player .nx-bar { opacity: 1; }
    .nx-player.nx-idle .nx-bar { opacity: 0; }
}
