/* ==========================================================================
   3. HEADER & CONTROLS
   ========================================================================== */
.main-header {
    background-color: var(--bg-header);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    height: 64px;
    gap: 16px;
    z-index: 100;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    flex-shrink: 0;
}

.header-left { display: flex; align-items: center; gap: 16px; }
.search-box { 
    position: relative; 
    display: flex; 
    align-items: center;
    background-color: var(--bg-main);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    width: 320px;
}

.search-box:focus-within {
    border-color: var(--primary);
    background-color: var(--bg-card);
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.1);
    width: 380px;
}

.search-icon {
    padding-left: 14px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    pointer-events: none;
}

.search-box input[type="text"] {
    background: none;
    border: none;
    width: 100%;
    padding: 10px 14px 10px 8px;
    box-shadow: none;
}

.suggestions-container {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: 100%;
    background-color: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    max-height: 400px;
    overflow-y: auto;
    display: none;
}

.suggestion-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.suggestion-item:hover {
    background-color: var(--bg-main);
}

.suggestion-item img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.suggestion-info {
    display: flex;
    flex-direction: column;
}

.suggestion-name {
    font-size: 14px;
    font-weight: 700;
}

.suggestion-status.live { color: var(--status-online); font-weight: 800; }
.suggestion-status.offline { color: var(--text-muted); }

.suggestion-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 11px;
    color: var(--text-muted);
}

.suggestion-game {
    color: var(--primary);
    font-weight: 700;
    max-width: 120px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.action-buttons { display: flex; gap: 8px; }

.brand {
    font-weight: 900;
    font-size: 24px;
    background: linear-gradient(135deg, var(--primary), var(--accent-pink));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    cursor: pointer;
    letter-spacing: 1px;
    user-select: none;
}

/* ==========================================================================
   4. LAYOUT & SIDEBAR
   ========================================================================== */
.layout {
    display: flex;
    flex: 1;
    overflow: hidden;
    position: relative;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding: 32px;
    height: 100%;
}

/* Resizer & Handles */
.resizer-h {
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    z-index: 110;
    transition: background-color 0.2s;
}

.resizer-h:hover, .resizer-h.resizing {
    background-color: var(--primary);
}

.resizer-v {
    position: absolute;
    top: -3px;
    left: 0;
    right: 0;
    height: 6px;
    cursor: row-resize;
    z-index: 110;
    transition: background-color 0.2s;
    background: transparent;
}

.resizer-v:hover, .resizer-v.resizing {
    background-color: var(--primary);
}

#chat-resizer {
    left: -3px;
    right: auto;
}

.player-wrapper.active[style*="--chat-order: 1"] #chat-resizer {
    left: auto;
    right: -3px;
}

.chat-drag-handle {
    position: absolute;
    top: 4px;
    left: 50%;
    transform: translateX(-50%);
    color: var(--text-muted);
    cursor: grab;
    padding: 2px 20px;
    opacity: 0.3;
    transition: all 0.2s;
    z-index: 10;
    background: rgba(255,255,255,0.05);
    border-radius: 10px;
}

.chat-drag-handle:hover { opacity: 1; }
.chat-drag-handle:active { cursor: grabbing; }

.player-wrapper.is-dragging .chat-container {
    opacity: 0.7;
    outline: 2px dashed var(--primary);
    outline-offset: -4px;
    transition: opacity 0.2s, outline 0.2s;
}

.player-wrapper.is-dragging #twitch-embed {
    opacity: 0.9;
}

.chat-container {
    position: relative;
    padding-top: 20px; /* Space for drag handle bar */
}

.sidebar {
    position: relative;
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background-color: var(--glass-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    z-index: 95;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed {
    margin-left: calc(-1 * var(--sidebar-width));
}

.aside-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 20px 16px;
    border-bottom: 1px solid var(--border-color);
}

.aside-header h3 {
    font-size: 13px;
    font-weight: 900;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-main);
    opacity: 0.8;
}

.fav-list { padding: 12px; display: flex; flex-direction: column; gap: 6px; }

.fav-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    border-radius: 14px;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    border: 1px solid transparent;
}

.fav-item:hover {
    background: var(--bg-card);
    border-color: rgba(139, 92, 246, 0.2);
    transform: translateX(6px);
    box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.1);
}

.fav-item.active {
    background-color: var(--primary);
    color: #fff;
}

.fav-item.active .fav-name { color: #fff; }
.fav-item.active .dot { border-color: var(--primary); }

.fav-info { display: flex; align-items: center; gap: 12px; overflow: hidden; flex: 1; }
.fav-name { font-size: 14px; font-weight: 600; }
.avatar-container { position: relative; display: inline-block; }

.avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border-color);
}

.dot {
    position: absolute;
    bottom: -1px;
    right: -1px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--status-offline);
    border: 2px solid var(--bg-card);
}

.dot.live {
    background: var(--status-online);
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.3);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
    70% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
    100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0); }
}

.btn-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    padding: 2px 8px;
    border-radius: 6px;
    cursor: pointer;
    opacity: 0;
    transition: all 0.15s ease;
}

.fav-item:hover .btn-delete { opacity: 0.6; }
.btn-delete:hover { opacity: 1 !important; color: var(--accent-pink); background-color: rgba(244, 63, 94, 0.1); }

/* Layout Responsive */
@media (max-width: 900px) {
    :root {
        --sidebar-width: 280px !important;
    }

    [data-tooltip]::after, [data-tooltip]::before { display: none !important; }

    .search-box { width: 100% !important; margin: 0 10px; }
    .search-box:focus-within { width: 100% !important; }

    .player-wrapper.active {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto auto 400px !important;
        grid-template-areas: "embed" "footer" "chat" !important;
    }

    .chat-container {
        width: 100% !important;
        height: 400px; /* Feste Höhe auf Mobile, damit man scrollen kann */
        display: flex;
    }

    .player-wrapper.active.chat-hidden .chat-container {
        display: none !important;
    }

    .main-header { 
        padding: 12px 16px;
    }
    .brand { font-size: 20px; }
    .header-left { gap: 12px; }
    .search-box { display: none; } /* Hide main search on mobile, maybe use a toggle later */
    
    .sidebar { 
        position: absolute; 
        top: 0; 
        bottom: 0; 
        left: 0; 
        width: var(--sidebar-width);
        min-width: var(--sidebar-width);
        box-shadow: 20px 0 50px rgba(0,0,0,0.3);
        background-color: var(--bg-card); /* No glass on mobile for performance */
    }
    
    .main-content { 
        padding: 16px; 
    }
    
    .btn-delete { opacity: 0.8 !important; }

    .resizer-h, .resizer-v, .chat-drag-handle { display: none !important; }
    .chat-container { padding-top: 0 !important; }
}
