/* ============================================================================
 *  REPRODUCTOR PROPIO DE LOS TUTORIALES · Atlantic Tech Hub
 * ============================================================================
 *  Sin YouTube ni iframes. Estilo navy/cian del portal, controles propios y
 *  adaptación a 390 y 1440 sin scroll horizontal.
 *
 *  Orden de capas: vídeo (0) < controles (1030) < capa de avisos/panel (1035).
 *  El asistente flotante del portal vive en z-index 1010, así que NUNCA tapa
 *  los controles del reproductor; el panel de ajustes va por encima de todo.
 * ========================================================================== */

.ath-player {
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0;
    background: #04101d;
    border-radius: 16px;
    color: #e2e8f0;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    box-shadow: 0 18px 44px rgba(10, 38, 71, .28);
    box-sizing: border-box;
}

.ath-player *,
.ath-player *::before,
.ath-player *::after { box-sizing: border-box; }

.ath-player [hidden] { display: none !important; }

.ath-player__pantalla {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 16px;
    overflow: hidden;
}

.ath-player__video {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
    outline: 0;
}

/* --- Capa de avisos y panel (por encima de los controles) --- */
.ath-player__capa {
    position: absolute;
    inset: 0;
    z-index: 1035;
    pointer-events: none;
}

.ath-player__capa > * { pointer-events: auto; }

.ath-player__aviso {
    position: absolute;
    top: 10px;
    left: 10px;
    max-width: calc(100% - 20px);
    padding: .45rem .7rem;
    border-radius: 10px;
    background: rgba(4, 16, 29, .92);
    border: 1px solid rgba(127, 243, 255, .45);
    color: #d7f8ff;
    font-size: .78rem;
    font-weight: 600;
    line-height: 1.4;
    box-shadow: 0 6px 18px rgba(0, 0, 0, .35);
    pointer-events: none;
}

.ath-player__cc-texto {
    position: absolute;
    left: 50%;
    bottom: 72px;
    transform: translateX(-50%);
    max-width: 86%;
    padding: .2rem .6rem;
    border-radius: 6px;
    background: rgba(0, 0, 0, .72);
    color: #ffffff;
    font-size: clamp(.85rem, 1.5vw, 1.1rem);
    font-weight: 600;
    line-height: 1.35;
    text-align: center;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .85);
    white-space: pre-line;
    pointer-events: none;
    z-index: 2;
}

.ath-player__gran-play {
    position: absolute;
    top: 50%;
    right: auto;
    bottom: auto;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 96px;
    height: 96px;
    padding: 0;
    border: 3px solid rgba(255, 255, 255, .95);
    border-radius: 50%;
    background: #ff0033;
    color: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    cursor: pointer;
    box-shadow: 0 14px 36px rgba(0, 0, 0, .46);
    transition: transform .18s ease, background .18s ease;
}

