/* public/css/voice.css */

/* Kontener panelu rozmowy (Wewnątrz czatu) */
#voice-call-panel {
    width: 100%;
    min-height: 105px;
    background: rgba(15, 17, 26, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0, 242, 254, 0.15);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0.6rem 1rem;
    box-sizing: border-box;
    position: relative;
    z-index: 10;
    gap: 0.4rem;
}

#voice-call-panel.hidden {
    display: none;
}

/* Wnętrze panelu (awatary i status) */
.voice-panel-content {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 2rem;
    flex-grow: 1;
    width: 100%;
    transition: all 0.3s ease;
}

/* Pojedynczy slot użytkownika */
.voice-user-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
    border-radius: 10px;
}

.voice-user-slot.has-stream {
    cursor: pointer;
}

.voice-user-slot.has-stream:hover {
    transform: translateY(-2px);
}

/* Miniaturowy podgląd streamu w slocie uczestnika na górze */
.voice-stream-preview-slot {
    width: 135px;
    height: 76px;
    border-radius: 10px;
    overflow: hidden;
    position: relative;
    background: #000;
    border: 2px solid rgba(0, 242, 254, 0.35);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.65);
    transition: all 0.25s ease;
}

.voice-stream-preview-slot video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.voice-user-slot.active-stream-focus .voice-stream-preview-slot {
    border-color: #00f2fe;
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.7);
    transform: scale(1.04);
}

.slot-overlay-top {
    position: absolute;
    top: 5px;
    left: 6px;
    right: 6px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    pointer-events: none;
    z-index: 5;
}

.slot-user-tag {
    display: flex;
    align-items: center;
    gap: 5px;
    background: rgba(10, 12, 18, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    padding: 2px 6px 2px 3px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.6);
}

.slot-mini-avatar {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid rgba(255, 255, 255, 0.3);
    transition: all 0.2s ease;
}

.voice-user-slot.pulsing .slot-mini-avatar {
    border-color: #43b581;
    box-shadow: 0 0 8px #43b581;
}

.slot-username {
    font-size: 0.68rem;
    font-weight: 700;
    color: #fff;
    max-width: 60px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.slot-live-tag {
    background: rgba(0, 0, 0, 0.85);
    font-size: 0.62rem;
    font-weight: 800;
    padding: 2px 6px;
    border-radius: 4px;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 3px;
    pointer-events: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6);
}

.slot-live-tag.live {
    color: #ff4757;
    border: 1px solid rgba(255, 71, 87, 0.4);
}

.slot-live-tag.self {
    color: #00f2fe;
    border: 1px solid rgba(0, 242, 254, 0.4);
}

.slot-overlay-bottom {
    position: absolute;
    bottom: 5px;
    right: 6px;
    z-index: 5;
}

.voice-badge.mini {
    position: static;
    width: 20px;
    height: 20px;
    font-size: 0.68rem;
    border: 2px solid #111;
}

