
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background: #f8f9fa;
    height: 100vh;
    overflow: hidden;
    font-size: 14px;
}

.container {
    display: flex;
    height: 100vh;
}

/* Sidebar Styles */
.sidebar {
    width: 320px;
    background: white;
    border-right: 1px solid #e1e4e8;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid #e1e4e8;
    background: #fafbfc;
}

.sidebar-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: #24292e;
}

.parameter-form {
    padding: 20px;
    flex: 1;
    overflow-y: auto;
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 500;
    color: #586069;
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5da;
    border-radius: 6px;
    font-size: 13px;
    font-family: inherit;
    transition: border-color 0.2s;
    background: white;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #687EFF;
    box-shadow: 0 0 0 3px rgba(104, 126, 255, 0.1);
}

.form-group textarea {
    resize: vertical;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Fira Code', monospace;
    font-size: 12px;
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: #f8f9fa;
}

.chat-header {
    background: white;
    padding: 16px 24px;
    border-bottom: 1px solid #e1e4e8;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h1 {
    font-size: 18px;
    font-weight: 600;
    color: #24292e;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: #586069;
}

.status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #d1d5da;
    transition: background 0.3s;
}

.status-indicator.connected {
    background: #28a745;
}

.status-indicator.connecting {
    background: #ffa726;
}

.status-indicator.error {
    background: #dc3545;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 24px;
}

.welcome-message {
    text-align: center;
    padding: 60px 20px;
    color: #586069;
}

.welcome-message h2 {
    font-size: 22px;
    margin-bottom: 12px;
    color: #24292e;
}

.welcome-message p {
    font-size: 14px;
    line-height: 1.6;
    max-width: 600px;
    margin: 0 auto;
}

/* Message Styles */
.message {
    margin-bottom: 16px;
    animation: fadeIn 0.2s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-user {
    display: flex;
    justify-content: flex-end;
}

.message-user .message-content {
    background: #687EFF;
    color: white;
    padding: 12px 16px;
    border-radius: 16px;
    max-width: 70%;
    word-wrap: break-word;
    font-size: 14px;
    line-height: 1.5;
}

.message-assistant {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* Thinking Section - Cleaner Design */
.thinking-section {
    background: white;
    border: 1px solid #e1e4e8;
    border-radius: 8px;
    margin-bottom: 12px;
    overflow: hidden;
}

.thinking-section.system-tag {
    border-left: 3px solid #B6FFFA;
}

.thinking-section.pipeline-tag {
    border-left: 3px solid #98E4FF;
}

.thinking-section.csv-tag {
    border-left: 3px solid #80B3FF;
}

.thinking-section.group-tag {
    border-left: 3px solid #687EFF;
}

.thinking-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    cursor: pointer;
    user-select: none;
    transition: background 0.15s;
    background: #fafbfc;
}

.thinking-header:hover {
    background: #f3f4f6;
}

.thinking-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 600;
    color: #24292e;
}

.thinking-badge {
    display: inline-block;
    padding: 2px 8px;
    background: #e1e4e8;
    color: #586069;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
}

.expand-icon {
    width: 16px;
    height: 16px;
    transition: transform 0.2s;
    color: #586069;
}

.thinking-header.expanded .expand-icon {
    transform: rotate(180deg);
}

.thinking-content {
    display: none;
    padding: 0;
    background: white;
}

.thinking-content.expanded {
    display: block;
}

/* Thinking Item - Minimal Clean Design */
.thinking-item {
    margin: 0;
    padding: 16px;
    border-top: 1px solid #f6f8fa;
    font-size: 13px;
    line-height: 1.6;
}

.thinking-item:first-child {
    border-top: none;
}

.thinking-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.thinking-item-title {
    font-size: 13px;
    font-weight: 600;
    color: #24292e;
}

.thinking-item-type {
    display: inline-block;
    padding: 2px 8px;
    background: #f6f8fa;
    color: #586069;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.thinking-item-content {
    color: #586069;
}

