/* History Sidebar - Desktop Styles (Right Side Mirror of Left Unified Sidebar)
 * Mirrors the exact structure and functionality of unified sidebar
 * Only visible on desktop (min-width: 769px)
 */

/* History Sidebar Toggle Button */
.history-sidebar-toggle-btn {
    position: fixed !important;
    top: 50% !important;
    right: 0 !important;
    transform: translateY(-50%) !important;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
    color: white !important;
    border: none !important;
    border-radius: 8px 0 0 8px !important;
    padding: 12px 8px !important;
    font-size: 1.1rem !important;
    cursor: pointer !important;
    box-shadow: -2px 0 8px rgba(102, 126, 234, 0.3) !important;
    transition: all 0.3s ease !important;
    z-index: 1040 !important;
    width: 48px !important;
    height: 48px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

@media (max-width: 768px) {
    .history-sidebar-toggle-btn {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .history-sidebar-toggle-btn {
        display: flex !important;
    }
}

.history-sidebar-toggle-btn:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%) !important;
    box-shadow: -4px 0 12px rgba(102, 126, 234, 0.4) !important;
    transform: translateY(-50%) translateX(-2px) !important;
}

.history-sidebar-toggle-btn.active {
    transform: translateY(-50%) translateX(-280px) !important;
    border-radius: 8px !important;
}

/* History Sidebar Overlay */
.history-sidebar-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    background: rgba(0, 0, 0, 0.5) !important;
    z-index: 1030 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    transition: all 0.3s ease !important;
}

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

.history-sidebar-overlay.active {
    opacity: 1 !important;
    visibility: visible !important;
}