.voice-slot-name-label {
    font-size: 0.76rem;
    font-weight: 600;
    color: var(--secondary-text);
    margin-top: 5px;
    max-width: 130px;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Wrapper awatara - BEZ overflow hidden, aby odznaki nie były ucięte */
.voice-avatar-wrapper {
    width: 76px;
    height: 76px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: visible !important;
}

/* Wewnętrzne koło ze zdjęciem - z overflow hidden */
.voice-avatar-circle {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid rgba(255, 255, 255, 0.15);
    background-color: #202225;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
    transition: all 0.3s ease;
}

.voice-avatar-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Wskaźniki wyciszenia mikrofonu i słuchawek na awatarze - DUŻE, WYRAŹNE, NIEUBLOKOWANE */
.voice-badge {
    position: absolute;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    color: #ffffff;
    font-size: 0.82rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #1e2024;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.7);
    z-index: 10;
    animation: badge-pop 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.voice-mute-badge {
    bottom: -4px;
    right: -6px;
    background: #ed4245;
}

.voice-deafen-badge {
    bottom: -4px;
    left: -6px;
    background: #5865f2;
}

.voice-badge.hidden {
    display: none !important;
}

@keyframes badge-pop {
    0% { transform: scale(0); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

/* Efekt pulsowania mówiącego */
.voice-user-slot.pulsing .voice-avatar-circle {
    border-color: #43b581;
    box-shadow: 0 0 0 0 rgba(67, 181, 129, 0.7);
    animation: pulse-green 2s infinite;
}

@keyframes pulse-green {
    0% { transform: scale(0.96); box-shadow: 0 0 0 0 rgba(67, 181, 129, 0.7); }
    70% { transform: scale(1.02); box-shadow: 0 0 0 12px rgba(67, 181, 129, 0); }
    100% { transform: scale(0.96); box-shadow: 0 0 0 0 rgba(67, 181, 129, 0); }
}

/* Środkowa sekcja (status i animacja) */
.voice-center-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-width: 100px;
    transition: all 0.3s ease;
}

.voice-status-text {
    font-size: 0.9rem;
    color: #ccc;
    margin-top: 0.5rem;
    white-space: nowrap;
    transition: all 0.3s ease;
}

/* Animacja kropek (zastępuje mrugający tekst) */
.voice-connection-anim {
    display: flex;
    gap: 4px;
}
.voice-connection-anim span {
    width: 8px;
    height: 8px;
    background-color: #43b581;
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}
.voice-connection-anim span:nth-child(1) { animation-delay: -0.32s; }
.voice-connection-anim span:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Panel sterowania (przyciski) */
.voice-panel-controls {
    display: flex;
    gap: 1rem;
    margin-top: 0.6rem;
    transition: all 0.3s ease;
}

.voice-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    color: white;
}

.voice-btn:hover { transform: scale(1.1); }
.voice-btn:active { transform: scale(0.95); }

.btn-end-call { background-color: #ed4245; }
.btn-end-call:hover { background-color: #f04747; }

.btn-mute, .btn-deafen {
    background-color: rgba(255, 255, 255, 0.1);
    color: var(--text-color, #ffffff);
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
}

.btn-mute:hover, .btn-deafen:hover {
    background-color: rgba(255, 255, 255, 0.25);
    color: white;
}

.btn-mute.active-muted, .btn-deafen.active-muted {
    background-color: #ed4245 !important;
    color: white !important;
    box-shadow: 0 0 12px rgba(237, 66, 69, 0.5);
}

.btn-minimize {
    background-color: rgba(255, 255, 255, 0.1);
    color: #b9bbbe;
    width: 40px;
    height: 40px;
    font-size: 1rem;
}
.btn-minimize:hover { background-color: rgba(255, 255, 255, 0.2); color: white; }

/* =========================================================
   ZWINIĘTY PANEL ROZMOWY (MINIMIZED COMPACT STRIP)
   ========================================================= */
#voice-call-panel.minimized {
    min-height: 48px;
    height: auto;
    padding: 0.45rem 1.2rem;
    border-radius: 0 0 14px 14px;
    background: rgba(32, 34, 37, 0.97);
    backdrop-filter: blur(12px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
}

#voice-call-panel.minimized .voice-panel-content {
    flex-direction: row;
    gap: 0.85rem;
    justify-content: flex-start;
    width: auto;
    flex-grow: 0;
}

#voice-call-panel.minimized .voice-avatar-wrapper {
    width: 34px;
    height: 34px;
}

#voice-call-panel.minimized .voice-badge {
    width: 16px;
    height: 16px;
    font-size: 0.55rem;
    border-width: 1.5px;
    bottom: -2px;
}

#voice-call-panel.minimized .voice-mute-badge {
    right: -3px;
}

#voice-call-panel.minimized .voice-deafen-badge {
    left: -3px;
}

#voice-call-panel.minimized .voice-center-info {
    flex-direction: row;
    gap: 6px;
    min-width: auto;
}

#voice-call-panel.minimized .voice-status-text {
    margin-top: 0;
    font-size: 0.82rem;
    font-weight: 600;
    color: #43b581;
}

#voice-call-panel.minimized .voice-panel-controls {
    margin-top: 0;
    gap: 0.45rem;
}

#voice-call-panel.minimized .voice-btn {
    width: 34px;
    height: 34px;
    font-size: 0.85rem;
}

/* Responsywność */
@media (max-width: 600px) {
    #voice-call-panel {
        min-height: 150px;
    }
    .voice-avatar-wrapper {
        width: 68px;
        height: 68px;
    }
    .voice-panel-content {
        gap: 1.2rem;
    }
}

/* ========================================================
   DISCORD-STYLE SCREEN SHARING & STAGE
   ======================================================== */

.voice-btn.btn-screen-share {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-color);
}

