/* Main Container Layout */
.threads-main-container {
    margin-left: 210px;
    margin-top: 52px;
    height: calc(100vh - 52px);
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
}

.threads-main-container.sidebar-collapsed {
    margin-left: 60px;
}

.threads-content-wrapper {
    display: flex;
    flex-direction: column;
    height: 100%;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* Filter Header */
.threads-filter-header {
    background: white;
    border-bottom: 1px solid rgb(230, 230, 230);
    padding: 12px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
    z-index: 10;
}

.filter-tabs {
    display: flex;
    gap: 4px;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.filter-tabs::-webkit-scrollbar {
    display: none;
}

.filter-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border: none;
    background: transparent;
    color: #5f6368;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    border-radius: 6px;
    transition: all 0.2s ease;
    white-space: nowrap;
    position: relative;
}

.filter-tab:hover {
    background: #f3f4f6;
    color: #0366d6;
}

.filter-tab.active {
    color: #0366d6;
    background: #e7f3ff;
}

.filter-tab i {
    font-size: 14px;
}

.filter-actions {
    display: flex;
    gap: 8px;
}

.filter-action-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: #6b7280;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.filter-action-btn:hover {
    background: #f3f4f6;
    color: #0366d6;
}

/* Conversation Area */
.threads-conversation-area {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 24px;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.threads-conversation-area::-webkit-scrollbar {
    width: 6px;
}

.threads-conversation-area::-webkit-scrollbar-track {
    background: transparent;
}

.threads-conversation-area::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.1);
    border-radius: 3px;
}

.threads-conversation-area::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.2);
}

/* Welcome State */
.welcome-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    max-width: 800px;
    margin: auto;
    padding: 40px 20px;
}

.welcome-icon {
    margin-bottom: 24px;
    animation: float 3s ease-in-out infinite;
}

.welcome-icon svg {
    width: 80px;
    height: 80px;
    fill: #5DADE2;
    filter: drop-shadow(0 4px 12px rgba(93, 173, 226, 0.3));
}

@keyframes float {
    0%, 100% {
        transform: translateY(0px);
    }
    50% {
        transform: translateY(-10px);
    }
}

.welcome-state h2 {
    font-size: 28px;
    font-weight: 600;
    color: rgb(32, 33, 36);
    margin-bottom: 12px;
}

.welcome-state p {
    font-size: 16px;
    color: #6b7280;
    margin-bottom: 32px;
}

.welcome-suggestions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    width: 100%;
    max-width: 600px;
}

.suggestion-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 20px;
    background: white;
    border: 1px solid rgb(230, 230, 230);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    color: rgb(32, 33, 36);
}

.suggestion-btn:hover {
    border-color: #0366d6;
    box-shadow: 0 4px 12px rgba(3, 102, 214, 0.1);
    transform: translateY(-2px);
}

.suggestion-btn i {
    font-size: 24px;
    color: #0366d6;
}

/* Messages Container */
.messages-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
    margin: 0 auto;
    width: 100%;
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 12px;
    animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user-message {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: #0366d6;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    flex-shrink: 0;
}

.message.user-message .message-avatar {
    background: linear-gradient(135deg, #0366d6 0%, #1e6bb8 100%);
}

.message-content {
    flex: 1;
    max-width: 75%;
}

.message-bubble {
    background: white;
    border-radius: 16px;
    padding: 16px;
}

.message.user-message .message-bubble {
    background: #0366d6;
    color: white;
    border-color: #0366d6;
}

.message-text {
    font-size: 14px;
    line-height: 1.6;
    color: rgb(32, 33, 36);
}

.message.user-message .message-text {
    color: white;
}

.message-text p {
    margin: 0 0 8px 0;
}

.message-text p:last-child {
    margin-bottom: 0;
}

.message-text strong {
    font-weight: 600;
}

.message-text em {
    font-style: italic;
}

.message-text code {
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
}

.message.user-message .message-text code {
    background: rgba(255, 255, 255, 0.2);
}

.message-text ul,
.message-text ol {
    margin: 12px 0;
    padding-left: 24px;
}

.message-text li {
    margin-bottom: 6px;
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    font-size: 12px;
    color: #9aa0a6;
}

.message.user-message .message-meta {
    justify-content: flex-end;
}

.message-time {
    color: #9aa0a6;
}

.message.user-message .message-time {
    color: rgba(255, 255, 255, 0.8);
}

.message-actions {
    display: flex;
    gap: 4px;
}

.message-action-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: #9aa0a6;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 12px;
}

