/* Sidebar Container */
/* Sidebar Container */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 260px;
    /* Locked at 260px on desktop */
    background: #1e293b;
    /* Slate 800 fallback */
    background: rgba(30, 41, 59, 0.98);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    transition: width 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1000;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.1);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    overflow: hidden;
    /* Prevent global scroll */
    display: flex;
    flex-direction: column;
}

/* Logo Area */
.sidebar-logo {
    height: 72px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    margin-bottom: 8px;
    overflow: hidden;
    white-space: nowrap;
    text-decoration: none;
    flex-shrink: 0;
    /* Sticky Header */
}

.sidebar-logo svg {
    min-width: 32px;
    transition: transform 0.3s ease;
}

.sidebar:hover .sidebar-logo svg,
.sidebar.locked .sidebar-logo svg {
    transform: scale(1.1);
}

.sidebar-logo-text {
    margin-left: 16px;
    font-size: 1.25rem;
    color: white;
    opacity: 1;
    max-width: 200px;
    overflow: hidden;
    transform: translateX(0);
    transition: all 0.3s ease;
}

/* Navigation Items */
.sidebar-nav {
    flex: 1;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow-y: auto;
    /* Scrollable Nav */
    overflow-x: hidden;
}

.sidebar-item {
    display: flex;
    align-items: center;
    height: 48px;
    padding: 0 11px;
    /* 11px + 1px border = 12px. 12px + 24px icon + 12px = 48px (available width) */
    border: 1px solid transparent;
    /* Ensure consistent alignment */
    border-radius: var(--radius-default);
    color: rgba(255, 255, 255, 0.6);
    text-decoration: none;
    transition: all 0.2s ease;
    cursor: pointer;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.sidebar-item.hidden {
    display: none !important;
}

.sidebar-item:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
}

.sidebar-item.active {
    background: rgba(196, 43, 140, 0.15);
    color: var(--accent-primary);
}

.sidebar-icon {
    font-size: 24px;
    min-width: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color 0.2s ease;
}

.sidebar-label {
    margin-left: 16px;
    font-size: 0.95rem;
    font-weight: 500;
    opacity: 1;
    max-width: 200px;
    overflow: hidden;
    transform: translateX(0);
    transition: all 0.3s ease;
    pointer-events: auto;
    white-space: nowrap;
}

.sidebar-status-pill {
    margin-left: auto;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.05em;
    background: rgba(255, 255, 255, 0.1);
    color: rgba(255, 255, 255, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-status-pill.guest {
    background: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
    /* Slate 400 */
}

.sidebar-status-pill.lite {
    background: rgba(56, 189, 248, 0.15);
    color: #38bdf8;
    /* Sky 400 */
}

.sidebar-status-pill.family {
    background: rgba(192, 132, 252, 0.15);
    color: #c084fc;
    /* Purple 400 */
}

.sidebar-status-pill.pro {
    background: rgba(244, 114, 182, 0.15);
    color: #f472b6;
    /* Pink 400 */
}

/* Space Selector Special Styling */
.space-selector {
    margin-bottom: 16px;
    background: rgba(255, 255, 255, 0.05);
    border-color: rgba(255, 255, 255, 0.05);
    /* Match spacing of .space-item but with room for chevron */
    padding: 10px 36px 10px 12px !important;
    height: auto !important;
    /* Override fixed height from .sidebar-item */
    min-height: 48px;
    /* Ensure at least standard size */
    align-items: flex-start;
    /* Allow multi-line text to wrap naturally if needed */
}

.space-selector:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.1);
}

.space-selector .sidebar-label {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
    overflow: hidden;
}

.space-name {
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.space-info {
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
}

.space-selector .chevron {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar:hover .space-selector .chevron,
.sidebar.open .space-selector .chevron,
.sidebar.locked .space-selector .chevron {
    opacity: 1;
}

/* Divider */
.sidebar-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.1);
    margin: 8px 24px;
}

/* Bottom Actions */
.sidebar-footer {
    padding: 12px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

/* Mobile Responsiveness */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        height: 100vh;
        transform: translateX(-100%);
        width: 280px;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-label {
        opacity: 1;
        transform: none;
    }

    .sidebar-logo-text {
        opacity: 1;
        transform: none;
    }

    .main-with-sidebar {
        margin-left: 0 !important;
    }
}