@media (min-width: 769px) {
    
    /* CSS Variables for Consistency */
    :root {
        --history-sidebar-mini-width: 60px;
        --history-sidebar-expanded-width: 280px;
        --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    }

    /* History Sidebar Container (Right Side) */
    .history-sidebar-container {
        position: fixed !important;
        top: 0 !important;
        right: 0 !important;
        height: 100vh !important;
        width: var(--history-sidebar-mini-width) !important;
        background: white !important;
        border-left: 1px solid #e2e8f0 !important;
        box-shadow: -2px 0 10px rgba(0,0,0,0.1) !important;
        z-index: 1050 !important;
        transition: width 0.3s ease !important;
        overflow: hidden !important;
        display: flex !important;
        flex-direction: column !important;
    }

    .history-sidebar-container:hover,
    .history-sidebar-container.expanded,
    .history-sidebar-container.open {
        width: var(--history-sidebar-expanded-width) !important;
    }

    .history-sidebar-container.open {
        box-shadow: -4px 0 15px rgba(0,0,0,0.15) !important;
    }

    /* History Sidebar Header */
    .history-sidebar-header {
        padding: 0.75rem !important;
        border-bottom: 1px solid #e2e8f0 !important;
        background: var(--primary-gradient) !important;
        color: white !important;
        min-height: 60px !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        position: relative !important;
    }

    .history-sidebar-logo {
        width: 28px !important;
        height: 28px !important;
        margin-bottom: 0.5rem !important;
        display: block !important;
        filter: brightness(0) invert(1) !important;
        transition: filter 0.3s ease !important;
    }

    .history-sidebar-header:hover .history-sidebar-logo {
        filter: brightness(0) invert(1) !important;
    }

    .history-sidebar-title {
        font-size: 0.9rem !important;
        font-weight: 600 !important;
        text-align: center !important;
        opacity: 0 !important;
        transition: opacity 0.3s ease !important;
        white-space: nowrap !important;
    }

    .history-sidebar-container:hover .history-sidebar-title,
    .history-sidebar-container.expanded .history-sidebar-title,
    .history-sidebar-container.open .history-sidebar-title {
        opacity: 1 !important;
    }

    /* History Sidebar Toggle Button */
    .history-sidebar-toggle {
        position: absolute !important;
        top: 20px !important;
        right: 20px !important;
        width: 20px !important;
        height: 20px !important;
        background: none !important;
        border: none !important;
        color: white !important;
        cursor: pointer !important;
        opacity: 0 !important;
        transition: opacity 0.3s ease !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        font-size: 0.8rem !important;
    }

    .history-sidebar-container:hover .history-sidebar-toggle,
    .history-sidebar-container.expanded .history-sidebar-toggle,
    .history-sidebar-container.open .history-sidebar-toggle {
        opacity: 1 !important;
    }

    .history-sidebar-toggle:hover {
        color: rgba(255,255,255,0.8) !important;
    }

    /* History Sidebar Content */
    .history-sidebar-content {
        flex: 1 !important;
        overflow-y: auto !important;
        padding: 0 !important;
    }

    /* History Sidebar Navigation */
    .history-sidebar-nav {
        display: flex !important;
        flex-direction: column !important;
        gap: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* History Sidebar Links */
    .history-sidebar-link {
        display: flex !important;
        align-items: center !important;
        padding: 0.75rem 1rem !important;
        text-decoration: none !important;
        color: #64748b !important;
        transition: all 0.2s ease !important;
        border: none !important;
        background: none !important;
        cursor: pointer !important;
        position: relative !important;
        min-height: 48px !important;
        gap: 0.75rem !important;
    }

    .history-sidebar-link:hover {
        background: #f1f5f9 !important;
        color: #475569 !important;
        text-decoration: none !important;
    }

    /* Prevent any pseudo-elements from creating black boxes on hover */
    .history-sidebar-link:hover::before,
    .history-sidebar-link:hover::after {
        background: none !important;
        box-shadow: none !important;
        content: none !important;
        display: none !important;
    }

    /* Override any conflicting tooltip styles when expanded */
    .history-sidebar-container:hover .history-sidebar-link::before,
    .history-sidebar-container:hover .history-sidebar-link::after,
    .history-sidebar-container.expanded .history-sidebar-link::before,
    .history-sidebar-container.expanded .history-sidebar-link::after {
        content: none !important;
        display: none !important;
        background: none !important;
        border: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
    }

    .history-sidebar-link.active {
        background: #e2e8f0 !important;
        color: #334155 !important;
        border-right: 3px solid #667eea !important;
    }

    .history-sidebar-link i {
        width: 20px !important;
        text-align: center !important;
        font-size: 1.1rem !important;
        flex-shrink: 0 !important;
        color: #64748b !important;
        transition: color 0.2s ease !important;
    }

    .history-sidebar-link:hover i {
        color: #475569 !important;
    }

    .history-sidebar-link.active i {
        color: #334155 !important;
    }

    .history-sidebar-link-danger i {
        color: #dc2626 !important;
    }

    .history-sidebar-link-danger:hover i {
        color: #b91c1c !important;
    }

    /* New Chat Button - Desktop */
    .new-chat-button {
        display: flex !important;
        align-items: center !important;
        justify-content: flex-start !important;
        width: 100% !important;
        padding: 0.75rem 1rem !important;
        background: transparent !important;
        color: #64748b !important;
        border: none !important;
        border-radius: 8px !important;
        margin: 0 !important;
        font-size: 0.875rem !important;
        font-weight: 500 !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        gap: 0.75rem !important;
        text-align: left !important;
    }

    .new-chat-button:hover {
        background: #f8fafc !important;
        color: #475569 !important;
        border-right: 3px solid #667eea !important;
    }

    .new-chat-button:active {
        background: #f1f5f9 !important;
        color: #334155 !important;
    }

    .new-chat-button i {
        width: 20px !important;
        text-align: center !important;
        font-size: 1.1rem !important;
        flex-shrink: 0 !important;
        color: #64748b !important;
        transition: color 0.2s ease !important;
    }

    .new-chat-button:hover i {
        color: #475569 !important;
    }

    /* Chevron icons for dropdowns */
    .history-sidebar-chevron {
        margin-left: auto !important;
        font-size: 0.875rem !important;
        transition: transform 0.2s ease, color 0.2s ease !important;
        color: #94a3b8 !important;
    }

    .history-sidebar-chevron.rotated {
        transform: rotate(180deg) !important;
        color: #667eea !important;
    }

    .history-sidebar-link.expanded .history-sidebar-chevron {
        transform: rotate(180deg) !important;
        color: #667eea !important;
    }

    /* Conversation Item Styling */
    .conversation-item {
        display: flex !important;
        align-items: center !important;
        padding: 0.75rem 1rem !important;
        border-bottom: 1px solid #e2e8f0 !important;
        cursor: pointer !important;
        transition: all 0.2s ease !important;
        background: #ffffff !important;
    }

    .conversation-item:hover {
        background: #f8fafc !important;
    }

    .conversation-content {
        flex: 1 !important;
        min-width: 0 !important;
    }

    .conversation-item-title {
        font-size: 0.875rem !important;
        font-weight: 500 !important;
        color: #1e293b !important;
        margin-bottom: 0.25rem !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    .conversation-item-meta {
        font-size: 0.75rem !important;
        color: #64748b !important;
        display: flex !important;
        gap: 0.5rem !important;
        align-items: center !important;
        flex-wrap: wrap !important;
    }

    .conversation-actions {
        display: flex !important;
        align-items: center !important;
        gap: 0.5rem !important;
    }

    .delete-conversation-btn {
        background: none !important;
        border: none !important;
        color: #94a3b8 !important;
        font-size: 0.875rem !important;
        padding: 0.25rem !important;
        cursor: pointer !important;
        border-radius: 0.25rem !important;
        transition: all 0.2s ease !important;
        opacity: 0 !important;
        transform: scale(0.9) !important;
    }

    .conversation-item:hover .delete-conversation-btn {
        opacity: 1 !important;
        transform: scale(1) !important;
    }

    .delete-conversation-btn:hover {
        background: #fee2e2 !important;
        color: #dc2626 !important;
    }

    .delete-conversation-btn:active {
        background: #fecaca !important;
        transform: scale(0.95) !important;
    }

    /* Dropdown content */
    .history-sidebar-dropdown {
        max-height: 0 !important;
        overflow: hidden !important;
        transition: max-height 0.3s ease !important;
        background: #f8fafc !important;
        border-left: 3px solid #e2e8f0 !important;
        margin-left: 1rem !important;
        display: block !important;
        opacity: 0 !important;
        transition: max-height 0.3s ease, opacity 0.3s ease !important;
    }

    .history-sidebar-dropdown.show {
        max-height: 400px !important;
        opacity: 1 !important;
    }

    /* Conversations Scroll Container - ChatGPT Style */
    .conversations-scroll-container {
        max-height: 380px !important;
        overflow-y: auto !important;
        padding: 0.5rem 0 !important;
        /* Lighter scrollbar for conversations container */
        scrollbar-width: thin !important;
        scrollbar-color: rgba(148, 163, 184, 0.4) transparent !important;
    }

    /* Webkit scrollbar styling for conversations (lighter than main page) */
    .conversations-scroll-container::-webkit-scrollbar {
        width: 6px !important;
    }

    .conversations-scroll-container::-webkit-scrollbar-track {
        background: rgba(248, 250, 252, 0.5) !important;
        border-radius: 3px !important;
    }

    .conversations-scroll-container::-webkit-scrollbar-thumb {
        background: rgba(148, 163, 184, 0.4) !important;
        border-radius: 3px !important;
        transition: background 0.2s ease !important;
    }

    .conversations-scroll-container::-webkit-scrollbar-thumb:hover {
        background: rgba(148, 163, 184, 0.6) !important;
    }

    .dropdown-content,
    .dropdown-loading {
        padding: 0.75rem 1rem !important;
        font-size: 0.875rem !important;
        color: #64748b !important;
    }

    .conversation-item {
        padding: 0.5rem 1rem !important;
        margin: 0.25rem 0 !important;
        background: white !important;
        border-radius: 0.375rem !important;
        cursor: pointer !important;
        transition: background 0.2s ease !important;
        border-left: 3px solid transparent !important;
    }

    .conversation-item:hover {
        background: #f1f5f9 !important;
        border-left-color: #667eea !important;
    }

    .conversation-item-title {
        font-weight: 600 !important;
        color: #334155 !important;
        font-size: 0.875rem !important;
        margin-bottom: 0.25rem !important;
    }

    .conversation-item-meta {
        font-size: 0.75rem !important;
        color: #94a3b8 !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 0.125rem !important;
    }

    .conversation-date {
        color: #667eea !important;
        font-weight: 500 !important;
    }

    .conversation-count {
        color: #64748b !important;
    }

    .conversation-ai-model {
        color: #94a3b8 !important;
        font-style: italic !important;
        font-size: 0.6875rem !important;
    }

    /* Section wrapper for dropdown functionality */
    .history-sidebar-section {
        margin-bottom: 0.25rem !important;
    }

    .history-sidebar-link-text {
        opacity: 0 !important;
        transition: opacity 0.3s ease !important;
        white-space: nowrap !important;
        font-weight: 500 !important;
        font-size: 0.875rem !important;
    }

    .history-sidebar-container:hover .history-sidebar-link-text,
    .history-sidebar-container.expanded .history-sidebar-link-text,
    .history-sidebar-container.open .history-sidebar-link-text {
        opacity: 1 !important;
    }

    /* Danger Link (Clear History) */
    .history-sidebar-link-danger {
        color: #dc2626 !important;
    }

    .history-sidebar-link-danger:hover {
        background: #fee2e2 !important;
        color: #b91c1c !important;
    }

    /* Tooltips for Mini Mode - Fixed to prevent black boxes */
    .history-sidebar-link[data-tooltip]:before {
        content: attr(data-tooltip) !important;
        position: absolute !important;
        left: -10px !important;
        top: 50% !important;
        transform: translateX(-100%) translateY(-50%) !important;
        background: #1f2937 !important;
        color: white !important;
        padding: 0.5rem 0.75rem !important;
        border-radius: 0.375rem !important;
        font-size: 0.75rem !important;
        font-weight: 500 !important;
        white-space: nowrap !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        transition: opacity 0.2s ease, visibility 0.2s ease !important;
        z-index: 1000 !important;
        box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
    }

    .history-sidebar-link[data-tooltip]:after {
        content: '' !important;
        position: absolute !important;
        left: -2px !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
        border: 6px solid transparent !important;
        border-left-color: #1f2937 !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
        transition: opacity 0.2s ease, visibility 0.2s ease !important;
        z-index: 1000 !important;
    }

    /* Show tooltips only in mini mode on hover */
    .history-sidebar-container:not(:hover):not(.expanded) .history-sidebar-link:hover[data-tooltip]:before,
    .history-sidebar-container:not(:hover):not(.expanded) .history-sidebar-link:hover[data-tooltip]:after {
        opacity: 1 !important;
        visibility: visible !important;
    }

    /* Ensure tooltips are completely hidden when expanded or when sidebar is hovered */
    .history-sidebar-container:hover .history-sidebar-link[data-tooltip]:before,
    .history-sidebar-container:hover .history-sidebar-link[data-tooltip]:after,
    .history-sidebar-container.expanded .history-sidebar-link[data-tooltip]:before,
    .history-sidebar-container.expanded .history-sidebar-link[data-tooltip]:after {
        opacity: 0 !important;
        visibility: hidden !important;
        display: none !important;
    }

    /* Hover trigger area for expanding mini sidebar */
    .history-mini-trigger {
        position: absolute !important;
        top: 0 !important;
        left: -10px !important;
        width: 10px !important;
        height: 100% !important;
        background: transparent !important;
        z-index: 1049 !important;
    }

    /* Hide mobile history sidebar on desktop */
    .mobile-history-sidebar,
    .mobile-history-overlay {
        display: none !important;
    }

}

    /* Desktop History Dropdown */
    .desktop-history-dropdown {
        position: absolute !important;
        top: 60px !important;
        right: 0 !important;
        width: 350px !important;
        max-height: 500px !important;
        background: white !important;
        border-radius: 12px !important;
        box-shadow: 0 10px 30px rgba(0,0,0,0.2) !important;
        opacity: 0 !important;
        visibility: hidden !important;
        transform: translateY(-10px) !important;
        transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) !important;
        overflow: hidden !important;
        z-index: 1060 !important;
    }

    .desktop-history-dropdown.active {
        opacity: 1 !important;
        visibility: visible !important;
        transform: translateY(0) !important;
    }

    /* Desktop History Header */
    .desktop-history-header {
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
        color: white !important;
        padding: 1rem !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    .desktop-history-title {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        font-weight: 600 !important;
        font-size: 1rem !important;
    }

    .desktop-history-close {
        background: none !important;
        border: none !important;
        color: white !important;
        font-size: 1.2rem !important;
        cursor: pointer !important;
        padding: 4px !important;
        border-radius: 4px !important;
        transition: background-color 0.2s ease !important;
    }

    .desktop-history-close:hover {
        background: rgba(255,255,255,0.2) !important;
    }

    /* Desktop History Content */
    .desktop-history-content {
        max-height: 400px !important;
        overflow-y: auto !important;
        padding: 0 !important;
    }

    /* Desktop History Sections */
    .desktop-history-section {
        border-bottom: 1px solid #f1f5f9 !important;
    }

    .desktop-history-section:last-child {
        border-bottom: none !important;
    }

    .desktop-history-section-header {
        padding: 1rem !important;
        background: #f8fafc !important;
        cursor: pointer !important;
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        font-weight: 500 !important;
        color: #374151 !important;
        transition: background-color 0.2s ease !important;
    }

    .desktop-history-section-header:hover {
        background: #e2e8f0 !important;
    }

    .desktop-history-section-header i {
        transition: transform 0.3s ease !important;
        color: #6b7280 !important;
    }

    .desktop-history-section-header.active i {
        transform: rotate(180deg) !important;
    }

    /* Desktop History Section Dropdown */
    .desktop-history-section-dropdown {
        background: white !important;
        border-top: 1px solid #e2e8f0 !important;
        max-height: 200px !important;
        overflow-y: auto !important;
    }

    .dropdown-content {
        padding: 1rem !important;
        color: #6b7280 !important;
        font-style: italic !important;
        text-align: center !important;
    }

    .dropdown-loading {
        padding: 1rem !important;
        color: #6b7280 !important;
        text-align: center !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 8px !important;
    }

    /* Conversation Items */
    .conversation-item-desktop {
        padding: 0.75rem 1rem !important;
        border-bottom: 1px solid #f1f5f9 !important;
        cursor: pointer !important;
        transition: background-color 0.2s ease !important;
    }

    .conversation-item-desktop:hover {
        background: #f8fafc !important;
    }

    .conversation-item-desktop:last-child {
        border-bottom: none !important;
    }

    .conversation-title {
        font-weight: 500 !important;
        color: #374151 !important;
        margin-bottom: 4px !important;
        font-size: 0.9rem !important;
    }

    .conversation-preview {
        color: #6b7280 !important;
        font-size: 0.8rem !important;
        margin-bottom: 4px !important;
        line-height: 1.3 !important;
    }

    .conversation-meta {
        display: flex !important;
        justify-content: space-between !important;
        color: #9ca3af !important;
        font-size: 0.7rem !important;
    }

    /* Desktop History Overlay */
    .desktop-history-overlay {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        background: transparent !important;
        z-index: 1059 !important;
        opacity: 0 !important;
        visibility: hidden !important;
        transition: all 0.3s ease !important;
    }

    .desktop-history-overlay.active {
        opacity: 1 !important;
        visibility: visible !important;
    }

    /* Hide mobile history sidebar on desktop */
    .mobile-history-sidebar,
    .mobile-history-overlay {
        display: none !important;
    }

}

/* History Sidebar Header */
.history-sidebar-header {
    padding: 1rem !important;
    border-bottom: 1px solid #e2e8f0 !important;
    background: var(--primary-gradient) !important;
    color: white !important;
    min-height: 80px !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
}

.history-sidebar-logo {
    width: 28px !important;
    height: 28px !important;
    margin: 0 auto 0.5rem auto !important;
    display: block !important;
}

.history-sidebar-title {
    font-size: 0.9rem !important;
    font-weight: 600 !important;
    text-align: center !important;
    opacity: 0 !important;
    transition: opacity 0.3s ease !important;
}

.history-sidebar-container.expanded .history-sidebar-title {
    opacity: 1 !important;
}

/* History Sidebar Toggle Button */
.history-sidebar-toggle {
    position: absolute !important;
    top: 20px !important;
    right: 20px !important;
    width: 20px !important;
    height: 20px !important;
    background: none !important;
    border: none !important;
    color: white !important;
    cursor: pointer !important;
    font-size: 12px !important;
    z-index: 1051 !important;
    opacity: 0 !important;
    transition: opacity 0.3s ease !important;
}

.history-sidebar-container.expanded .history-sidebar-toggle {
    opacity: 1 !important;
}

/* History Sidebar Content */
.history-sidebar-content {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 0 !important;
}

/* History Sidebar Navigation */
.history-sidebar-nav {
    list-style: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* History Sidebar Links */
.history-sidebar-link {
    display: flex !important;
    align-items: center !important;
    padding: 0.875rem 1rem !important;
    color: #64748b !important;
    text-decoration: none !important;
    border-left: 3px solid transparent !important;
    transition: all 0.2s ease !important;
    cursor: pointer !important;
    margin-bottom: 2px !important;
    position: relative !important;
}

.history-sidebar-link:hover {
    background: #f8fafc !important;
    color: #667eea !important;
    text-decoration: none !important;
    border-left-color: #667eea !important;
}

.history-sidebar-link.active {
    background: #f1f5f9 !important;
    color: #667eea !important;
    border-left-color: #667eea !important;
}

.history-sidebar-link i {
    margin-right: 0.75rem !important;
    width: 20px !important;
    font-size: 1rem !important;
    text-align: center !important;
    flex-shrink: 0 !important;
    color: #64748b !important; /* Match left sidebar icon color */
}

.history-sidebar-link:hover i {
    color: #667eea !important; /* Match left sidebar hover color */
}

.history-sidebar-link.active i {
    color: #667eea !important; /* Match left sidebar active color */
}

.history-sidebar-link-text {
    opacity: 0 !important;
    transition: opacity 0.3s ease !important;
    white-space: nowrap !important;
}

.history-sidebar-container.expanded .history-sidebar-link-text {
    opacity: 1 !important;
}

/* History Mini Sidebar Trigger Area and Click-to-Expand */
.history-mini-trigger {
    position: absolute !important;
    left: -10px !important;
    top: 0 !important;
    width: 10px !important;
    height: 100vh !important;
    cursor: pointer !important;
    z-index: 1049 !important;
}

/* Make entire mini sidebar clickable */
.history-sidebar-container:not(.expanded) {
    cursor: pointer !important;
}

/* Hover indicator for mini sidebar */
.history-sidebar-container:not(.expanded):hover {
    background: #f8fafc !important;
    box-shadow: -4px 0 15px rgba(0,0,0,0.15) !important;
}

/* Tooltip for mini sidebar */
.history-sidebar-link::after {
    content: attr(data-tooltip) !important;
    position: absolute !important;
    right: 100% !important;
    top: 50% !important;
    transform: translateY(-50%) !important;
    background: #1e293b !important;
    color: white !important;
    padding: 0.5rem 0.75rem !important;
    border-radius: 6px !important;
    font-size: 0.75rem !important;
    white-space: nowrap !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transition: opacity 0.2s ease !important;
    margin-right: 0.5rem !important;
    z-index: 10001 !important;
}

.history-sidebar-container:not(.expanded) .history-sidebar-link:hover::after {
    opacity: 1 !important;
}

/* Scrollbar Styling for History Sidebar */
.history-sidebar-content::-webkit-scrollbar {
    width: 6px !important;
}

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

.history-sidebar-content::-webkit-scrollbar-thumb {
    background: rgba(100, 116, 139, 0.3) !important;
    border-radius: 3px !important;
}

.history-sidebar-content::-webkit-scrollbar-thumb:hover {
    background: rgba(100, 116, 139, 0.5) !important;
}

/* Active state for history links */
.history-sidebar-link.active {
    background: #f1f5f9 !important;
    color: #667eea !important;
    border-left-color: #667eea !important;
}

/* Responsive adjustments for smaller screens */
@media (max-width: 1200px) {
    .history-sidebar-container {
        width: 50px !important;
    }
    
    .history-sidebar-container.expanded {
        width: 260px !important;
    }
}

/* Scrollbar Styling */
#historySidebar::-webkit-scrollbar {
    width: 6px;
}

#historySidebar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
}

