/* Global Styles */
* { 
    box-sizing: border-box; 
}

body { 
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; 
    margin: 0; 
    padding: 0; 
    background: #f8fafc; 
    height: 100vh; 
    overflow: hidden; 
}

.chat-container { 
    display: flex; 
    height: 100vh; 
}

/* Left Sidebar */
.sidebar { 
    width: 400px; 
    background: white; 
    border-right: 1px solid #e2e8f0; 
    display: flex; 
    flex-direction: column; 
}

.sidebar-header { 
    padding: 20px; 
    border-bottom: 1px solid #e2e8f0; 
    background: #f8fafc; 
}

.sidebar-header h1 { 
    margin: 0; 
    font-size: 20px; 
    color: #1e293b; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
}

.sidebar-header .subtitle { 
    margin: 5px 0 0 0; 
    font-size: 12px; 
    color: #64748b; 
}

.sidebar-content { 
    flex: 1; 
    padding: 20px; 
    overflow-y: auto; 
}

.form-section { 
    margin-bottom: 24px; 
}

.form-section h3 { 
    margin: 0 0 12px 0; 
    font-size: 14px; 
    font-weight: 600; 
    color: #374151; 
    text-transform: uppercase; 
    letter-spacing: 0.05em; 
}

.form-group { 
    margin-bottom: 16px; 
}

.form-group label { 
    display: block; 
    margin-bottom: 6px; 
    font-weight: 500; 
    color: #374151; 
    font-size: 13px; 
}

.form-group input, 
.form-group textarea { 
    width: 100%; 
    padding: 10px 12px; 
    border: 1px solid #d1d5db; 
    border-radius: 6px; 
    font-size: 14px; 
    transition: border-color 0.2s, box-shadow 0.2s; 
}

.form-group input:focus, 
.form-group textarea:focus { 
    outline: none; 
    border-color: #3b82f6; 
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1); 
}

/* Platform Dropdown */
.platform-dropdown-container { 
    position: relative; 
}

.platform-dropdown { 
    position: absolute; 
    top: 100%; 
    left: 0; 
    right: 0; 
    background: white; 
    border: 1px solid #d1d5db; 
    border-top: none; 
    border-radius: 0 0 6px 6px; 
    max-height: 200px; 
    overflow-y: auto; 
    z-index: 1000; 
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1); 
}

.platform-option { 
    padding: 12px; 
    cursor: pointer; 
    border-bottom: 1px solid #f3f4f6; 
    transition: background-color 0.2s ease; 
}

.platform-option:hover { 
    background: #f8fafc; 
}

.platform-option:last-child { 
    border-bottom: none; 
}

.platform-option .platform-name { 
    font-weight: 500; 
    color: #1f2937; 
    font-size: 14px; 
}

.platform-option .account-name { 
    font-size: 12px; 
    color: #6b7280; 
    margin-top: 2px; 
}

.selected-platform-info { 
    margin-top: 12px; 
    padding: 12px; 
    background: #ecfdf5; 
    border: 1px solid #bbf7d0; 
    border-radius: 6px; 
    font-size: 12px; 
    color: #065f46; 
}

.loading { 
    text-align: center; 
    padding: 12px; 
    color: #6b7280; 
    font-size: 13px; 
}

.send-button { 
    width: 100%; 
    background: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%); 
    color: white; 
    padding: 12px; 
    border: none; 
    border-radius: 6px; 
    cursor: pointer; 
    font-size: 14px; 
    font-weight: 500; 
    transition: all 0.2s; 
}

.send-button:hover { 
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4); 
}

.send-button:active { 
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3); 
}

/* Right Chat Area */
.chat-area { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    background: white; 
}

.chat-header { 
    padding: 20px; 
    border-bottom: 1px solid #e2e8f0; 
    background: #f8fafc; 
}

.chat-header h2 { 
    margin: 0; 
    font-size: 18px; 
    color: #1e293b; 
    display: flex; 
    align-items: center; 
    gap: 8px; 
}

