/* ═══════════════════════════════════════════════════════════════
   KAPI STREAMBOX — caja de transmisión rediseñada
   Todo posicionado con % / left:50%+translate, nunca px fijos desde
   un borde, para que se ajuste a cualquier ancho y notch de pantalla.
   ═══════════════════════════════════════════════════════════════ */

#streaming-stage {
    overflow: hidden;
}

/* ─── HUD superior: aro de energía + nombre + contador ─────────── */
.kapi-hud-top {
    position: absolute;
    top: max(12px, env(safe-area-inset-top));
    left: 12px;
    right: 12px;
    z-index: 40;
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}

.kapi-avatar-wrap {
    position: relative;
    width: 44px;
    height: 44px;
    flex-shrink: 0;
}

.kapi-ring {
    position: absolute;
    top: 0;
    left: 0;
    width: 44px;
    height: 44px;
    transform: rotate(-90deg);
}

.kapi-ring-bg {
    fill: none;
    stroke: rgba(255, 255, 255, 0.15);
    stroke-width: 3;
}

.kapi-ring-fill {
    fill: none;
    stroke: #00e5ff;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-dasharray: 119.4;
    stroke-dashoffset: 119.4;
    transition: stroke-dashoffset 0.4s ease, stroke 0.4s ease;
}

#streaming-stage .streamer-avatar {
    position: absolute;
    top: 4px;
    left: 4px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    background: #333;
}

.kapi-live-dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e0243c;
    border: 2px solid rgba(0, 0, 0, 0.6);
}

.streamer-details {
    min-width: 0;
    flex: 1;
    pointer-events: auto;
}

.kapi-name-row {
    display: flex;
    align-items: center;
    gap: 8px;
}

#streaming-stage .streamer-details h3 {
    margin: 0;
    color: #fff;
    font-size: 13px;
    font-weight: 500;
    max-width: 130px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

#streaming-stage #pro-stream-duration {
    color: rgba(255, 255, 255, 0.6);
    font-size: 10px;
}

.kapi-follow-btn {
    flex-shrink: 0;
    height: 20px;
    padding: 0 9px;
    border-radius: 10px;
    background: #00e5ff;
    border: none;
    color: #000;
    font-size: 10px;
    font-weight: 600;
}

.kapi-viewer-pill {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    background: rgba(0, 0, 0, 0.45);
    padding: 5px 10px;
    border-radius: 20px;
    pointer-events: auto;
}

.kapi-viewer-pill .material-icons {
    font-size: 14px;
    color: #00e5ff;
}

.kapi-viewer-pill span {
    color: #fff;
    font-size: 11px;
}

/* ─── Hint de pellizcar para zoom (solo transmisor) ─────────────── */
.kapi-zoom-hint {
    position: absolute;
    bottom: 96px;
    right: 14px;
    z-index: 30;
    display: none;
    align-items: center;
    gap: 4px;
    color: rgba(255, 255, 255, 0.55);
    font-size: 10px;
    pointer-events: none;
    transition: opacity 0.6s ease;
}

.kapi-zoom-hint .material-icons {
    font-size: 14px;
}

#streaming-stage.kapi-role-broadcaster .kapi-zoom-hint {
    display: flex;
}

/* ─── Encuesta compacta (en vivo) ───────────────────────────────── */
.kapi-poll-compact {
    position: absolute;
    top: 66px;
    left: 12px;
    right: 12px;
    max-width: 320px;
    z-index: 35;
    background: rgba(18, 18, 18, 0.72);
    border-radius: 12px;
    padding: 9px 11px;
}

.kapi-poll-question {
    color: #eee;
    font-size: 11px;
    margin-bottom: 7px;
}

.kapi-poll-options {
    display: flex;
    gap: 6px;
}

.kapi-poll-compact .poll-option-row {
    flex: 1;
    min-width: 0;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 8px;
    padding: 5px 6px;
    cursor: pointer;
}

.kapi-poll-compact .poll-option-label {
    display: flex;
    justify-content: center;
    align-items: baseline;
    gap: 4px;
    color: #ddd;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kapi-poll-compact .poll-option-pct {
    color: #f5c04a;
    font-size: 9px;
}

.kapi-poll-compact .poll-bar-bg {
    margin-top: 4px;
    height: 3px;
    border-radius: 2px;
    background: rgba(255, 255, 255, 0.12);
    overflow: hidden;
}

.kapi-poll-compact .poll-bar-fill {
    height: 100%;
    background: #00e5ff;
}

.kapi-poll-compact .poll-option-row.my-vote {
    outline: 1px solid #00e5ff;
}

.kapi-poll-compact .poll-option-row.winner {
    outline: 1px solid #f5c04a;
}

.kapi-poll-total {
    color: rgba(255, 255, 255, 0.45);
    font-size: 9px;
}

.kapi-poll-close {
    background: none;
    border: none;
    color: #e0243c;
    font-size: 10px;
}

/* ─── Modal crear encuesta ───────────────────────────────────────── */
.kapi-poll-modal {
    position: absolute;
    inset: 0;
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    padding: 16px;
}

.kapi-poll-modal-card {
    width: 100%;
    max-width: 320px;
    background: #1a1a1a;
    border: 1px solid #2c2c2c;
    border-radius: 14px;
    padding: 16px;
}

.kapi-poll-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
    font-size: 14px;
    margin-bottom: 12px;
}

.kapi-poll-modal-header .material-icons {
    cursor: pointer;
    color: #888;
    font-size: 18px;
}

.kapi-poll-presets {
    display: flex;
    gap: 6px;
    margin-bottom: 12px;
}