#historySidebar::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea, #764ba2);
    border-radius: 3px;
}

/* History Sidebar Header */
.history-sidebar-header {
    padding: 25px 20px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    position: sticky;
    top: 0;
    z-index: 10;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.history-sidebar-title {
    display: flex;
    align-items: center;
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 5px;
}

.history-sidebar-title i {
    margin-right: 10px;
    font-size: 1.1rem;
}

.history-sidebar-subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
    margin: 0;
}

#historySidebarClose {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    color: white;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#historySidebarClose:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

/* History Sidebar Content */
.history-sidebar-content {
    padding: 0;
    color: white;
}

/* History Sections */
.history-section {
    margin-bottom: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.history-section-header {
    padding: 20px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.history-section-header:hover {
    background: rgba(255, 255, 255, 0.08);
}

.history-section-header i {
    margin-right: 12px;
    color: #667eea;
    font-size: 1.1rem;
    width: 20px;
}

.history-section-header span {
    flex: 1;
    font-weight: 500;
    font-size: 1rem;
}

.section-toggle {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 5px;
    border-radius: 50%;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.section-toggle:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.1);
}

.section-toggle i {
    transition: transform 0.3s ease;
    margin: 0;
    width: auto;
}

/* History Section Content */
.history-section-content {
    padding: 0;
    max-height: 300px;
    overflow-y: auto;
}

.history-section-content::-webkit-scrollbar {
    width: 4px;
}

.history-section-content::-webkit-scrollbar-thumb {
    background: rgba(102, 126, 234, 0.5);
    border-radius: 2px;
}

/* History Items */
.history-item {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    cursor: pointer;
    transition: all 0.2s ease;
    background: transparent;
}

.history-item:hover {
    background: rgba(102, 126, 234, 0.1);
    transform: translateX(5px);
}

.history-item:last-child {
    border-bottom: none;
}

.history-item-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea, #764ba2);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 15px;
    font-size: 16px;
    color: white;
    flex-shrink: 0;
}

