/* sidebar.css - Complete Sidebar Styles with Mobile Support */

:root {
    --nav-height: 60px;
    --sidebar-width: 260px;
    --sidebar-collapsed: 72px;
}

/* ============ SIDEBAR BASE ============ */
.sidebar {
    position: fixed;
    top: var(--nav-height);
    left: 0;
    bottom: 0;
    width: var(--sidebar-width);
    background: var(--color-white, #ffffff);
    border-right: 1px solid var(--color-gray-200, #e5e7eb);
    z-index: 90;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
}

[data-theme="dark"] .sidebar {
    background: #0F172A;
    border-right-color: #334155;
}

/* ============ DESKTOP COLLAPSED STATE ============ */
@media (min-width: 1024px) {
    .sidebar.collapsed {
        width: var(--sidebar-collapsed);
    }
    
    .sidebar.collapsed .sidebar-link-text,
    .sidebar.collapsed .sidebar-section-title,
    .sidebar.collapsed .sidebar-badge,
    .sidebar.collapsed .streak-widget {
        display: none;
    }
    
    .sidebar.collapsed .sidebar-link {
        justify-content: center;
        padding: 0.75rem;
    }
    
    .sidebar.collapsed .sidebar-link-icon {
        margin: 0;
    }
    
    .sidebar.collapsed .sidebar-section {
        padding: 0.25rem 0;
    }
    
    .sidebar.collapsed .sidebar-nav {
        padding: 0 0.75rem;
    }
    
    .sidebar.collapsed .sidebar-divider {
        margin: 0.5rem 1rem;
    }
    
    .sidebar.collapsed .chevron-left {
        display: none !important;
    }
    
    .sidebar.collapsed .chevron-right {
        display: block !important;
    }
}

/* ============ MOBILE STYLES ============ */
@media (max-width: 1023px) {
    .sidebar {
        transform: translateX(-100%);
        z-index: 999;
        width: 280px;
        box-shadow: 0 0 0 rgba(0, 0, 0, 0);
        transition: transform 0.3s ease, box-shadow 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
        box-shadow: 4px 0 24px rgba(0, 0, 0, 0.15);
    }
    
    /* Hide collapse button on mobile */
    .sidebar-collapse-handle {
        display: none !important;
    }
    
    /* Content doesn't shift on mobile */
    .main-content {
        padding-left: 0 !important;
        margin-left: 0 !important;
    }
    
    .main-content.sidebar-collapsed {
        padding-left: 0 !important;
        margin-left: 0 !important;
    }
}

/* ============ MOBILE OVERLAY ============ */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    z-index: 998;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease, background-color 0.3s ease;
}

.sidebar-overlay.active {
    background: rgba(0, 0, 0, 0.5);
    pointer-events: auto;
    opacity: 1;
}

/* ============ SIDEBAR CONTENT ============ */
.sidebar-content {
    height: 100%;
    display: flex;
    flex-direction: column;
    padding: 1rem 0;
    overflow-y: auto;
    overflow-x: hidden;
}

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

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

.sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.5);
    border-radius: 3px;
}

.sidebar-content::-webkit-scrollbar-thumb:hover {
    background: rgba(156, 163, 175, 0.7);
}

/* ============ SIDEBAR SECTIONS ============ */
.sidebar-section {
    padding: 0 0.75rem;
    margin-bottom: 0.5rem;
}

.sidebar-section-title {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: #6b7280;
    padding: 0.5rem 1rem;
    margin: 0 0 0.5rem 0;
}

[data-theme="dark"] .sidebar-section-title {
    color: #9ca3af;
}

.sidebar-divider {
    height: 1px;
    background: #e5e7eb;
    margin: 0.5rem 1rem;
}

[data-theme="dark"] .sidebar-divider {
    background: #334155;
}

/* ============ SIDEBAR NAVIGATION ============ */
.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.sidebar-link {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    border-radius: 0.75rem;
    color: #4b5563;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
    white-space: nowrap;
    cursor: pointer;
}

[data-theme="dark"] .sidebar-link {
    color: #9ca3af;
}

.sidebar-link:hover {
    background: #f3f4f6;
    color: #111827;
    transform: translateX(2px);
}

[data-theme="dark"] .sidebar-link:hover {
    background: rgba(51, 65, 85, 0.5);
    color: #f1f5f9;
}

/* Active State */
.sidebar-link.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.1), rgba(139, 92, 246, 0.1));
    color: #6366f1;
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 3px;
    height: 60%;
    background: linear-gradient(135deg, #6366F1, #8B5CF6);
    border-radius: 0 3px 3px 0;
}

/* Link Icon */
.sidebar-link-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.sidebar-link:hover .sidebar-link-icon {
    transform: scale(1.1);
}