/* Main Content Adjustment */
.main-with-sidebar {
    margin-left: 260px;
    /* Match locked sidebar width */
    transition: margin-left 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Dropdown Styling */
#spaceDropdown {
    background: #1e293b;
    background: rgba(30, 41, 59, 0.95);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    border-radius: var(--radius-default);
    padding: 8px;
    color: white;
    z-index: 1100;
    /* Position will be handled by JS or fixed fallback */
}

.space-item {
    border-radius: var(--radius-default);
    color: rgba(255, 255, 255, 0.7);
    transition: all 0.2s;
    padding: 10px 12px;
    margin-bottom: 2px;
}

.space-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.space-item.active {
    background: var(--accent-primary);
    color: white;
}

.space-item .font-semibold {
    color: inherit;
}

.space-item .text-sm {
    color: rgba(255, 255, 255, 0.5);
}

.space-item:hover .text-sm {
    color: rgba(255, 255, 255, 0.7);
}

.space-item.active .text-sm {
    color: rgba(255, 255, 255, 0.8);
}

/* Mobile Header & Overlay Shared Styles */
.mobile-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    backdrop-filter: blur(4px);
}

.mobile-overlay.active {
    display: block;
}

.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: 72px;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    z-index: 50;
    padding: 0 16px;
    /* Align with standard px-4 (16px) container padding */
    border-bottom: 1px solid var(--border-light);
}

#mobileSidebarToggle {
    background: none;
    border: none;
    color: var(--accent-primary);
    cursor: pointer;
    padding: 8px;
    margin-left: -8px;
    /* Offset button padding to align icon visually with 16px edge */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s;
    line-height: 0;
}

#mobileSidebarToggle .material-icons {
    font-size: 32px;
}

#mobileSidebarToggle:active {
    transform: scale(0.9);
}

.mobile-header h1 {
    font-size: 1.6rem;
    color: var(--accent-primary);
    margin: 0;
    line-height: 1;
}

@media (max-width: 768px) {
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .main-with-sidebar {
        padding-top: 86px;
    }

    #folderHeader {
        top: 72px !important;
    }
}

/* Inline Spaces List (Accordion) */
.sidebar-space-list {
    flex: 0 0 auto;
    overflow-y: hidden;
    max-height: 0;
    transition: max-height 0.3s ease-in-out;
    padding: 0;
    background: rgba(255, 255, 255, 0.03);
    /* Slightly lighter/distinct background */
    border-radius: var(--radius-default);
    /* Optional: round the container block slightly */
    margin: 0 8px 8px 8px;
}

.sidebar-space-list:not(.hidden) {
    max-height: 200px !important;
    /* Fixed exposed height as requested */
    overflow-y: auto !important;
    padding: 4px 0;
    /* Minimal padding inside list */
}

/* Custom Scrollbar for the accordion list */
.sidebar-space-list::-webkit-scrollbar {
    width: 4px;
}

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

.sidebar-space-list::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 0;
}

/* Adjust hidden utility if needed, but using max-height for accordion effect is smoother. 
   However, our JS toggles 'hidden' class which sets display:none. 
   To support smooth transition, we might need JS to toggle a height class instead.
   For now, strictly following "hidden" class usage from JS: */
.sidebar-space-list.hidden {
    display: none;
}

/* Space Item Styling in Sidebar - Identical to Selector */
.space-item {
    display: flex;
    align-items: center;
    /* Vertical center */
    min-height: 48px;
    padding: 10px 12px;
    /* Identical padding to selector base */
    margin: 0;
    border-radius: var(--radius-default);
    color: rgba(255, 255, 255, 0.6);
    transition: all 0.2s;
    background: transparent;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.space-item:hover {
    background: rgba(255, 255, 255, 0.08);
    /* Match selector hover if possible, or distinct */
    color: #fff;
}

.space-item.active {
    background: rgba(196, 43, 140, 0.15);
    color: var(--accent-primary);
}

.space-item .sidebar-label-content {
    /* Wrapper for text content if needed to match layout */
    display: flex;
    flex-direction: column;
    justify-content: center;
    line-height: 1.2;
}

.space-item .font-semibold {
    font-size: 0.95rem;
    /* Match space-name */
    font-weight: 500;
    color: inherit;
    line-height: 1.3;
}

.space-item .text-sm {
    font-size: 0.75rem;
    /* Match space-info */
    color: rgba(255, 255, 255, 0.5);
    line-height: 1.2;
}