.history-item-content {
    flex: 1;
    min-width: 0;
}

.history-item-title {
    font-weight: 500;
    font-size: 0.95rem;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: white;
}

.history-item-meta {
    font-size: 0.8rem;
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    gap: 8px;
}

.history-item-meta span {
    white-space: nowrap;
}

.history-item-date {
    color: rgba(255, 255, 255, 0.6);
}

.history-item-count,
.history-item-duration,
.history-item-type {
    color: #667eea;
}

.history-item-actions {
    display: flex;
    gap: 5px;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.history-item:hover .history-item-actions {
    opacity: 1;
}

.btn-icon {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 12px;
}

.btn-icon:hover {
    background: rgba(102, 126, 234, 0.5);
    transform: scale(1.1);
}

/* Empty States */
.empty-state {
    padding: 30px 20px;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    font-style: italic;
    font-size: 0.9rem;
}

/* Loading States */
.loading-spinner {
    padding: 30px 20px;
    text-align: center;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.9rem;
}

/* Responsive Adjustments */
@media (max-width: 1200px) {
    #historySidebar {
        width: 320px;
        right: -320px;
    }
}

@media (max-width: 768px) {
    /* Hide desktop history sidebar on mobile */
    #historySidebarToggle,
    #historySidebar,
    #historySidebarOverlay {
        display: none !important;
    }
}