/* Gradient Icons */
.sidebar-link-icon.gradient-purple { color: #8B5CF6; }
.sidebar-link-icon.gradient-blue { color: #0EA5E9; }
.sidebar-link-icon.gradient-green { color: #10B981; }

/* Link Text */
.sidebar-link-text {
    flex: 1;
}

/* ============ BADGES ============ */
.sidebar-badge {
    padding: 0.125rem 0.5rem;
    border-radius: 0.375rem;
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.sidebar-badge.new {
    background: #EF4444;
    color: white;
}

.sidebar-badge.live {
    background: #10B981;
    color: white;
    animation: pulse-badge 2s infinite;
}

@keyframes pulse-badge {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* ============ STREAK WIDGET ============ */
.streak-widget {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin: 0 0.75rem;
    background: linear-gradient(135deg, #F97316, #EF4444);
    border-radius: 0.75rem;
    color: white;
}

.streak-icon {
    font-size: 1.5rem;
    animation: flame 1.5s ease-in-out infinite;
}

@keyframes flame {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.1) rotate(-5deg); }
    75% { transform: scale(1.1) rotate(5deg); }
}

.streak-info {
    flex: 1;
}

.streak-label {
    font-size: 0.625rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.streak-value {
    display: flex;
    align-items: baseline;
    gap: 0.25rem;
}

.streak-number {
    font-size: 1.25rem;
    font-weight: 700;
}

.streak-text {
    font-size: 0.75rem;
    opacity: 0.9;
}

/* ============ SIDEBAR FOOTER ============ */
.sidebar-footer {
    margin-top: auto;
    padding-top: 0.5rem;
}

.sidebar-spacer {
    flex: 1;
    min-height: 1rem;
}

/* ============ COLLAPSE HANDLE (Desktop Only) ============ */
.sidebar-collapse-handle {
    position: absolute;
    right: -20px;
    top: 24px;
    width: 40px;
    height: 40px;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 91;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

[data-theme="dark"] .sidebar-collapse-handle {
    background: #0F172A;
    border-color: #334155;
}

.sidebar-collapse-handle:hover {
    background: #f9fafb;
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

[data-theme="dark"] .sidebar-collapse-handle:hover {
    background: #334155;
}

.chevron-left, .chevron-right {
    color: #6b7280;
}

/* ============ TOOLTIPS (Desktop Collapsed) ============ */
@media (min-width: 1024px) {
    .sidebar.collapsed .sidebar-link::after {
        content: attr(data-tooltip);
        position: absolute;
        left: calc(100% + 0.5rem);
        top: 50%;
        transform: translateY(-50%);
        padding: 0.5rem 0.75rem;
        background: #111827;
        color: white;
        font-size: 0.75rem;
        border-radius: 0.5rem;
        white-space: nowrap;
        opacity: 0;
        visibility: hidden;
        transition: all 0.2s ease;
        pointer-events: none;
        z-index: 100;
    }
    
    .sidebar.collapsed .sidebar-link:hover::after {
        opacity: 1;
        visibility: visible;
        left: calc(100% + 1rem);
    }
}

/* ============ RESPONSIVE ADJUSTMENTS ============ */
@media (max-width: 768px) {
    .sidebar {
        width: 85%;
        max-width: 320px;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 80%;
        max-width: 280px;
    }
    
    .sidebar-link {
        padding: 0.5rem 0.75rem;
    }
    
    .sidebar-section {
        padding: 0 0.5rem;
    }
}
/* ============ FOLDERS SECTION ============ */
.sidebar-folders-container {
    margin: 0.5rem 0;
}

/* Folders Toggle Button */
.sidebar-folders-toggle {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1rem;
    border: none;
    background: transparent;
    border-radius: 0.75rem;
    color: #4b5563;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

[data-theme="dark"] .sidebar-folders-toggle {
    color: #9ca3af;
}

.sidebar-folders-toggle:hover {
    background: #f3f4f6;
    color: #111827;
    transform: translateX(2px);
}

[data-theme="dark"] .sidebar-folders-toggle:hover {
    background: rgba(51, 65, 85, 0.5);
    color: #f1f5f9;
}

/* Empty state */
.sidebar-folders-toggle.empty {
    opacity: 0.7;
    border: 1px dashed #e5e7eb;
}

[data-theme="dark"] .sidebar-folders-toggle.empty {
    border-color: #4b5563;
}

.sidebar-folders-toggle.empty:hover {
    opacity: 1;
    border-style: solid;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.05), rgba(139, 92, 246, 0.05));
}

/* Folder count badge */
.sidebar-folder-count {
    margin-left: auto;
    padding: 0.125rem 0.375rem;
    background: rgba(99, 102, 241, 0.1);
    color: #6366f1;
    border-radius: 0.25rem;
    font-size: 0.625rem;
    font-weight: 600;
}

[data-theme="dark"] .sidebar-folder-count {
    background: rgba(99, 102, 241, 0.2);
}

/* Chevron icon */
.sidebar-chevron {
    margin-left: 0.25rem;
    transition: transform 0.2s ease;
    flex-shrink: 0;
}

.sidebar-folders-toggle[aria-expanded="true"] .sidebar-chevron {
    transform: rotate(180deg);
}

/* Folders List */
.sidebar-folders-list {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
    padding-left: 0.5rem;
}

.sidebar-folders-list.expanded {
    max-height: 400px;
    overflow-y: auto;
    margin: 0.25rem 0;
}

/* Custom scrollbar for folders list */
.sidebar-folders-list::-webkit-scrollbar {
    width: 4px;
}

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

.sidebar-folders-list::-webkit-scrollbar-thumb {
    background: rgba(156, 163, 175, 0.3);
    border-radius: 2px;
}

/* Folder Item */
.sidebar-folder-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    margin: 0.125rem 0;
    border-radius: 0.5rem;
    color: #6b7280;
    text-decoration: none;
    font-size: 0.8125rem;
    transition: all 0.15s ease;
    position: relative;
}

[data-theme="dark"] .sidebar-folder-item {
    color: #9ca3af;
}

.sidebar-folder-item:hover {
    background: #f9fafb;
    color: #111827;
    transform: translateX(2px);
}

[data-theme="dark"] .sidebar-folder-item:hover {
    background: rgba(51, 65, 85, 0.3);
    color: #e5e7eb;
}

.sidebar-folder-item.active {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.08), rgba(139, 92, 246, 0.08));
    color: #6366f1;
}

/* Folder Icon */
.folder-icon222 {
    font-size: 1rem;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Folder Name */
.folder-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Folder item count */
.folder-count {
    font-size: 0.625rem;
    color: #9ca3af;
    background: #f3f4f6;
    padding: 0.0625rem 0.25rem;
    border-radius: 0.25rem;
}

[data-theme="dark"] .folder-count {
    background: rgba(51, 65, 85, 0.5);
    color: #9ca3af;
}

/* New Folder Button */
.sidebar-new-folder {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: calc(100% - 0.5rem);
    margin: 0.5rem 0.25rem 0.25rem;
    padding: 0.375rem 0.75rem;
    border: 1px dashed #e5e7eb;
    background: transparent;
    border-radius: 0.5rem;
    color: #6b7280;
    font-size: 0.75rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s ease;
}

[data-theme="dark"] .sidebar-new-folder {
    border-color: #4b5563;
    color: #9ca3af;
}

.sidebar-new-folder:hover {
    background: #f9fafb;
    border-color: #d1d5db;
    color: #4b5563;
}

[data-theme="dark"] .sidebar-new-folder:hover {
    background: rgba(51, 65, 85, 0.3);
    border-color: #6b7280;
    color: #d1d5db;
}

.sidebar-new-folder svg {
    width: 14px;
    height: 14px;
}

/* Collapsed state adjustments */
@media (min-width: 1024px) {
    .sidebar.collapsed .sidebar-folders-container {
        display: none;
    }
    
    /* In collapsed state, show folder icon in nav */
    .sidebar.collapsed .sidebar-link[href="/library"]::after {
        content: attr(data-folder-count);
        position: absolute;
        top: 0.25rem;
        right: 0.25rem;
        width: 16px;
        height: 16px;
        background: #6366f1;
        color: white;
        font-size: 0.5rem;
        font-weight: 700;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
    }
}

/* Folder colors (optional custom colors) */
.sidebar-folder-item[data-color="blue"] .folder-icon222 { color: #3B82F6; }
.sidebar-folder-item[data-color="green"] .folder-icon222 { color: #10B981; }
.sidebar-folder-item[data-color="purple"] .folder-icon222 { color: #8B5CF6; }
.sidebar-folder-item[data-color="red"] .folder-icon222 { color: #EF4444; }
.sidebar-folder-item[data-color="yellow"] .folder-icon222 { color: #F59E0B; }
.sidebar-folder-item[data-color="pink"] .folder-icon222 { color: #EC4899; }

/* Smart folder indicator */
.sidebar-folder-item.smart::before {
    content: '✨';
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    font-size: 0.625rem;
}

/* Pinned folder indicator */
.sidebar-folder-item.pinned {
    order: -1;
}

.sidebar-folder-item.pinned::after {
    content: '📌';
    position: absolute;
    top: 0.25rem;
    right: 0.25rem;
    font-size: 0.625rem;
    opacity: 0.5;
}

/* Loading state */
.sidebar-folders-list.loading {
    position: relative;
    min-height: 60px;
}

.sidebar-folders-list.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 20px;
    height: 20px;
    border: 2px solid #e5e7eb;
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .sidebar-folders-list.expanded {
        max-height: 300px;
    }
    
    .sidebar-folder-item {
        padding: 0.625rem 0.75rem;
    }
}