/* History Sidebar - Fresh Desktop Implementation
 * Clean CSS for right-side history sidebar
 */

/* Hide on mobile */
@media (max-width: 768px) {
    .history-sidebar-toggle-btn,
    .history-sidebar-container {
        display: none !important;
    }
}

/* Desktop only styles */
@media (min-width: 769px) {
    
    /* CSS Variables */
    :root {
        --history-sidebar-width: 280px;
        --history-primary: #667eea;
        --history-secondary: #764ba2;
        --history-gradient: linear-gradient(135deg, var(--history-primary) 0%, var(--history-secondary) 100%);
    }

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

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

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

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

    .history-sidebar-container.show {
        right: 0;
    }

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

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

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

    /* Header */
    .history-sidebar-header {
        background: var(--history-gradient);
        color: white;
        padding: 1rem;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        min-height: 80px;
        position: relative;
    }

    .history-sidebar-logo {
        width: 28px;
        height: 28px;
        margin-bottom: 0.5rem;
        filter: brightness(0) invert(1);
    }

    .history-sidebar-title {
        font-size: 0.9rem;
        font-weight: 600;
        text-align: center;
    }

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

    .history-sidebar-nav {
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    /* Sections */
    .history-sidebar-section {
        border-bottom: 1px solid #f1f5f9;
    }

    /* Links */
    .history-sidebar-link {
        display: flex;
        align-items: center;
        padding: 0.75rem 1rem;
        color: #64748b;
        text-decoration: none;
        font-size: 0.875rem;
        font-weight: 500;
        transition: all 0.2s ease;
        cursor: pointer;
        gap: 0.75rem;
    }

    .history-sidebar-link:hover {
        background: #f8fafc;
        color: #475569;
        text-decoration: none;
        border-right: 3px solid var(--history-primary);
    }

    .history-sidebar-link:active {
        background: #f1f5f9;
        color: #334155;
    }

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

    .history-sidebar-link-text {
        flex: 1;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

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

    .new-chat-button:hover {
        background: #f8fafc;
        color: #475569;
        border-right: 3px solid var(--history-primary);
    }

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

    .new-chat-button i {
        width: 20px;
        text-align: center;
        font-size: 1.1rem;
        flex-shrink: 0;
    }

    /* Chevrons */
    .history-sidebar-chevron {
        margin-left: auto;
        font-size: 0.875rem;
        transition: transform 0.2s ease;
        color: #94a3b8;
    }

    .history-sidebar-chevron.rotated {
        transform: rotate(180deg);
        color: var(--history-primary);
    }

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

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

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

    .conversations-scroll-container::-webkit-scrollbar {
        width: 6px;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

    /* Dropdown Content */
    .dropdown-content,
    .dropdown-loading {
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
        color: #64748b;
        text-align: center;
    }

    .dropdown-loading {
        opacity: 0.7;
    }

}