.chat-header .status { 
    margin: 5px 0 0 0; 
    font-size: 12px; 
    color: #64748b; 
    font-weight: 500; 
}

.chat-messages { 
    flex: 1; 
    padding: 20px; 
    overflow-y: auto; 
    background: #ffffff; 
    display: flex; 
    flex-direction: column; 
    gap: 24px;
    scroll-behavior: smooth;
}

/* Welcome Screen */
.chat-welcome { 
    flex: 1; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center; 
    text-align: center; 
    padding: 40px 20px; 
    color: #64748b; 
    max-width: 600px; 
    margin: 0 auto; 
}

.welcome-icon { 
    font-size: 48px; 
    margin-bottom: 16px; 
}

.chat-welcome h3 { 
    margin: 0 0 16px 0; 
    color: #1e293b; 
    font-size: 24px; 
    font-weight: 600; 
}

.chat-welcome p { 
    margin: 0 0 24px 0; 
    line-height: 1.6; 
    font-size: 16px; 
}

.platform-status { 
    display: grid; 
    grid-template-columns: 1fr 1fr; 
    gap: 12px; 
    margin-bottom: 32px; 
    width: 100%; 
    max-width: 500px; 
}

.platform-item { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    padding: 12px 16px; 
    background: white; 
    border-radius: 8px; 
    border: 1px solid #e2e8f0; 
    font-size: 14px; 
    font-weight: 500; 
}

.status-icon.ready { 
    color: #10b981; 
}

.status-icon.pending { 
    color: #f59e0b; 
}

.example-queries { 
    width: 100%; 
}

.example-queries h4 { 
    margin: 0 0 16px 0; 
    color: #374151; 
    font-size: 16px; 
    font-weight: 600; 
}

.query-examples { 
    display: flex; 
    flex-wrap: wrap; 
    gap: 8px; 
    justify-content: center; 
}

.query-tag { 
    padding: 8px 12px; 
    background: white; 
    border: 1px solid #e2e8f0; 
    border-radius: 20px; 
    font-size: 13px; 
    color: #374151; 
    font-style: italic; 
    transition: all 0.2s; 
}

.query-tag:hover { 
    background: #f3f4f6; 
    border-color: #d1d5db; 
}

/* Chat Messages */
.message { 
    display: flex; 
    flex-direction: row; 
    gap: 12px;
    max-width: 100%;
}

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

.message.assistant { 
    flex-direction: row;
    justify-content: flex-start;
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    margin-top: 4px;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.message.assistant .message-avatar {
    background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
    color: white;
    box-shadow: 0 2px 8px rgba(79, 172, 254, 0.3);
}

.message-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.message-bubble { 
    max-width: 100%; 
    padding: 16px 20px; 
    border-radius: 20px; 
    word-wrap: break-word; 
    line-height: 1.5; 
    font-size: 15px;
    position: relative;
    transition: all 0.2s ease;
}

.message.user .message-bubble { 
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); 
    color: white; 
    border-bottom-right-radius: 6px;
    box-shadow: 0 2px 12px rgba(102, 126, 234, 0.2);
}