.voice-btn.btn-screen-share:hover {
    background: rgba(0, 242, 254, 0.2);
    color: var(--accent-color, #00f2fe);
    border-color: rgba(0, 242, 254, 0.4);
}

.voice-btn.btn-screen-share.sharing {
    background: rgba(255, 71, 87, 0.25) !important;
    color: #ff4757 !important;
    border-color: #ff4757 !important;
    box-shadow: 0 0 16px rgba(255, 71, 87, 0.5);
    animation: pulseScreenShare 2s infinite ease-in-out;
}

@keyframes pulseScreenShare {
    0%, 100% { transform: scale(1); box-shadow: 0 0 12px rgba(255, 71, 87, 0.4); }
    50% { transform: scale(1.06); box-shadow: 0 0 22px rgba(255, 71, 87, 0.75); }
}

/* --- MODAL KONFIGURACJI STREAMU (DISCORD-STYLE) --- */
.discord-stream-modal {
    max-width: 480px;
    width: 90%;
    margin: auto;
    background: #181a24 !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    border-radius: 20px !important;
    padding: 1.6rem !important;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.8) !important;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    position: relative;
    box-sizing: border-box;
}

.stream-modal-close-btn {
    position: absolute;
    top: 1.25rem;
    right: 1.25rem;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.95rem;
    z-index: 10;
    transition: all 0.2s ease;
}

.stream-modal-close-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    border-color: #00f2fe;
}

.stream-modal-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    position: relative;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    padding-bottom: 1rem;
    padding-right: 2.5rem;
    box-sizing: border-box;
}

.stream-modal-icon-badge {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    color: #fff;
    box-shadow: 0 4px 16px rgba(0, 242, 254, 0.35);
    flex-shrink: 0;
}

.stream-modal-title-box h2 {
    margin: 0;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
}

.stream-modal-title-box p {
    margin: 0.2rem 0 0 0;
    font-size: 0.84rem;
    color: var(--secondary-text);
}

.stream-modal-body {
    display: flex;
    flex-direction: column;
    gap: 1.2rem;
}

.stream-config-section {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.stream-config-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #e2e8f0;
    display: flex;
    align-items: center;
    gap: 0.45rem;
}

.stream-config-label i {
    color: #00f2fe;
}

.stream-quality-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(105px, 1fr));
    gap: 0.55rem;
}

.stream-opt-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 0.65rem 0.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
}

.stream-opt-card .opt-main {
    font-size: 0.95rem;
    font-weight: 700;
    color: #fff;
}

.stream-opt-card .opt-sub {
    font-size: 0.72rem;
    color: var(--secondary-text);
    margin-top: 2px;
}

.stream-opt-card:hover {
    background: rgba(255, 255, 255, 0.08);
    border-color: rgba(0, 242, 254, 0.4);
    transform: translateY(-1px);
}

.stream-opt-card.active {
    background: rgba(0, 242, 254, 0.12);
    border-color: #00f2fe;
    box-shadow: 0 0 12px rgba(0, 242, 254, 0.3);
}

.stream-opt-card.active .opt-main {
    color: #00f2fe;
}

.stream-audio-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid rgba(255, 255, 255, 0.06);
    border-radius: 14px;
    padding: 0.75rem 1rem;
}

.stream-audio-info {
    display: flex;
    flex-direction: column;
}

.audio-row-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.audio-row-title i {
    color: #43b581;
}

.audio-row-desc {
    font-size: 0.76rem;
    color: var(--secondary-text);
    margin-top: 2px;
}

/* Discord Toggle Switch */
.discord-toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    flex-shrink: 0;
}

.discord-toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-track {
    position: absolute;
    cursor: pointer;
    top: 0; left: 0; right: 0; bottom: 0;
    background-color: rgba(255, 255, 255, 0.2);
    transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 24px;
}

.toggle-track:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s cubic-bezier(0.4, 0, 0.2, 1);
    border-radius: 50%;
}

.discord-toggle-switch input:checked + .toggle-track {
    background-color: #00f2fe;
    box-shadow: 0 0 10px rgba(0, 242, 254, 0.4);
}

.discord-toggle-switch input:checked + .toggle-track:before {
    transform: translateX(20px);
}

.stream-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    padding-top: 1rem;
}

