/**
 * Modern Sidebar - Twitch/Kick Inspired
 * Compact, collapsible, and mobile-friendly
 */

/* Sidebar Container */
.sidebar {
    position: fixed;
    left: 0;
    top: 50px;
    width: 240px;
    height: calc(100vh - 50px);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: var(--z-fixed);
    overflow: hidden;
}

.sidebar.collapsed {
    width: 50px;
}

/* Ensure main content doesn't overlap with sidebar */
body {
    margin-left: 0;
}

@media (min-width: 769px) {
    .content {
        margin-left: 240px !important;
        transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }
    
    .sidebar.collapsed ~ .content {
        margin-left: 50px !important;
    }
}

/* Sidebar Content */
.sidebar-content {
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Sidebar Toggle Button */
.sidebar-toggle {
    position: absolute;
    top: 10px;
    right: -35px;
    width: 30px;
    height: 30px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-left: none;
    border-radius: 0 6px 6px 0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
}

.sidebar-toggle:hover {
    background: var(--bg-hover);
}

.sidebar-toggle svg {
    width: 16px;
    height: 16px;
    color: var(--text-secondary);
    transition: transform 0.3s ease;
}

.sidebar.expanded .sidebar-toggle svg {
    transform: rotate(180deg);
}

/* Navigation Section */
.sidebar-nav {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-nav-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    position: relative;
    height: 40px;
}

.sidebar-nav-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-nav-item.active {
    color: var(--primary-purple);
}

.sidebar-nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary-purple);
}

/* Nav Icons */
.nav-icon {
    width: 50px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.nav-icon svg {
    width: 20px;
    height: 20px;
}

/* Nav Text */
.nav-text {
    flex: 1;
    text-align: left;
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
    padding-right: 16px;
}

.sidebar.expanded .nav-text {
    opacity: 1;
}

/* For You Section */
.sidebar-section {
    padding: 12px 0;
}

.sidebar-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 16px;
    min-height: 32px;
}

.sidebar-section-title {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-tertiary);
    letter-spacing: 0.5px;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar.expanded .sidebar-section-title {
    opacity: 1;
}

.section-toggle {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    border-radius: 4px;
    transition: all 0.2s ease;
    margin-left: auto;
}

.section-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.section-toggle svg {
    width: 12px;
    height: 12px;
    transition: transform 0.2s ease;
}

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

/* Channels List */
.channels-list {
    padding: 0;
    transition: all 0.3s ease;
}

.sidebar-section.collapsed .channels-list {
    display: none;
}

.channel-item {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    height: 36px;
}

.channel-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Channel Avatar */
.channel-avatar {
    width: 50px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.avatar-img {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    color: var(--text-primary);
}

/* Channel Info */
.channel-info {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-right: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar.expanded .channel-info {
    opacity: 1;
}

.channel-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.channel-status {
    display: flex;
    align-items: center;
    gap: 4px;
}

.live-dot {
    width: 6px;
    height: 6px;
    background: var(--accent-red);
    border-radius: 50%;
    animation: pulse 2s ease-in-out infinite;
}

.viewer-count {
    font-size: 12px;
    color: var(--text-tertiary);
}

/* Bottom Actions */
.sidebar-footer {
    margin-top: auto;
    padding: 8px 0;
    border-top: 1px solid var(--border-color);
}

.sidebar-action {
    display: flex;
    align-items: center;
    width: 100%;
    padding: 0;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    height: 40px;
}

.sidebar-action:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Collapsed State Tooltips */
.sidebar:not(.expanded) .sidebar-nav-item:hover::after,
.sidebar:not(.expanded) .channel-item:hover::after,
.sidebar:not(.expanded) .sidebar-action:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 8px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    color: var(--text-primary);
    font-size: 12px;
    font-weight: 500;
    border-radius: 6px;
    white-space: nowrap;
    box-shadow: var(--shadow-md);
    z-index: 1000;
    pointer-events: none;
    opacity: 0;
    animation: tooltipFadeIn 0.2s ease forwards;
}

@keyframes tooltipFadeIn {
    to { opacity: 1; }
}

/* Main Content Adjustment */
.content {
    margin-left: 50px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.expanded ~ .content {
    margin-left: 240px;
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        width: 240px !important;
        z-index: var(--z-modal);
    }
    
    .sidebar.open {
        transform: translateX(0);
        box-shadow: var(--shadow-xl);
    }
    
    .sidebar-toggle {
        display: none;
    }
    
    .content {
        margin-left: 0 !important;
    }
    
    /* Mobile Overlay */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: calc(var(--z-modal) - 1);
    }
    
    .sidebar.open ~ .sidebar-overlay {
        display: block;
    }
    
    /* All items expanded on mobile */
    .nav-text,
    .sidebar-section-title,
    .channel-info {
        opacity: 1 !important;
    }
}

@media (max-width: 768px) {
    .sidebar {
        top: 50px;
        height: calc(100vh - 50px - 60px); /* Account for mobile nav */
    }
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Scrollbar Styling */
.sidebar-content::-webkit-scrollbar {
    width: 4px;
}

.sidebar-content::-webkit-scrollbar-track {
    background: transparent;
}

.sidebar-content::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 2px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: var(--bg-active);
}