.message-action-btn:hover {
    background: #f3f4f6;
    color: #0366d6;
}

.message.user-message .message-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Thinking Indicator */
.thinking-indicator {
    display: flex;
    gap: 12px;
    max-width: 900px;
    margin: 0 auto;
    width: 100%;
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.thinking-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    flex-shrink: 0;
}

.thinking-content {
    background: white;
    border: 1px solid rgb(230, 230, 230);
    border-radius: 16px;
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.thinking-dots {
    display: flex;
    gap: 4px;
}

.thinking-dots span {
    width: 8px;
    height: 8px;
    background: #0366d6;
    border-radius: 50%;
    animation: thinkingDots 1.4s infinite ease-in-out;
}

.thinking-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.thinking-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes thinkingDots {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

.thinking-text {
    font-size: 14px;
    color: #6b7280;
}


.sources-section {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgb(230, 230, 230);
}

.sources-header {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.sources-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.source-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 8px;
    text-decoration: none;
    color: #0366d6;
    font-size: 13px;
    transition: all 0.2s ease;
}

.source-item:hover {
    background: #e7f3ff;
    transform: translateX(4px);
}

.source-item i {
    font-size: 12px;
}

/* Responsive Design */
@media screen and (max-width: 1024px) {
    .threads-main-container {
        margin-left: 60px;
    }

    .message-content {
        max-width: 85%;
    }

    .welcome-suggestions {
        grid-template-columns: 1fr;
    }
}

@media screen and (max-width: 768px) {
    .threads-filter-header {
        padding: 12px 16px;
    }

    .filter-tab span {
        display: none;
    }

    .filter-tab {
        padding: 8px 12px;
    }

    .threads-conversation-area {
        padding: 16px;
    }

    .threads-input-section {
        padding: 12px 16px;
    }

    .message-content {
        max-width: 90%;
    }

    .welcome-state {
        padding: 20px 16px;
    }

    .welcome-state h2 {
        font-size: 24px;
    }

    .suggestion-btn {
        padding: 16px;
    }
}

@media screen and (max-width: 480px) {
    .threads-main-container {
        margin-left: 0;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .thinking-avatar {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .message-bubble {
        padding: 12px;
    }
}

/* Loading and Error States */
.loading-message,
.error-message {
    text-align: center;
    padding: 20px;
    color: #6b7280;
}

.error-message {
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 8px;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.3s ease-out;
}

.fade-out {
    animation: fadeOut 0.3s ease-out;
}

@keyframes fadeOut {
    from {
        opacity: 1;
    }
    to {
        opacity: 0;
    }
}

/* Code Blocks */
.message-text pre {
    background: #f3f4f6;
    border: 1px solid rgb(230, 230, 230);
    border-radius: 8px;
    padding: 12px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-text pre code {
    background: transparent;
    padding: 0;
    font-size: 13px;
    line-height: 1.5;
}

.message.user-message .message-text pre {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

/* Citations and Links */
.message-text a {
    color: #0366d6;
    text-decoration: underline;
    transition: opacity 0.2s ease;
}

.message-text a:hover {
    opacity: 0.8;
}

.message.user-message .message-text a {
    color: white;
    text-decoration: underline;
}

/* Tables in Messages */
.message-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
}

.message-text th,
.message-text td {
    border: 1px solid rgb(230, 230, 230);
    padding: 8px 12px;
    text-align: left;
}

.message-text th {
    background: #f8f9fa;
    font-weight: 600;
}

/* Smooth Scroll */
.threads-conversation-area {
    scroll-behavior: smooth;
}