/* Analytics Layout */
.analytics-layout {
    display: grid;
    grid-template-columns: 320px 1fr;
    gap: 20px;
}

.sidebar-controls {
    background: #1e1e1e;
    padding: 20px;
    border-radius: 12px;
    border: 1px solid #333;
    height: calc(100vh - 100px);
    /* Fixed height instead of max */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    /* Ensure nothing leaks out */
}

/* Ensure the inner group fills the space */
.sidebar-controls .control-group {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    /* Critical for nested flex scrolling */
}

.main-chart-area {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Time Control Bar */
.time-control-bar {
    background: #1e1e1e;
    padding: 15px 20px;
    border-radius: 12px;
    border: 1px solid #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.time-ranges {
    display: flex;
    gap: 10px;
}

/* Styled Range Buttons (like Nav Links) */
.range-btn {
    background: transparent;
    color: #aaaaaa;
    border: 1px solid transparent;
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    font-family: inherit;
    font-size: 0.95rem;
}

.range-btn:hover {
    color: white;
    background: #333;
}

.range-btn.active {
    background: #ff0000;
    color: white;
    border-color: #ff0000;
}

/* Action Buttons (Select All/None) */
.actions-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.action-btn {
    background: #252525;
    color: #ccc;
    border: 1px solid #333;
    padding: 8px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 600;
    font-size: 0.85rem;
    flex: 1;
    transition: all 0.2s;
}

.action-btn:hover {
    background: #333;
    color: white;
    border-color: #555;
}

/* Channel List */
.channel-select-container {
    flex: 1;
    overflow-y: auto;
    background: #151515;
    /* Slightly darker inner bg */
    border: 1px solid #333;
    border-radius: 8px;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-height: 200px;
    /* Reduced min-height to prevent forcing layout too big */
    /* It's constrained by the sidebar flex parent generally, but let's be safe */
}

/* Custom Scrollbar for Dark Theme */
.channel-select-container::-webkit-scrollbar {
    width: 8px;
}

.channel-select-container::-webkit-scrollbar-track {
    background: #151515;
}

.channel-select-container::-webkit-scrollbar-thumb {
    background-color: #333;
    border-radius: 4px;
    border: 1px solid #151515;
}

.channel-select-container::-webkit-scrollbar-thumb:hover {
    background-color: #555;
}

.channel-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s;
}

.channel-option:hover {
    background: #252525;
}

.channel-logo-mini {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    background: #333;
    border: 1px solid #444;
}

/* Control Inputs */
#channelSearch,
#sortMode {
    width: 100%;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #333;
    background: #151515;
    color: white;
    margin-bottom: 12px;
    font-family: inherit;
    font-size: 0.9rem;
    box-sizing: border-box;
    /* Fix width issues */
}

#channelSearch:focus,
#sortMode:focus {
    outline: none;
    border-color: #555;
}

.search-container {
    position: relative;
    width: 100%;
}

.clear-btn {
    position: absolute;
    right: 10px;
    top: 45%;
    transform: translateY(-55%);
    /* Slightly higher to offset visual weight */
    background: none;
    border: none;
    color: #888;
    cursor: pointer;
    font-size: 1.2rem;
    line-height: 1;
    /* Normalize height */
    padding: 0;
    padding-bottom: 2px;
    /* Visual lift */
    display: none;
    /* Hidden by default */
}

.clear-btn:hover {
    color: #fff;
}

/* Responsive */
@media (max-width: 900px) {
    .analytics-layout {
        grid-template-columns: 1fr;
    }

    .sidebar-controls {
        max-height: none;
        height: auto;
    }

    .channel-select-container {
        min-height: 250px;
        max-height: 300px;
    }

    .time-control-bar {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .time-ranges {
        flex-wrap: wrap;
    }

    .range-btn {
        flex: 1;
        text-align: center;
        background: #252525;
    }
}