/* Simplified Data Display */
.data-grid {
    display: grid;
    gap: 8px;
    margin-top: 8px;
}

.data-row {
    display: grid;
    grid-template-columns: 140px 1fr;
    gap: 12px;
    padding: 8px 12px;
    background: #f6f8fa;
    border-radius: 6px;
    align-items: start;
}

/* NEW: Style for rows containing objects/arrays */
.data-row-block {
    grid-template-columns: 1fr; /* Single column layout for complex data */
    padding: 12px;
}

.data-row-block .data-key {
    margin-bottom: 8px;
}

.nested-object-content {
    background: white;
    padding: 10px;
    border: 1px solid #e1e4e8;
    border-radius: 4px;
    font-family: 'SF Mono', monospace;
    font-size: 11px;
    white-space: pre-wrap;
    overflow-x: auto;
    max-height: 150px;
}

.data-row.success {
    background: #f0f9f4;
    border-left: 2px solid #28a745;
}

.data-row.error {
    background: #fff5f5;
    border-left: 2px solid #dc3545;
}

.data-row.info {
    background: #f0f7ff;
    border-left: 2px solid #687EFF;
}

.data-key {
    font-weight: 600;
    color: #24292e;
    font-size: 12px;
}

.data-value {
    color: #586069;
    font-size: 12px;
    word-break: break-word;
}

/* Stage Progress Indicator */
.stage-progress {
    margin-top: 12px;
    padding: 12px;
    background: #f6f8fa;
    border-radius: 6px;
    border-left: 3px solid #687EFF;
}

.stage-label {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #586069;
    margin-bottom: 6px;
}

.stage-name {
    font-size: 13px;
    font-weight: 500;
    color: #24292e;
    margin-bottom: 4px;
}

.stage-description {
    font-size: 12px;
    color: #6a737d;
    line-height: 1.5;
}

/* Text Content */
.text-content {
    color: #586069;
    line-height: 1.6;
    font-size: 13px;
    margin-top: 8px;
}

.text-content strong {
    color: #24292e;
    font-weight: 600;
}

.text-content.error-content {
    color: #dc3545;
}

/* Code Preview - Clean Minimal Design */
.code-preview {
    background: #f6f8fa;
    border: 1px solid #e1e4e8;
    padding: 12px;
    border-radius: 6px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    font-size: 11px;
    line-height: 1.6;
    color: #24292e;
    overflow-x: auto;
    margin: 8px 0;
    max-height: 200px;
    overflow-y: auto;
}

/* NEW: Inline Code Preview for final answer markdown output */
.code-preview-inline {
    background: #f6f8fa;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', monospace;
    font-size: 11px;
    line-height: 1.6;
    color: #24292e;
    overflow-x: auto;
    margin: 8px 0;
    max-height: 150px;
    overflow-y: auto;
    padding: 10px;
}

.code-preview-inline pre {
    margin: 0;
    padding: 0;
    border: none;
    background: transparent;
}


/* Nested Object Display */
.nested-object {
    background: #fafbfc;
    border: 1px solid #e1e4e8;
    border-radius: 6px;
    padding: 12px;
    margin-top: 8px;
}

.nested-object-title {
    font-weight: 600;
    color: #24292e;
    margin-bottom: 8px;
    font-size: 12px;
}

/* CSV Groups - Cleaner */
.csv-groups-container {
    margin-top: 12px;
    display: grid;
    gap: 8px;
}

.csv-group-item {
    background: #fafbfc;
    border: 1px solid #e1e4e8;
    border-left: 3px solid #80B3FF;
    border-radius: 6px;
    padding: 12px;
}

.csv-group-header {
    font-weight: 600;
    color: #24292e;
    margin-bottom: 8px;
    font-size: 13px;
}

.csv-group-details {
    display: grid;
    gap: 6px;
    font-size: 12px;
}

.csv-group-detail {
    color: #586069;
    display: grid;
    grid-template-columns: 100px 1fr;
    gap: 8px;
}

.csv-group-detail strong {
    color: #24292e;
    font-weight: 600;
}