.ath-player__gran-play:hover { background: #d9002b; transform: translate(-50%, -50%) scale(1.06); }
.ath-player__gran-play i { margin-left: 5px; }

.ath-player__gran-play:focus-visible {
    outline: 3px solid #ffffff;
    outline-offset: 3px;
}

.ath-player__oculto {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

.ath-player__cargando {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .7rem;
    background: rgba(4, 16, 29, .62);
    color: #dbe7f3;
    font-size: .84rem;
    font-weight: 600;
    pointer-events: none;
}

.ath-player__spinner {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    border: 3px solid rgba(226, 232, 240, .25);
    border-top-color: #06b6d4;
    animation: ath-girar .9s linear infinite;
}

@keyframes ath-girar { to { transform: rotate(360deg); } }

.ath-player__error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: min(420px, calc(100% - 32px));
    padding: 1.1rem 1.2rem;
    border-radius: 14px;
    background: rgba(4, 16, 29, .97);
    border: 1px solid #1e3a5f;
    box-shadow: 0 18px 44px rgba(0, 0, 0, .5);
    text-align: center;
}

.ath-player__error-icono { display: block; font-size: 1.5rem; color: #fbbf24; margin-bottom: .35rem; }
.ath-player__error strong { display: block; color: #ffffff; font-size: 1rem; line-height: 1.3; }
.ath-player__error p { margin: .35rem 0 .8rem; color: #cbd9e8; font-size: .84rem; line-height: 1.45; }
.ath-player__error-acciones { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; justify-content: center; }

.ath-player__boton-texto {
    border: 1px solid rgba(127, 243, 255, .5);
    background: rgba(6, 182, 212, .16);
    color: #d7f8ff;
    padding: .45rem .8rem;
    border-radius: 9px;
    font: 700 .8rem 'Inter', system-ui, sans-serif;
    cursor: pointer;
}

.ath-player__boton-texto:hover { background: rgba(6, 182, 212, .35); }

.ath-player__enlace {
    color: #7ff3ff;
    font-size: .8rem;
    font-weight: 700;
    text-decoration: underline;
}

.ath-player__reanudar {
    position: absolute;
    left: 50%;
    bottom: 64px;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: .6rem;
    flex-wrap: wrap;
    justify-content: center;
    max-width: calc(100% - 24px);
    padding: .5rem .75rem;
    border-radius: 10px;
    background: rgba(4, 16, 29, .94);
    border: 1px solid #1e3a5f;
    color: #e2e8f0;
    font-size: .8rem;
    font-weight: 600;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .4);
}

/* --- Panel de ajustes --- */
.ath-player__panel {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    background: rgba(4, 16, 29, .97);
    padding: .8rem .9rem;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.ath-player__panel-cab {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .5rem;
    padding-bottom: .5rem;
    margin-bottom: .5rem;
    border-bottom: 1px solid #16324f;
}

.ath-player__panel-cab strong { font-size: .92rem; color: #ffffff; }

.ath-player__panel-cuerpo { display: grid; gap: .8rem; }
.ath-player__panel-cuerpo section h4 {
    margin: 0 0 .35rem;
    font-size: .7rem;
    text-transform: uppercase;
    letter-spacing: .1em;
    color: #7ff3ff;
}

.ath-player__chips { display: flex; flex-wrap: wrap; gap: .4rem; }

.ath-player__chip {
    border: 1px solid rgba(255, 255, 255, .16);
    background: rgba(255, 255, 255, .08);
    color: #e2e8f0;
    padding: .35rem .65rem;
    border-radius: 999px;
    font: 700 .78rem 'Inter', system-ui, sans-serif;
    cursor: pointer;
    line-height: 1.2;
}

.ath-player__chip:hover { background: rgba(255, 255, 255, .18); }
.ath-player__chip.is-activo { background: #06b6d4; border-color: #06b6d4; color: #04283f; }
.ath-player__chip:disabled { opacity: .45; cursor: not-allowed; }

/* --- Controles --- */
.ath-player__controles {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1030;
    padding: .3rem .5rem .4rem;
    background: linear-gradient(to top, rgba(4, 16, 29, .97) 0%, rgba(4, 16, 29, .82) 55%, rgba(4, 16, 29, 0) 100%);
    min-width: 0;
}

.ath-player__progreso-caja {
    position: relative;
    display: flex;
    align-items: center;
    height: 18px;
    margin: 0 .1rem .1rem;
}

.ath-player__buffer {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 4px;
    width: 0;
    max-width: 100%;
    border-radius: 999px;
    background: rgba(127, 243, 255, .4);
    pointer-events: none;
}

.ath-player__progreso {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 18px;
    margin: 0;
    padding: 0;
    background: transparent;
    -webkit-appearance: none;
    appearance: none;
    cursor: pointer;
}

.ath-player__progreso::-webkit-slider-runnable-track {
    height: 4px;
    border-radius: 999px;
    background: rgba(226, 232, 240, .32);
}
.ath-player__progreso::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 13px;
    height: 13px;
    margin-top: -4.5px;
    border-radius: 50%;
    background: #06b6d4;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 2px rgba(4, 16, 29, .6);
}
.ath-player__progreso::-moz-range-track {
    height: 4px;
    border-radius: 999px;
    background: rgba(226, 232, 240, .32);
}
.ath-player__progreso::-moz-range-thumb {
    width: 13px;
    height: 13px;
    border: 2px solid #ffffff;
    border-radius: 50%;
    background: #06b6d4;
}

.ath-player__fila {
    display: flex;
    align-items: center;
    gap: .2rem;
    flex-wrap: wrap;
    row-gap: 2px;
    min-width: 0;
}

.ath-player__hueco { flex: 1 1 0; min-width: 0; }

.ath-player__boton {
    flex: 0 0 auto;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 8px;
    background: transparent;
    color: #e2e8f0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    cursor: pointer;
    line-height: 1;
}

.ath-player__boton:hover { background: rgba(255, 255, 255, .14); }
.ath-player__boton:disabled { opacity: .4; cursor: not-allowed; background: transparent; }

.ath-player__boton--principal {
    background: #06b6d4;
    color: #04283f;
    font-size: 1rem;
}
.ath-player__boton--principal:hover { background: #22d3ee; }

.ath-player__boton--cc {
    font-size: .66rem;
    font-weight: 800;
    letter-spacing: .02em;
}
.ath-player__boton--cc[aria-pressed="true"] {
    background: #06b6d4;
    color: #04283f;
}

.ath-player__tiempo {
    flex: 0 0 auto;
    padding: 0 .15rem;
    font-size: .74rem;
    font-weight: 600;
    color: #dbe7f3;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}

.ath-player__volumen {
    flex: 0 1 72px;
    width: 72px;
    min-width: 44px;
    height: 20px;
    margin: 0 .1rem;
    accent-color: #06b6d4;
    cursor: pointer;
}

.ath-player__idiomas {
    flex: 0 0 auto;
    display: inline-flex;
    border: 1px solid rgba(255, 255, 255, .24);
    border-radius: 8px;
    overflow: hidden;
    margin: 0 .1rem;
}

.ath-player__idioma {
    width: 34px;
    height: 30px;
    padding: 0;
    border: 0;
    background: transparent;
    color: #cbd9e8;
    font: 800 .66rem 'Inter', system-ui, sans-serif;
    cursor: pointer;
}

.ath-player__idioma:hover { background: rgba(255, 255, 255, .14); }
.ath-player__idioma.is-activo,
.ath-player__idioma[aria-pressed="true"] { background: #06b6d4; color: #04283f; }

/* --- Foco visible (teclado) --- */
.ath-player:focus-visible {
    outline: 3px solid #7ff3ff;
    outline-offset: 3px;
}

.ath-player button:focus-visible,
.ath-player a:focus-visible,
.ath-player input:focus-visible {
    outline: 3px solid #7ff3ff;
    outline-offset: 2px;
    border-radius: 8px;
}

/* --- Pantalla completa --- */
.ath-player:fullscreen,
.ath-player:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    box-shadow: none;
    background: #000;
}

.ath-player:fullscreen .ath-player__pantalla,
.ath-player:-webkit-full-screen .ath-player__pantalla {
    height: 100%;
    aspect-ratio: auto;
    border-radius: 0;
}

.ath-player:fullscreen .ath-player__controles,
.ath-player:-webkit-full-screen .ath-player__controles {
    padding: .5rem 1rem .7rem;
}

.ath-player:fullscreen .ath-player__gran-play,
.ath-player:-webkit-full-screen .ath-player__gran-play { width: 92px; height: 92px; font-size: 1.9rem; }

.ath-player:fullscreen .ath-player__cc-texto,
.ath-player:-webkit-full-screen .ath-player__cc-texto {
    bottom: 86px;
    max-width: 80%;
    font-size: 1.35rem;
}

/* El asistente flotante nunca debe quedar por encima de los controles. */
body.ath-pantalla-completa .ai-assistant { display: none !important; }
body.ath-pantalla-completa { overflow: hidden !important; }

/* Botón de cierre grande, también visible en pantalla completa nativa. */
.ath-player__cerrar-pantalla {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 1046;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: 50%;
    background: rgba(4, 16, 29, .82);
    color: #ffffff;
    font-size: 1.3rem;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(0, 0, 0, .35);
}
.ath-player__cerrar-pantalla:hover { background: #0a2647; }

/* Pantalla completa CSS cuando requestFullscreen no está disponible o falla
   (iOS, navegadores restrictivos). Mantiene el vídeo completo con contain. */
.ath-player--pantalla-forzada {
    position: fixed;
    inset: 0;
    z-index: 2147482000;
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    border-radius: 0;
    background: #000000;
    box-shadow: none;
}
.ath-player--pantalla-forzada .ath-player__pantalla {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;
    aspect-ratio: auto;
    border-radius: 0;
}
.ath-player--pantalla-forzada .ath-player__controles {
    flex: 0 0 auto;
    padding-bottom: max(.7rem, env(safe-area-inset-bottom));
}
.ath-player--pantalla-forzada .ath-player__video { object-fit: contain; }

/* --- Tabletas --- */
@media (max-width: 900px) {
    .ath-player__boton { width: 32px; height: 32px; }
    .ath-player__tiempo { font-size: .7rem; }
    .ath-player__volumen { width: 60px; flex-basis: 60px; }
}

/* --- Móviles (390) --- */
@media (max-width: 560px) {
    .ath-player { border-radius: 12px; }
    .ath-player__pantalla { border-radius: 12px; }
    .ath-player__controles { padding: .2rem .35rem .3rem; }
    .ath-player__progreso-caja { height: 16px; margin-bottom: 0; }
    .ath-player__progreso { height: 16px; }
    .ath-player__boton { width: 30px; height: 30px; font-size: .85rem; }
    .ath-player__boton--principal { font-size: .9rem; }
    .ath-player__boton--cc { font-size: .6rem; }
    .ath-player__volumen { display: none; }
    .ath-player__tiempo { font-size: .66rem; padding: 0 .1rem; }
    .ath-player__idioma { width: 30px; height: 28px; font-size: .6rem; }
    .ath-player__fila { gap: .15rem; }
    .ath-player__gran-play { width: 56px; height: 56px; font-size: 1.25rem; }
    .ath-player__cc-texto { bottom: 62px; font-size: .85rem; max-width: 92%; padding: .15rem .45rem; }
    .ath-player__aviso { font-size: .7rem; top: 6px; left: 6px; padding: .35rem .5rem; max-width: calc(100% - 12px); }
    .ath-player__reanudar { bottom: 56px; font-size: .72rem; padding: .4rem .55rem; gap: .4rem; }
    .ath-player__panel { padding: .6rem .65rem; }
    .ath-player__panel-cab strong { font-size: .84rem; }
    .ath-player__chip { font-size: .72rem; padding: .3rem .55rem; }
    .ath-player__error { padding: .8rem .85rem; }
    .ath-player__error strong { font-size: .9rem; }
    .ath-player__error p { font-size: .78rem; }
}

@media (max-width: 360px) {
    .ath-player__tiempo { font-size: .6rem; }
    .ath-player__boton { width: 28px; height: 28px; }
    .ath-player__idioma { width: 28px; }
}

/* Con movimiento reducido no hace falta animar el indicador de carga. */
@media (prefers-reduced-motion: reduce) {
    .ath-player__spinner { animation-duration: 2.4s; }
    .ath-player__gran-play { transition: none; }
}


/* En pantallas estrechas el póster es más bajo: el play va a la esquina
   inferior derecha para no tapar el subtítulo ni la píldora central. */
@media (max-width: 560px) {
    .ath-player__gran-play {
        top: 50%;
        left: 50%;
        right: auto;
        bottom: auto;
        transform: translate(-50%, -50%);
        width: 76px;
        height: 76px;
        font-size: 1.6rem;
    }
    .ath-player__gran-play:hover { transform: translate(-50%, -50%) scale(1.06); }
    .ath-player__gran-play i { margin-left: 4px; }
}