.kapi-preset-btn {
    flex: 1;
    background: #232323;
    border: 1px solid #333;
    border-radius: 8px;
    color: #ddd;
    font-size: 10px;
    padding: 7px 4px;
}

.kapi-preset-btn.active {
    border-color: #00e5ff;
    color: #00e5ff;
}

.kapi-poll-input {
    width: 100%;
    box-sizing: border-box;
    background: #252525;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    color: #fff;
    padding: 10px;
    font-size: 13px;
    margin-bottom: 10px;
}

.kapi-poll-options-input {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 8px;
}

.poll-option-input {
    width: 100%;
    box-sizing: border-box;
    background: #252525;
    border: 1px solid #3a3a3a;
    border-radius: 8px;
    color: #fff;
    padding: 9px 10px;
    font-size: 12px;
}

.kapi-poll-add-btn {
    width: 100%;
    background: none;
    border: 1px dashed #444;
    border-radius: 8px;
    color: #888;
    font-size: 11px;
    padding: 8px;
    margin-bottom: 12px;
}

.kapi-poll-launch-btn {
    width: 100%;
    background: #00e5ff;
    border: none;
    border-radius: 8px;
    color: #000;
    font-weight: 600;
    font-size: 13px;
    padding: 11px;
}

/* ─── Acciones flotantes del espectador ─────────────────────────── */
.kapi-viewer-actions {
    position: absolute;
    right: 6px;
    bottom: max(84px, calc(env(safe-area-inset-bottom) + 84px));
    z-index: 40;
    display: none;
    flex-direction: column;
    gap: 10px;
}

#streaming-stage.kapi-role-viewer .kapi-viewer-actions {
    display: flex;
}

.kapi-side-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(20, 20, 20, 0.65);
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kapi-side-btn .material-icons {
    color: #fff;
    font-size: 20px;
}

#kapi-gift-btn .material-icons {
    color: #f5c04a;
}

#kapi-heart-btn .material-icons {
    color: #d4537e;
}

/* ─── Dock del transmisor: vertical, pegado al raz del borde derecho ───
   (esta es la regla que de verdad manda: usa #streaming-stage, así que
   le gana en especificidad a cualquier ajuste puesto en movil-style.css
   aunque ese tenga !important — por eso el dock volvía a quedar centrado) */
#streaming-stage .broadcaster-controls-bar {
    left: auto !important;
    right: 4px !important;
    transform: none !important;
    bottom: max(80px, calc(env(safe-area-inset-bottom) + 80px)) !important;
    top: auto !important;
    display: flex;
    flex-direction: column !important;
    align-items: center;
    gap: 8px;
    background: rgba(20, 20, 20, 0.72);
    padding: 8px 6px;
    border-radius: 22px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 50;
    width: auto;
}

#streaming-stage .broadcaster-controls-bar #toggle-mic-stream-btn,
#streaming-stage .broadcaster-controls-bar #toggle-camera-stream-btn,
#streaming-stage .broadcaster-controls-bar .kapi-expand-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #232323;
    border: none;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

#streaming-stage .broadcaster-controls-bar .kapi-expand-btn {
    background: #00e5ff;
}

#streaming-stage .broadcaster-controls-bar .kapi-expand-btn .material-icons {
    color: #000;
}

#streaming-stage .broadcaster-controls-bar #toggle-mic-stream-btn .material-icons,
#streaming-stage .broadcaster-controls-bar #toggle-camera-stream-btn .material-icons {
    color: #fff;
    font-size: 18px;
}

/* Antes era una píldora horizontal con el texto "FINALIZAR"; ahora, en la
   columna vertical, queda como un círculo rojo más, solo con el ícono. */
#streaming-stage .broadcaster-controls-bar #pro-leave-btn {
    margin-left: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    background: #e0243c;
    border: none;
    color: #fff;
    font-size: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0;
    flex-shrink: 0;
}

#streaming-stage .broadcaster-controls-bar #pro-leave-btn .material-icons {
    font-size: 18px;
}

/* ─── Menú en abanico (encuesta / filtros / minijuegos / compartir) ──
   El dock del transmisor (mic/cámara/+/finalizar) ahora es una columna
   vertical pegada al borde derecho, así que el abanico se abre hacia la
   izquierda del botón "+", a la misma altura. */
.kapi-fan-menu {
    position: absolute;
    right: 54px;
    left: auto;
    bottom: max(84px, calc(env(safe-area-inset-bottom) + 84px));
    transform: translateX(10px);
    z-index: 45;
    display: flex;
    flex-direction: column-reverse;
    gap: 10px;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.25s ease;
}

.kapi-fan-menu.open {
    opacity: 1;
    pointer-events: auto;
    transform: translateX(0);
}

.kapi-fan-btn {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
}

.kapi-fan-btn .material-icons {
    color: #fff;
    font-size: 18px;
}

.kapi-fan-poll { background: #00c2a8; }
.kapi-fan-filters { background: #8b5cf6; }
.kapi-fan-minigames { background: #ff6b35; }
.kapi-fan-share { background: #378add; }

/* Se ocultan del flujo normal: minigames-btn / filters-btn originales
   siguen existiendo en el DOM (los usa el JS interno) pero ya no se
   ven sueltos por la pantalla — el abanico los dispara por código. */
html.kapi-native-app #minigames-btn,
html.kapi-native-app #filters-btn {
    display: none !important;
}

/* ─── Ajuste responsivo fino para equipos muy angostos (<360px) ─── */
@media (max-width: 360px) {
    #streaming-stage .streamer-details h3 {
        max-width: 90px;
    }
    .kapi-poll-compact {
        top: 60px;
    }
}