/* Plan Display */
.plan-container {
    background: #f0f9f4;
    border-left: 3px solid #28a745;
    border-radius: 6px;
    padding: 12px;
    margin-top: 12px;
}

.plan-title {
    font-weight: 600;
    color: #24292e;
    margin-bottom: 8px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.plan-content {
    color: #586069;
    font-size: 12px;
    line-height: 1.6;
    white-space: pre-wrap;
}

/* Reasoning Display */
.reasoning-container {
    background: #f6f8fa;
    border-left: 3px solid #687EFF;
    border-radius: 6px;
    padding: 12px;
    margin-top: 12px;
}

.reasoning-title {
    font-weight: 600;
    color: #24292e;
    margin-bottom: 8px;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.reasoning-content {
    color: #586069;
    font-size: 12px;
    line-height: 1.6;
}

/* Final Answer - Professional Design */
.final-answer {
    background: white;
    padding: 20px;
    border-radius: 8px;
    border: 2px solid #B6FFFA;
    margin-top: 12px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.final-answer-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    color: #687EFF;
    font-weight: 600;
    font-size: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e1e4e8;
}

.final-answer-content {
    color: #24292e;
    line-height: 1.7;
    font-size: 14px;
}

.final-answer-content p {
    margin-bottom: 12px;
}

.final-answer-content p:last-child {
    margin-bottom: 0;
}

/* NEW: QA Summary Results */
.qa-result {
    margin-bottom: 12px;
    padding: 12px;
    border-left: 3px solid #687EFF;
    border-radius: 6px;
    background: #f6f8fa;
}

.qa-result-success {
    border-left-color: #28a745;
    background: #f0f9f4;
}

.qa-result-error {
    border-left-color: #dc3545;
    background: #fff5f5;
}

.qa-result:last-child {
    margin-bottom: 0;
}

.qa-result-question {
    font-weight: 600;
    color: #24292e;
    margin-bottom: 6px;
    font-size: 13px;
}

.qa-result-answer {
    color: #586069;
    line-height: 1.6;
    font-size: 13px;
    margin-bottom: 6px;
}

.qa-result-meta {
    font-size: 11px;
    color: #959da5;
}

/* NEW: Clarification List Style */
.clarification-list {
    margin-top: 12px;
    padding: 12px;
    background: #fffbe6;
    border: 1px dashed #ffe58f;
    border-radius: 6px;
    font-size: 13px;
    color: #614700;
}

.clarification-list strong {
    color: #614700;
}

.clarification-list ul {
    margin-top: 8px;
    margin-left: 20px;
}

.clarification-list li {
    margin-bottom: 4px;
}

/* Chat Input */
.chat-input-container {
    padding: 16px 24px;
    background: white;
    border-top: 1px solid #e1e4e8;
}

.input-wrapper {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #f6f8fa;
    border: 1px solid #d1d5da;
    border-radius: 24px;
    padding: 4px 4px 4px 16px;
    transition: all 0.2s;
}

.input-wrapper:focus-within {
    border-color: #687EFF;
    background: white;
    box-shadow: 0 0 0 3px rgba(104, 126, 255, 0.1);
}

.input-wrapper input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 0;
    font-size: 14px;
    outline: none;
    color: #24292e;
}

.input-wrapper input::placeholder {
    color: #959da5;
}

.send-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: #687EFF;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.send-button:hover:not(:disabled) {
    background: #5568E0;
    transform: scale(1.05);
}

.send-button:disabled {
    background: #d1d5da;
    cursor: not-allowed;
}

/* Loading Animation */
.loading-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    margin-left: 10px;
}

.loading-dots span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #687EFF;
    animation: bounce 1.4s infinite ease-in-out both;
}

.loading-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.loading-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {
    0%, 80%, 100% {
        transform: scale(0);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f6f8fa;
}

::-webkit-scrollbar-thumb {
    background: #d1d5da;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #959da5;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 280px;
    }
    
    .chat-messages {
        padding: 16px;
    }
}