.message.assistant .message-bubble { 
    background: #f8f9fa; 
    color: #2d3748; 
    border: 1px solid #e2e8f0; 
    border-bottom-left-radius: 6px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.message-time { 
    font-size: 12px; 
    color: #718096; 
    margin-top: 8px; 
    opacity: 0.7;
    font-weight: 400;
}



/* Markdown Styles in Chat Messages */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4,
.message-bubble h5,
.message-bubble h6 {
    margin: 12px 0 8px 0;
    font-weight: 600;
    line-height: 1.3;
}

.message-bubble h1 { font-size: 18px; }
.message-bubble h2 { font-size: 16px; }
.message-bubble h3 { font-size: 15px; }
.message-bubble h4 { font-size: 14px; }
.message-bubble h5 { font-size: 13px; }
.message-bubble h6 { font-size: 12px; }

.message-bubble p {
    margin: 8px 0;
    line-height: 1.5;
}

.message-bubble ul,
.message-bubble ol {
    margin: 8px 0;
    padding-left: 20px;
}

.message-bubble li {
    margin: 4px 0;
    line-height: 1.4;
}

.message-bubble blockquote {
    margin: 12px 0;
    padding: 8px 12px;
    border-left: 3px solid #e5e7eb;
    background: rgba(0, 0, 0, 0.03);
    border-radius: 4px;
    font-style: italic;
}

.message.assistant .message-bubble blockquote {
    background: rgba(0, 0, 0, 0.05);
    border-left-color: #3b82f6;
}

.message.user .message-bubble blockquote {
    background: rgba(255, 255, 255, 0.1);
    border-left-color: rgba(255, 255, 255, 0.5);
}

.message-bubble code {
    background: rgba(0, 0, 0, 0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
}

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

.message-bubble pre {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 12px;
    margin: 12px 0;
    overflow-x: auto;
    font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', monospace;
    font-size: 13px;
    line-height: 1.4;
}

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

.message-bubble pre code {
    background: none;
    padding: 0;
    border-radius: 0;
}

.message-bubble a {
    color: inherit;
    text-decoration: underline;
    text-decoration-color: rgba(59, 130, 246, 0.5);
}

.message.user .message-bubble a {
    text-decoration-color: rgba(255, 255, 255, 0.7);
}

.message-bubble a:hover {
    text-decoration-color: currentColor;
}

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

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

.message-bubble hr {
    border: none;
    border-top: 1px solid #e5e7eb;
    margin: 16px 0;
}

.message.user .message-bubble hr {
    border-top-color: rgba(255, 255, 255, 0.3);
}

.message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 13px;
}

.message-bubble th,
.message-bubble td {
    padding: 6px 8px;
    border: 1px solid #e5e7eb;
    text-align: left;
}

.message-bubble th {
    background: #f8fafc;
    font-weight: 600;
}

.message.user .message-bubble th {
    background: rgba(255, 255, 255, 0.1);
}

.message.user .message-bubble th,
.message.user .message-bubble td {
    border-color: rgba(255, 255, 255, 0.2);
}

/* Chat Response Styles */
.chat-response { 
    background: #f8fafc; 
    border-left: 4px solid #3b82f6; 
    padding: 16px; 
    border-radius: 8px; 
    margin: 16px 0; 
}

.chat-response h1, 
.chat-response h2, 
.chat-response h3 { 
    color: #1e293b; 
    margin-top: 0; 
}

.chat-response a { 
    color: #3b82f6; 
    text-decoration: none; 
}

.chat-response a:hover { 
    text-decoration: underline; 
}

.chat-response code { 
    background: #e2e8f0; 
    padding: 2px 6px; 
    border-radius: 4px; 
    font-size: 13px; 
}

.chat-response pre { 
    background: #1e293b; 
    color: #e2e8f0; 
    padding: 16px; 
    border-radius: 8px; 
    overflow-x: auto; 
    font-size: 13px; 
}

.chat-response ul, 
.chat-response ol { 
    padding-left: 20px; 
}

.chat-response blockquote { 
    border-left: 4px solid #3b82f6; 
    margin: 16px 0; 
    padding-left: 16px; 
    color: #64748b; 
}

/* Status Styles */
.success { 
    background: #ecfdf5; 
    border: 1px solid #bbf7d0; 
    color: #065f46; 
}

.error { 
    background: #fef2f2; 
    border: 1px solid #fecaca; 
    color: #991b1b; 
}

.conversation-info { 
    background: #eff6ff; 
    border: 1px solid #bfdbfe; 
    color: #1e40af; 
    padding: 12px; 
    border-radius: 6px; 
    margin-bottom: 12px; 
    font-size: 12px; 
}

.thinking { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
    color: #6b7280; 
    font-style: italic; 
}

.thinking::before { 
    content: '🤖'; 
}

/* Chat Input Area */
.chat-input-area {
    border-top: 1px solid #e2e8f0;
    background: white;
    padding: 16px 20px;
}

.chat-input-container {
    max-width: 100%;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 8px;
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: #3b82f6;
}

.input-wrapper.disabled {
    opacity: 0.6;
    background: #f1f5f9;
}

#chat-message {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    padding: 8px 12px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    min-height: 20px;
    max-height: 120px;
    overflow-y: auto;
}

