/* Research Assistant Tab Styles */

/* Research Tab - Override default tab styles */
#researchTab {
    padding: 0 !important;
    flex: none !important; /* Don't expand with flex */
}

#researchTab.active {
    display: block !important;
    overflow-y: auto !important;
    height: 100% !important; /* Fill available space */
}

.research-container {
    display: flex;
    flex-direction: row; /* Changed from column to row for sidebar layout */
    height: 100%;
    background: var(--bg-primary);
}

/* Session Containers */
.session-container {
    display: none;
}

/* ============================================================================
   LEFT SIDEBAR - Sessions
   ============================================================================ */

.research-sidebar {
    width: 220px;
    background: #f8f9fa;
    border-right: 1px solid #e0e0e0;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.research-sidebar-section {
    padding: 12px;
    border-bottom: 1px solid #e0e0e0;
}

.research-sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    border-bottom: 1px solid #e0e0e0;
}

.research-sidebar-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #333;
    text-transform: uppercase;
}

.research-new-session-btn {
    width: calc(100% - 24px);
    margin: 12px;
    padding: 10px;
    background: #28a745;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.research-new-session-btn:hover {
    background: #218838;
}

.research-sessions-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

/* Session Items in Sidebar */
.session-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    margin-bottom: 6px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
}

.session-tab:hover {
    background: #e3f2fd;
    border-color: #1976d2;
}

.session-tab.active {
    background: #3b82f6;
    color: white;
    border-color: #3b82f6;
}

.session-tab.active:hover {
    background: #2563eb;
}

.session-tab.pinned {
    border: 2px solid #f59e0b;
    box-shadow: 0 0 0 1px #f59e0b;
}

.session-tab-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.tab-actions {
    display: flex;
    gap: 4px;
    align-items: center;
}

.tab-action-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 3px;
    font-size: 12px;
    opacity: 0.5;
    transition: all 0.2s;
    cursor: pointer;
}

.session-tab:hover .tab-action-btn {
    opacity: 1;
}

.tab-action-btn:hover {
    background: rgba(0, 0, 0, 0.1);
    transform: scale(1.1);
}

.session-tab.active .tab-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.tab-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    border-radius: 3px;
    font-size: 16px;
    opacity: 0.7;
    transition: all 0.2s;
    cursor: pointer;
}

.tab-close:hover {
    opacity: 1;
    background: rgba(220, 38, 38, 0.1);
    transform: scale(1.1);
}

.session-tab.active .tab-close:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Deep Research Toggle in Sidebar */
.deep-research-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 13px;
    color: #333;
}

.deep-research-toggle:hover {
    background: #f0f9ff;
    border-color: #10b981;
}

.deep-research-toggle input[type="checkbox"] {
    margin: 0;
    cursor: pointer;
}

.deep-research-toggle input[type="checkbox"]:checked + span {
    color: #10b981;
    font-weight: 600;
}

.btn-new-session {
    display: inline-block !important;
    visibility: visible !important;
    padding: 6px 12px;
    background: #3b82f6 !important;
    color: #ffffff !important;
    border: none !important;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
    min-width: 70px;
}

.btn-new-session:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.btn-new-session:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.tab-counter {
    font-size: 11px;
    font-weight: 600;
    color: #666;
    padding: 2px 6px;
    background: #e0e0e0;
    border-radius: 10px;
}

.tab-counter.warning {
    color: #f59e0b;
    background: #fef3c7;
}

/* ============================================================================
   MAIN CONTENT AREA
   ============================================================================ */

.research-main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Messages Area */
.research-messages-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.research-messages-header {
    padding: 12px 16px;
    background: #f8f9fa;
    border-bottom: 1px solid #e0e0e0;
}

.session-title {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.research-messages-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: white;
}

/* Controls */
.research-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px;
    background: #f8f9fa;
    border-top: 1px solid #e0e0e0;
}

.research-icon-buttons {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.research-controls .text-input {
    width: 100%;
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    font-family: inherit;
    resize: vertical;
    min-height: 80px;
    max-height: 200px;
    background: white;
    color: #333;
    transition: all 0.2s;
}

.research-controls .text-input:focus {
    outline: none;
    border-color: #10b981;
    box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.1);
}

.research-controls .btn-icon {
    padding: 8px 12px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}

.research-controls .btn-icon:hover {
    background: var(--bg-hover);
    border-color: var(--primary-color);
    transform: scale(1.05);
}

.research-controls .btn-send {
    display: inline-block !important;
    visibility: visible !important;
    padding: 10px 20px;
    background: #28a745 !important;
    color: #ffffff !important;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    flex-shrink: 0;
}

.research-controls .btn-send.hidden {
    display: none !important;
}

.research-controls .btn-send:hover {
    background: #218838 !important;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

.research-controls .btn-send:active {
    transform: translateY(0);
}

/* Reuse message styles from main chat */
.research-messages-content .message {
    margin-bottom: 10px;
    position: relative;
}

.research-messages-content .message.user {
    display: flex;
    justify-content: flex-end;
}

.research-messages-content .message.assistant {
    display: flex;
    justify-content: flex-start;
}

.research-messages-content .message-bubble {
    max-width: 80%;
    padding: 8px 12px;
    border-radius: 12px;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.5;
}

.research-messages-content .message.user .message-bubble {
    background: linear-gradient(135deg, var(--primary-color) 0%, #0056b3 100%);
    color: white;
    box-shadow: 0 2px 6px rgba(0, 123, 255, 0.25);
}

.research-messages-content .message.assistant .message-bubble {
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.research-messages-content .message-actions {
    display: flex;
    gap: 4px;
    margin-top: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.research-messages-content .message:hover .message-actions {
    opacity: 1;
}

.research-messages-content .message-action-btn {
    padding: 3px 6px;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    transition: all 0.2s;
}

.research-messages-content .message-action-btn:hover {
    background: var(--bg-hover);
    border-color: var(--primary-color);
}

/* Scrollbar styling */
.session-tabs-container::-webkit-scrollbar,
.research-messages-content::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

.session-tabs-container::-webkit-scrollbar-track,
.research-messages-content::-webkit-scrollbar-track {
    background: var(--bg-primary);
}

.session-tabs-container::-webkit-scrollbar-thumb,
.research-messages-content::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

.session-tabs-container::-webkit-scrollbar-thumb:hover,
.research-messages-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.session-tab {
    animation: slideIn 0.2s ease-out;
}

/* Responsive */
@media (max-width: 768px) {
    .research-session-tabs {
        padding: 8px;
    }

    .session-tab {
        min-width: 100px;
        max-width: 140px;
        padding: 6px 10px;
    }

    .research-controls {
        flex-direction: column;
    }

    .research-controls .btn-send {
        width: 100%;
    }
}