.stream-btn-secondary {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: #cbd5e1;
    padding: 0.65rem 1.25rem;
    border-radius: 12px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.stream-btn-secondary:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.stream-btn-primary {
    background: linear-gradient(135deg, #00f2fe 0%, #4facfe 100%);
    border: none;
    color: #fff;
    padding: 0.65rem 1.4rem;
    border-radius: 12px;
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 4px 16px rgba(0, 242, 254, 0.35);
    transition: all 0.25s ease;
}

.stream-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 242, 254, 0.55);
}

/* --- BANER ZAPROSZENIA DO STREAMU (IN-CHAT BANNER) --- */
.stream-invite-banner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(90deg, rgba(255, 71, 87, 0.15) 0%, rgba(18, 20, 29, 0.95) 100%);
    border: 1px solid rgba(255, 71, 87, 0.35);
    border-radius: 12px;
    padding: 0.75rem 1.1rem;
    margin: 0.5rem 1rem 0.8rem 1rem;
    box-shadow: 0 4px 20px rgba(255, 71, 87, 0.2);
    animation: fadeInSlideDown 0.3s ease;
}

.stream-invite-banner.hidden {
    display: none !important;
}

.stream-invite-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.discord-live-pill {
    background: #ff4757;
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    padding: 0.2rem 0.55rem;
    border-radius: 6px;
    letter-spacing: 0.5px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 0 10px rgba(255, 71, 87, 0.6);
}

.discord-live-pill i {
    font-size: 0.5rem;
    animation: livePulse 1.2s infinite ease-in-out;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.3; transform: scale(0.8); }
}

.stream-invite-text {
    font-size: 0.88rem;
    color: #fff;
}

.stream-invite-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.watch-stream-btn {
    background: linear-gradient(135deg, #ff4757 0%, #ff6b81 100%);
    border: none;
    color: #fff;
    font-size: 0.82rem;
    font-weight: 700;
    padding: 0.45rem 0.9rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    box-shadow: 0 4px 12px rgba(255, 71, 87, 0.4);
    transition: all 0.2s ease;
}

.watch-stream-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(255, 71, 87, 0.6);
}

/* --- GŁÓWNY POWIĘKSZONY ODTWARZACZ STREAMU (Pływający & Skalowalny) --- */
.chat-stage-container {
    position: relative;
    width: fit-content;
    width: -moz-fit-content;
    max-width: min(880px, 94%);
    min-width: 320px;
    margin: 0.35rem auto;
    border-radius: 12px;
    background: #08090d;
    border: 1px solid rgba(0, 242, 254, 0.3);
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.75);
    overflow: hidden;
    flex-shrink: 0;
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
    z-index: 25;
    touch-action: none;
}

.chat-stage-container.hidden {
    display: none !important;
}

/* Pływający tryb okna streamu (Floating Draggable Window) */
.chat-stage-container.floating-mode {
    position: absolute;
    margin: 0;
    z-index: var(--z-pip);
    box-shadow: 0 16px 48px rgba(0, 0, 0, 0.88), 0 0 24px rgba(0, 242, 254, 0.35);
    border-color: rgba(0, 242, 254, 0.5);
    animation: fadeInScale 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-stage-container.floating-mode #stage-dock-toggle-btn {
    color: #00f2fe;
    background: rgba(0, 242, 254, 0.15);
}

.chat-stage-video-wrapper {
    position: relative;
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 10px;
    overflow: hidden;
}

.chat-stage-video-wrapper video {
    width: 100%;
    height: 100%;
    max-height: 52vh;
    aspect-ratio: 16 / 9;
    object-fit: contain;
    background: #000;
    display: block;
}

#stage-drag-handle {
    cursor: grab;
    user-select: none;
}

#stage-drag-handle:active {
    cursor: grabbing;
}