#chat-message:disabled {
    color: #9ca3af;
    cursor: not-allowed;
}

#chat-message::placeholder {
    color: #9ca3af;
}

.send-btn {
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 8px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background: #2563eb;
}

.send-btn:disabled {
    background: #d1d5db;
    color: #9ca3af;
    cursor: not-allowed;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    font-size: 12px;
    color: #6b7280;
}

.platform-indicator {
    font-weight: 500;
}

.typing-indicator {
    color: #3b82f6;
    font-style: italic;
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar { 
        width: 100%; 
        position: absolute; 
        z-index: 100; 
        height: 100%; 
        transform: translateX(-100%); 
        transition: transform 0.3s; 
    }
    
    .sidebar.open { 
        transform: translateX(0); 
    }
    
    .chat-area { 
        width: 100%; 
    }
}

/* Streaming Message Styles */
.message.streaming {
    animation: streamingPulse 2s ease-in-out infinite;
}

.message-bubble.streaming-bubble {
    background: linear-gradient(135deg, #f0f9ff 0%, #fef7ff 100%);
    border: 2px solid #60a5fa;
    position: relative;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(96, 165, 250, 0.15);
}

/* ChatGPT-like thinking indicator */
.thinking-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: #f8f9fa;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    margin: 8px 0;
    animation: thinkingPulse 1.5s ease-in-out infinite;
}

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

.thinking-dot {
    width: 8px;
    height: 8px;
    background: #60a5fa;
    border-radius: 50%;
    animation: thinkingDot 1.4s ease-in-out infinite;
}

.thinking-dot:nth-child(1) { animation-delay: 0s; }
.thinking-dot:nth-child(2) { animation-delay: 0.2s; }
.thinking-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinkingDot {
    0%, 60%, 100% {
        opacity: 0.5;
    }
    30% {
        opacity: 1;
    }
}

@keyframes thinkingPulse {
    0%, 100% {
        opacity: 0.8;
    }
    50% {
        opacity: 1;
    }
}

.streaming-status {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-weight: 500;
    color: #1565c0;
}

.status-text {
    flex: 1;
    font-size: 14px;
}

.step-badge {
    background: #4fc3f7;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: all 0.3s ease;
}

.step-badge.step-init { background: #9c27b0; }
.step-badge.step-analysis { background: #ff9800; }
.step-badge.step-routing { background: #2196f3; }
.step-badge.step-processing { background: #4caf50; }
.step-badge.step-planning { background: #673ab7; }
.step-badge.step-fetching { background: #00bcd4; }
.step-badge.step-analyzing { background: #ff5722; }
.step-badge.step-rendering { background: #e91e63; }
.step-badge.step-fallback { background: #795548; }

.streaming-progress {
    margin-top: 8px;
}

.progress-bar {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4fc3f7, #29b6f6);
    border-radius: 2px;
    transition: width 0.5s ease;
    position: relative;
}

.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.4),
        transparent
    );
    animation: progressShimmer 1.5s ease-in-out infinite;
}

.completion-indicator {
    margin-top: 12px;
    padding: 8px 12px;
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid rgba(76, 175, 80, 0.3);
    border-radius: 6px;
    color: #2e7d32;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 6px;
}

@keyframes streamingPulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.98;
    }
}

@keyframes progressShimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Streaming indicator for GitHub platform */
.platform-indicator.github-streaming::after {
    content: '📡';
    margin-left: 8px;
    animation: spin 2s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
