/* ═══════════════════════════════════════════════════════════
   App Shell & Grid Layout
════════════════════════════════════════════════════════════ */
#app {
    display: flex;
    height: 100vh;
    width: 100vw;
}

/* ── Sidebar ─────────────────────────────────────────────── */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: var(--sidebar-width);
    height: 100%;
    background-color: var(--sidebar-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid var(--sidebar-border);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 100;
    overflow-y: auto;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.8);
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar.side-right {
    left: auto;
    right: 0;
    border-right: none;
    border-left: 1px solid var(--sidebar-border);
}

.sidebar.side-right.collapsed {
    transform: translateX(100%);
}

/* Sidebar overlay (captures outside clicks) */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: transparent;
    z-index: 95;
    /* Above streams, below sidebar (100) */
    display: none;
}

body.sidebar-open .sidebar-overlay {
    display: block;
}

/* ── Sidebar Header ──────────────────────────────────────── */
.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--sidebar-border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 700;
    font-size: 14px;
}

.logo-img {
    width: 24px;
    height: 24px;
    object-fit: contain;
    border-radius: 6px;
}

/* ── Sidebar Sections ────────────────────────────────────── */
.sidebar-section {
    padding: 0;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-section.sub-section {
    border: 1px solid rgba(255, 255, 255, 0.05);
    background: rgba(0, 0, 0, 0.2);
    margin: 6px 0;
    border-radius: 8px;
    box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.2);
}

.sidebar-section.sub-section:first-of-type {
    margin-top: 8px;
}

.sidebar-section.sub-section .sidebar-section-header {
    padding: 8px 12px;
}

.sidebar-section.sub-section .sidebar-section-header h3 {
    font-size: 11px;
    /* Matching top-level section h3 size */
    opacity: 1;
    color: var(--text-primary);
}

.sidebar-section.sub-section .sidebar-section-content {
    padding: 0 12px 8px 12px;
}

.sidebar-section-header {
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.sidebar-section-header:hover {
    background: rgba(255, 255, 255, 0.03);
}

.sidebar-section-header h3 {
    font-size: 11px;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 700;
    margin-bottom: 0 !important;
    display: flex;
    align-items: center;
    gap: 6px;
}

.header-title-group {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.sidebar-section-header .toggle-icon {
    font-size: 10px;
    color: var(--text-muted);
    transition: transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-section.collapsed .toggle-icon {
    transform: rotate(-90deg);
}

.sidebar-section-content {
    padding: 0 14px 14px 14px;
    overflow: visible;
    max-height: 2000px;
    transition: max-height 0.15s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.15s, padding 0.15s;
    opacity: 1;
}

.sidebar-section.collapsed .sidebar-section-content {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    padding-top: 0;
    padding-bottom: 0;
    pointer-events: none;
}

.toggle-icon-svg {
    width: 14px;
    height: 14px;
}

/* ── Main Content Area ───────────────────────────────────── */
.main-content {
    width: 100vw;
    height: 100vh;
    background-color: var(--bg-color);
    position: relative;
    display: flex;
    flex-direction: column;
}

/* Content area — side-by-side: streams + chat */
.content-area {
    flex: 1;
    display: flex;
    flex-direction: row;
    overflow: hidden;
    height: 100%;
    width: 100%;
}

/* ── Floating Controls (Open Sidebar / Fullscreen / Pause) ─ */
.floating-controls {
    position: fixed;
    top: 20px;
    left: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 110;
    padding: 40px;
    /* Hitbox area */
    margin: -40px;
    /* Offset hitbox */
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1),
        right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.floating-controls.side-right {
    left: auto;
    right: 20px;
}

/* Stick to sidebar edge when sidebar is open (left side) */
body.sidebar-open .floating-controls:not(.side-right) {
    left: calc(var(--sidebar-width) + 12px);
}

/* Stick to sidebar edge when sidebar is open (right side) */
body.sidebar-open .floating-controls.side-right {
    right: calc(var(--sidebar-width) + 12px);
}

/* ── Streams Container ───────────────────────────────────── */
.streams-container {
    flex: 1;
    position: relative;
    min-width: 0;
    height: 100%;
    overflow: hidden;
    /* Avoid scrollbars */
}

/* ── Chat Panel ──────────────────────────────────────────── */
.chat-panel {
    width: 340px;
    flex-shrink: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: rgba(14, 14, 18, 0.97);
    border-left: 1px solid var(--sidebar-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    animation: slideInRight 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.chat-panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-bottom: 1px solid var(--sidebar-border);
    background: rgba(28, 28, 34, 0.85);
    flex-shrink: 0;
}

.chat-panel-header span {
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 7px;
}

.chat-panel-header span i {
    color: var(--accent);
}

.chat-panel iframe {
    flex: 1;
    border: none;
    width: 100%;
    height: 100%;
    min-height: 0;
}

/* ── Stream Wrapper (individual player) ─────────────────── */
.stream-wrapper {
    position: relative;
    background: #181818;
    border-radius: 4px;
    overflow: hidden;
}

.stream-wrapper iframe,
.stream-wrapper>div {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    border: none;
}

/* Twitch SDK injects a nested iframe inside a div — ensure it fills too */
.stream-wrapper>div>iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    border: none;
}