/* Uchwyt do zmiany rozmiaru w prawym dolnym rogu */
.stage-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    z-index: 30;
    background: linear-gradient(135deg, transparent 50%, rgba(0, 242, 254, 0.7) 50%);
    border-bottom-right-radius: 10px;
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.stage-resize-handle:hover {
    background: linear-gradient(135deg, transparent 50%, #00f2fe 50%);
    transform: scale(1.15);
}

/* Tryb Powiększony (Theater / Expand Mode) */
.chat-stage-container.theater-mode {
    max-width: 100%;
    width: 100%;
    border-radius: 0;
    margin: 0 0 0.5rem 0;
    border-left: none;
    border-right: none;
}
.chat-stage-container.theater-mode .chat-stage-video-wrapper {
    height: 480px;
    max-height: 65vh;
}
.chat-stage-container.theater-mode .chat-stage-video-wrapper video {
    max-height: 65vh;
}

/* Tryb Mini-Odtwarzacza (Picture-in-Picture / PiP - Floating & Draggable) */
.chat-stage-container.pip-mode {
    position: absolute;
    bottom: 85px;
    right: 20px;
    width: 290px;
    max-width: 290px;
    margin: 0;
    border-radius: 12px;
    border: 2px solid rgba(0, 242, 254, 0.45);
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.85), 0 0 20px rgba(0, 242, 254, 0.3);
    z-index: var(--z-pip);
    cursor: grab;
    touch-action: none;
    user-select: none;
    animation: fadeInSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.chat-stage-container.pip-mode:active {
    cursor: grabbing;
}

.chat-stage-container.pip-mode .chat-stage-video-wrapper {
    height: 163px;
    min-height: 163px;
    max-height: 163px;
    border-radius: 10px;
}

.chat-stage-container.pip-mode .stage-user-info,
.chat-stage-container.pip-mode .stage-quality-dropdown-wrapper,
.chat-stage-container.pip-mode .stage-streamer-overlay {
    display: none !important;
}

.chat-stage-container.pip-mode .stage-tile-header,
.chat-stage-container.pip-mode .chat-stage-header {
    top: 6px;
    left: 8px;
    right: 8px;
}

.chat-stage-container.pip-mode .stage-header-left,
.chat-stage-container.pip-mode .stage-header-right {
    padding: 0.2rem 0.45rem;
    gap: 0.25rem;
    border-radius: 8px;
}

.chat-stage-container.pip-mode .stage-icon-btn {
    width: 26px;
    height: 26px;
    font-size: 0.72rem;
    border-radius: 6px;
}

.stage-tile-header,
.chat-stage-header {
    position: absolute;
    top: 10px;
    left: 12px;
    right: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0;
    background: transparent;
    border: none;
    z-index: 15;
    pointer-events: none;
}

.discord-live-pill.self-live {
    background: rgba(0, 242, 254, 0.2);
    border: 1px solid rgba(0, 242, 254, 0.5);
    color: #00f2fe;
}

.stage-header-left {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(15, 16, 21, 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 0.3rem 0.65rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
}

.stage-user-info {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.85rem;
    font-weight: 700;
    color: #fff;
}

.stage-quality-badge {
    background: rgba(255, 255, 255, 0.1);
    color: #00f2fe;
    font-size: 0.7rem;
    font-weight: 700;
    padding: 0.12rem 0.4rem;
    border-radius: 6px;
    border: 1px solid rgba(0, 242, 254, 0.3);
}

.stage-header-right {
    pointer-events: auto;
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background: rgba(15, 16, 21, 0.82);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 0.3rem 0.55rem;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5);
    position: relative;
}

.stage-icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #cbd5e1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.stage-icon-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    color: #fff;
    transform: translateY(-1px);
}

.stage-icon-btn.danger {
    background: rgba(255, 71, 87, 0.2);
    border-color: rgba(255, 71, 87, 0.4);
    color: #ff4757;
}

.stage-icon-btn.danger:hover {
    background: #ff4757;
    color: #fff;
    box-shadow: 0 0 12px rgba(255, 71, 87, 0.5);
}

/* Menu Jakości w Locie */
.stage-quality-dropdown-wrapper {
    position: relative;
}

.stage-quality-menu {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    width: 170px;
    background: #181a24;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6);
    padding: 0.4rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
    z-index: var(--z-dropdown);
}

.stage-quality-menu.hidden {
    display: none !important;
}

.stage-menu-header {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--secondary-text);
    padding: 0.3rem 0.6rem;
    letter-spacing: 0.5px;
}

.stage-menu-item {
    background: transparent;
    border: none;
    color: #cbd5e1;
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.45rem 0.6rem;
    border-radius: 6px;
    text-align: left;
    cursor: pointer;
    transition: all 0.15s ease;
}

.stage-menu-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.stage-menu-item.active {
    background: rgba(0, 242, 254, 0.15);
    color: #00f2fe;
    font-weight: 700;
}

.chat-stage-video-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-stage-video-wrapper video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #000;
}

.stage-streamer-overlay {
    position: absolute;
    bottom: 12px;
    left: 14px;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(0, 242, 254, 0.4);
    border-radius: 20px;
    padding: 0.35rem 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #00f2fe;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
    pointer-events: none;
    z-index: 10;
}