/* Animation for collapsible sections */
.history-section-content.collapsed {
    max-height: 0;
    overflow: hidden;
    padding: 0;
}

.history-section-content.expanded {
    max-height: 300px;
    overflow-y: auto;
}

/* Focus states for accessibility */
.history-item:focus,
.section-toggle:focus,
#historySidebarClose:focus,
#historySidebarToggle:focus {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

/* Smooth transitions for all interactive elements */
* {
    transition: all 0.2s ease;
}

/* Ensure proper content positioning with sidebar */
@media (min-width: 769px) {
    body {
        margin-right: var(--history-sidebar-mini-width) !important;
        padding-right: 0 !important;
        transition: margin-right 0.3s ease !important;
    }
    
    /* Body margin adjustment when history sidebar is expanded (desktop only) */
    /* ONLY adjust right margin, preserve unified sidebar's left margin */
    body.history-sidebar-expanded {
        margin-right: var(--history-sidebar-expanded-width) !important;
        transition: margin-right 0.3s ease !important;
    }
    
    /* Ensure unified sidebar body left margin is preserved when history sidebar expands */
    body.history-sidebar-expanded:not(.auth-page):not(.login-page):not(.register-page) {
        margin-left: var(--sidebar-mini-width, 70px) !important;
    }
    
    /* Center content properly on large screens */
    .container, .container-fluid {
        max-width: calc(100% - 20px) !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }
    
    /* Special handling for pages with their own content wrappers */
    .content-wrapper, .main-content {
        margin-right: 0 !important;
        padding-right: 0 !important;
    }
}

