
/* Sidebar Components */

/* CRITICAL FIX: Force static icons for file status - override all CSS animations */
.document-status-indicator .icon,
.document-status-indicator i[class*="icon"] {
    animation: none !important;
    -webkit-animation: none !important;
    -moz-animation: none !important;
    -o-animation: none !important;
}

/* Ensure URL status indicators are also static */
.url-status-indicator .icon,
.url-status-indicator i[class*="icon"] {
    animation: none !important;
    -webkit-animation: none !important;
    -moz-animation: none !important;
    -o-animation: none !important;
}

/* Left Sidebar Column - CSS Grid Layout */
.left-sidebar {
    width: 280px;
    height: 100vh;
    height: 100dvh; /* Use dynamic viewport height for better mobile support */
    max-height: 100vh; /* Strictly enforce viewport height limit */
    background-color: var(--bg-primary);
    box-sizing: border-box;
    position: relative;
    
    /* Use CSS Grid for precise layout control - same as right-content */
    display: grid;
    grid-template-rows: 80px 1fr 140px; /* Fixed header, flexible content, larger fixed footer for desktop */
    grid-template-areas: 
        "sidebar-header"
        "sidebar-content" 
        "sidebar-footer";
    overflow: hidden;
}

/* Desktop: show sidebar by default */
@media (min-width: 769px) {
    .left-sidebar {
        position: relative;
        transform: translateX(0);
    }
}

/* Mobile: ensure sidebar is hidden by default and toggle button is visible */
@media (max-width: 768px) {
    .left-sidebar {
        position: fixed !important;
        top: 0 !important;
        left: -280px !important;
        z-index: 1000 !important;
        transition: left 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
        height: 100vh;
        height: 100svh; /* Use small viewport height on mobile */
        touch-action: manipulation;
        -webkit-overflow-scrolling: touch;
    }

    .left-sidebar.open {
        left: 0 !important;
    }

    .sidebar-toggle {
        display: block !important;
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* Improve touch targets on mobile */
    .folder-header,
    .document-item,
    .sidebar-add-btn,
    .logout-btn {
        min-height: 44px !important; /* iOS recommended touch target */
        touch-action: manipulation;
        -webkit-tap-highlight-color: transparent;
    }

    /* Prevent text selection during swipe gestures */
    .left-sidebar,
    .sidebar-overlay {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
    }
}

/* Mobile overlay */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    touch-action: manipulation;
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* GRID AREA 1: Sidebar Header (Add Content Button) */
.sidebar-header {
    grid-area: sidebar-header;
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background-color: var(--bg-primary);
    box-sizing: border-box;
    overflow: hidden;
}

.sidebar-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.header-buttons {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 100%;
    box-sizing: border-box;
}

.sidebar-close {
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: color 0.3s ease;
    display: none;
}

.sidebar-close:hover {
    color: var(--text-primary);
}

/* Add Content Button - More prominent while keeping Semantic UI style */
.sidebar-add-btn {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.5rem !important;
    width: 100% !important;
    box-sizing: border-box !important;
    padding: 0.75rem 1rem !important;
    font-size: 0.9rem !important;
    font-weight: 500 !important;
    border: 1px solid var(--accent-color) !important;
    background: var(--suggestion-bg) !important;
    color: var(--accent-color) !important;
    border-radius: 0.25rem !important;
    transition: all 0.3s ease !important;
    cursor: pointer !important;
    text-decoration: none !important;
    margin: 0 !important;
    flex-shrink: 0 !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1) !important;
}

.sidebar-add-btn:hover {
    background: var(--accent-color) !important;
    color: white !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15) !important;
    transform: translateY(-1px) !important;
}

/* Hide close button on all screens */
@media (max-width: 768px) {
    .sidebar-close {
        display: none !important;
    }
}

/* Hide close button in header buttons on desktop */
@media (min-width: 769px) {
    #sidebarCloseBtn {
        display: none !important;
    }
}

/* GRID AREA 2: Sidebar Content (Scrollable Folders/Files) */
.sidebar-content {
    grid-area: sidebar-content;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    box-sizing: border-box;
    
    /* Grid will automatically size this to fill available space */
    min-height: 0; /* Allow grid item to shrink */
    
    /* Custom scrollbar styling */
    scrollbar-width: thin;
    scrollbar-color: var(--border-color) transparent;
}

/* Custom scrollbar for webkit browsers */
.sidebar-content::-webkit-scrollbar {
    width: 6px;
}

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

.sidebar-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

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

.folder-section, .document-section {
    margin-bottom: 2rem;
}

/* Folder and Document Items */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.section-header h4 {
    margin: 0;
    color: var(--text-primary);
    font-size: 0.9rem;
    font-weight: 600;
}

.folder-list {
    /* No height restrictions needed with grid layout */
}

.folder-item {
    border-radius: 4px;
    margin-bottom: 0.25rem;
    cursor: pointer;
    transition: background-color 0.3s ease;
    border: 1px solid transparent;
}

.folder-header {
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: var(--suggestion-bg);
    border-radius: 4px;
    border: 1px solid var(--suggestion-border);
}

.folder-header:hover {
    background-color: var(--suggestion-hover);
}

.folder-header.active {
    background-color: var(--suggestion-hover);
    color: var(--text-primary);
    border: 0px;
    box-shadow: inset 2px 0 0 var(--accent-color);
}