.stage-streamer-overlay.hidden {
    display: none !important;
}

/* --- DISCORD STAGE: FOCUS & THUMBNAIL OVERLAY --- */
.stage-grid-wrapper.focus-layout {
    position: relative;
    display: block;
    width: 100%;
}

.stage-grid-wrapper.focus-layout .stage-tile.focused {
    width: 100%;
    border-radius: 12px;
    z-index: 1;
}

.stage-grid-wrapper.focus-layout .stage-tile.thumbnail {
    position: absolute;
    bottom: 16px;
    right: 16px;
    width: 220px;
    max-width: 35%;
    border-radius: 10px;
    border: 2px solid rgba(0, 242, 254, 0.6);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.85), 0 0 16px rgba(0, 242, 254, 0.25);
    z-index: 20;
    cursor: pointer;
    overflow: hidden;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
}

.stage-grid-wrapper.focus-layout .stage-tile.thumbnail:hover {
    transform: scale(1.05);
    border-color: #00f2fe;
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.9), 0 0 24px rgba(0, 242, 254, 0.5);
}

.stage-grid-wrapper.focus-layout .stage-tile.thumbnail .stage-tile-header {
    top: 4px;
    left: 6px;
    right: 6px;
}

.stage-grid-wrapper.focus-layout .stage-tile.thumbnail .stage-header-right {
    display: none; /* Ukryj zbędne przyciski w miniaturce */
}

.stage-grid-wrapper.focus-layout .stage-tile.thumbnail .stage-header-left {
    padding: 0.15rem 0.4rem;
    font-size: 0.7rem;
}

/* --- PŁYWAJĄCE MENU KONTEKSTOWE DLA STREAMU (Right-Click Context Menu) --- */
.stream-context-menu {
    position: fixed;
    background: rgba(13, 15, 22, 0.95);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(0, 242, 254, 0.3);
    border-radius: 12px;
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.85), 0 0 20px rgba(0, 242, 254, 0.2);
    padding: 0.5rem 0;
    min-width: 220px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    animation: fadeInScale 0.15s ease-out;
}

.stream-context-menu.hidden {
    display: none !important;
}

.context-menu-header {
    padding: 0.4rem 0.85rem;
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--secondary-text);
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 0.25rem;
}

.context-menu-section {
    padding: 0.4rem 0.85rem;
}

.ctx-volume-row {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    color: #cbd5e1;
    font-size: 0.85rem;
}

.stream-volume-slider {
    flex: 1;
    accent-color: #00f2fe;
    cursor: pointer;
    height: 4px;
}

#ctx-volume-value {
    font-size: 0.75rem;
    font-weight: 700;
    color: #00f2fe;
    min-width: 32px;
    text-align: right;
}

.context-menu-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.08);
    margin: 0.35rem 0;
}

.ctx-menu-item {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    padding: 0.5rem 0.85rem;
    background: transparent;
    border: none;
    color: #e2e8f0;
    font-size: 0.85rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
    width: 100%;
}

.ctx-menu-item:hover {
    background: rgba(0, 242, 254, 0.12);
    color: #00f2fe;
}

.ctx-menu-item.ctx-danger {
    color: #ff4757;
}

.ctx-menu-item.ctx-danger:hover {
    background: rgba(255, 71, 87, 0.15);
    color: #ff6b81;
}

@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Przycisk oglądania streamu w navbarze (Discord-style Live Watch Pill) */
.header-watch-stream-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.75rem;
    border-radius: 20px;
    background: rgba(255, 71, 87, 0.15);
    border: 1px solid rgba(255, 71, 87, 0.4);
    color: #ff4757;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 0 12px rgba(255, 71, 87, 0.2);
}

.header-watch-stream-btn:hover {
    background: rgba(255, 71, 87, 0.25);
    border-color: #ff4757;
    transform: translateY(-1px);
    box-shadow: 0 0 16px rgba(255, 71, 87, 0.4);
}

.header-watch-stream-btn.hidden {
    display: none !important;
}

@keyframes pulseRed {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.3); opacity: 0.6; }
    100% { transform: scale(1); opacity: 1; }
}

@media (max-width: 600px) {
    .chat-stage-container {
        width: 100%;
        border-radius: 0;
        margin: 0 0 0.5rem 0;
    }
}