/* Special styling for different item types */
.conversation-item .history-item-icon {
    background: linear-gradient(135deg, #3498db, #2980b9);
}

.recording-item .history-item-icon {
    background: linear-gradient(135deg, #e74c3c, #c0392b);
}

.activity-item .history-item-icon {
    background: linear-gradient(135deg, #f39c12, #e67e22);
}

/* Mobile New Chat Button */
.mobile-new-chat-button {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-start !important;
    width: 100% !important;
    padding: 1rem !important;
    background: transparent !important;
    color: #64748b !important;
    border: none !important;
    border-radius: 12px !important;
    margin: 0.5rem 0 !important;
    font-size: 1rem !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    text-align: left !important;
}

.mobile-new-chat-button:hover {
    background: #f8fafc !important;
    color: #475569 !important;
}

.mobile-new-chat-button:active {
    background: #f1f5f9 !important;
    color: #334155 !important;
}

.mobile-new-chat-button .item-icon {
    background: #f1f5f9 !important;
    border-radius: 8px !important;
    padding: 8px !important;
    margin-right: 12px !important;
    transition: background-color 0.2s ease !important;
}

.mobile-new-chat-button:hover .item-icon {
    background: #e2e8f0 !important;
}

.mobile-new-chat-button .item-icon i {
    color: #64748b !important;
    font-size: 1.1rem !important;
    transition: color 0.2s ease !important;
}

.mobile-new-chat-button:hover .item-icon i {
    color: #475569 !important;
}

.mobile-new-chat-button .item-content .item-title {
    color: #64748b !important;
    font-weight: 600 !important;
    transition: color 0.2s ease !important;
}

.mobile-new-chat-button:hover .item-content .item-title {
    color: #475569 !important;
}

.mobile-new-chat-button .item-content .item-meta {
    color: #94a3b8 !important;
    transition: color 0.2s ease !important;
}

.mobile-new-chat-button:hover .item-content .item-meta {
    color: #64748b !important;
}