.folder-header i {
    margin-right: 0.5rem;
    color: var(--text-secondary);
}

.folder-header.active i {
    color: white;
}

.private-menu {
    font-size: 0.65em !important;
    margin-left: 0.5em !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
}

.private-menu:hover {
    transform: scale(1.1) !important;
}

.folder-documents {
    padding-left: 1rem;
    margin-top: 0.25rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.folder-documents.open {
    max-height: 500px;
}

.document-item {
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.2rem;
    cursor: pointer;
    transition: background-color 0.3s ease;
    border: 1px solid transparent;
    font-size: 0.9rem;
}

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

.document-item.active {
    background-color: var(--suggestion-hover);
    color: var(--text-primary);
}

.document-item i {
    margin-right: 0.5rem;
    color: var(--text-secondary);
}

.document-item.active i {
    color: var(--text-secondary);
}

.loading-item {
    padding: 1rem;
    text-align: center;
    color: var(--text-secondary);
}

/* Auth buttons container for non-authenticated users */
.auth-buttons-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 1rem;
    padding: 2rem 1rem;
}

.auth-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    width: 100%;
    max-width: 200px;
    border: 1px solid var(--border-color);
}

.auth-button.google-auth {
    background: #4285f4;
    color: white;
    border-color: #4285f4;
    font-weight: 600;
}

.auth-button.google-auth:hover {
    background: #3367d6;
    border-color: #3367d6;
    color: white;
}

.auth-button.email-auth {
    background: transparent;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.auth-button.email-auth:hover {
    background: var(--suggestion-hover);
    color: var(--text-primary);
}

.auth-button.signup {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.auth-button.signup:hover {
    background: var(--link-hover);
    border-color: var(--link-hover);
}

.auth-button.login {
    background: transparent;
    color: var(--text-primary);
}

.auth-button.login:hover {
    background: var(--suggestion-hover);
}

/* GRID AREA 3: Sidebar Footer (Bottom buttons) */
.sidebar-footer {
    grid-area: sidebar-footer;
    padding: 0.75rem;
    background-color: var(--bg-primary);
    box-sizing: border-box;
    
    /* Ensure footer is always visible and never shrinks */
    overflow: visible;
    
    /* Use flex to arrange footer content */
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: stretch;
    gap: 0.5rem;
    
    /* Ensure minimum height for content - matches grid template */
    min-height: 140px;
    max-height: 140px;
}

/* Mobile adjustments for sidebar */
@media (max-width: 768px) {
    .left-sidebar {
        grid-template-rows: 70px 1fr 110px; /* Ensure footer has enough space on mobile */
        max-height: 100vh;
        max-height: 100svh;
    }
    
    .sidebar-footer {
        padding: 0.5rem;
        min-height: 110px; /* Ensure minimum height on mobile */
    }
    
    .user-email {
        font-size: 0.65rem;
        padding: 0.2rem;
        margin-bottom: 0.2rem;
    }
    
    .logout-btn {
        font-size: 0.65rem;
        padding: 0.25rem;
    }
}

.user-info {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    justify-content: flex-start;
    align-items: stretch;
    flex: 1;
}

.user-email {
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 500;
    text-align: center;
    word-break: break-word;
    display: block;
    padding: 0.25rem;
    border-radius: 0.25rem;
    margin-bottom: 0.1rem;
    flex-shrink: 0;
}

.user-email:hover {
    background: var(--suggestion-hover);
    color: var(--text-primary);
}

.logout-btn {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    padding: 0.5rem;
    background: transparent;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    transition: all 0.3s ease;
    border: 1px solid var(--border-color);
    flex-shrink: 0;
    min-height: 36px; /* Ensure minimum clickable area */
    width: 100%;
    box-sizing: border-box;
}

.logout-btn:hover {
    background: var(--suggestion-hover);
    color: var(--text-primary);
}

/* Subscription status badges */
.subscription-badge {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-left: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.subscription-badge.free {
    background: #6c757d;
    color: white;
}

.subscription-badge.plus {
    background: #10b981;
    color: white;
}

.upgrade-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0.8rem;
    background: #10b981;
    color: white;
    text-decoration: none;
    border-radius: 0.4rem;
    font-size: 0.75rem;
    font-weight: 600;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
    margin-bottom: 0.4rem;
    width: 100%;
    flex-shrink: 0;
    min-height: 28px;
}

.upgrade-btn:hover {
    background: #059669;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

/* New Item Button */
.new-item-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.6rem 0.9rem;
    background: var(--suggestion-bg);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    min-width: 90px;
}

.new-item-button:hover {
    background: var(--suggestion-hover);
    border-color: var(--accent-color);
    transform: translateY(-0.5px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.new-item-button i {
    font-size: 1.1rem;
}

/* New Item Menu */
.new-item-menu {
    min-width: 180px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
    padding: 0.5rem 0;
    z-index: 10001;
}

.new-item-menu .context-menu-item {
    padding: 12px 16px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    color: var(--text-primary);
    transition: background-color 0.2s ease;
}

.new-item-menu .context-menu-item:hover {
    background-color: var(--suggestion-hover);
}

.new-item-menu .context-menu-item i {
    width: 18px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 1rem;
}

.new-item-menu .context-menu-separator {
    height: 1px;
    background: var(--border-color);
    margin: 0.25rem 0;
}
