/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

/* Container */
.container {
    display: flex;
    height: 100vh;
    max-width: 1600px;
    margin: 0 auto;
    gap: 1rem;
    padding: 1rem;
}

/* Panel Base Styles */
.panel {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.panel-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    color: #333;
}

/* Chat Panel */
.chat-panel {
    flex: 1;
    min-width: 400px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}

.message {
    margin-bottom: 1rem;
    animation: fadeIn 0.3s ease;
}

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

.message-content {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    max-width: 85%;
}

.user-message .message-content {
    background: #007AFF;
    color: white;
    margin-left: auto;
    border-bottom-right-radius: 4px;
}

.bot-message .message-content {
    background: #f0f0f0;
    color: #333;
    border-bottom-left-radius: 4px;
}

.bot-message .message-content ul {
    margin: 0.5rem 0 0 1.5rem;
}

.bot-message .message-content li {
    margin: 0.25rem 0;
}

.news-links {
    margin-top: 1rem;
    padding-top: 0.75rem;
    border-top: 1px solid #ddd;
}

.news-links h4 {
    font-size: 0.875rem;
    color: #666;
    margin-bottom: 0.5rem;
}

.news-link {
    display: block;
    color: #007AFF;
    text-decoration: none;
    font-size: 0.875rem;
    margin: 0.25rem 0;
    padding: 0.25rem 0;
}

.news-link:hover {
    text-decoration: underline;
}

/* Chat Input */
.chat-input-container {
    padding: 1rem;
    border-top: 1px solid #eee;
    display: flex;
    gap: 0.5rem;
}

#chat-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

#chat-input:focus {
    border-color: #007AFF;
}

#send-button {
    padding: 0.75rem 1.5rem;
    background: #007AFF;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    cursor: pointer;
    transition: background-color 0.2s;
}

#send-button:hover {
    background: #0056b3;
}

#send-button:disabled {
    background: #ccc;
    cursor: not-allowed;
}

/* Status Badge */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge.connected {
    background: #d4edda;
    color: #155724;
}

.status-badge.disconnected {
    background: #f8d7da;
    color: #721c24;
}

.status-badge.connecting {
    background: #fff3cd;
    color: #856404;
}

/* Dashboard Panel */
.dashboard-panel {
    width: 400px;
    overflow-y: auto;
}

.dashboard-section {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid #eee;
}

.dashboard-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: #666;
    margin-bottom: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Flow Visualization */
.flow-visualization {
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.25rem;
    padding: 0.5rem 0;
}

.flow-node {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.node-circle {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: #e0e0e0;
    color: #666;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
    transition: all 0.3s ease;
}

.flow-node.active .node-circle {
    background: #007AFF;
    color: white;
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.2);
}

.flow-node.completed .node-circle {
    background: #28a745;
    color: white;
}

.node-label {
    font-size: 0.7rem;
    color: #666;
    text-align: center;
    max-width: 60px;
}

.flow-arrow {
    color: #ccc;
    font-size: 1rem;
}

/* Classification Display */
.classification-display {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 0.75rem;
}

.classification-badge {
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    min-width: 50px;
    text-align: center;
    background: #e0e0e0;
    color: #666;
}

.classification-badge.badge-a { background: #f8d7da; color: #721c24; }
.classification-badge.badge-b { background: #fff3cd; color: #856404; }
.classification-badge.badge-c1 { background: #d4edda; color: #155724; }
.classification-badge.badge-c2 { background: #cce5ff; color: #004085; }
.classification-badge.badge-c3 { background: #d1ecf1; color: #0c5460; }
.classification-badge.badge-d { background: #e2e3e5; color: #383d41; }

.classification-label {
    font-size: 0.875rem;
    color: #333;
}

.classification-legend {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
    font-size: 0.75rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-badge {
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-weight: 600;
    font-size: 0.625rem;
}

/* Search Info */
.search-info {
    background: #f8f9fa;
    border-radius: 8px;
    padding: 0.75rem;
}

.info-row {
    display: flex;
    margin-bottom: 0.5rem;
}

.info-row:last-child {
    margin-bottom: 0;
}

.info-label {
    font-weight: 500;
    color: #666;
    min-width: 80px;
}

.info-value {
    color: #333;
    word-break: break-all;
}

/* Debug Logs */
.debug-logs {
    max-height: 200px;
    overflow-y: auto;
    background: #1e1e1e;
    border-radius: 8px;
    padding: 0.75rem;
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 0.75rem;
}

.log-entry {
    color: #9cdcfe;
    margin-bottom: 0.25rem;
    padding: 0.25rem 0;
    border-bottom: 1px solid #333;
}

.log-entry:last-child {
    border-bottom: none;
}

.log-time {
    color: #6a9955;
}

.log-step {
    color: #dcdcaa;
}

.log-detail {
    color: #ce9178;
}

/* Loading State */
.loading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.loading-dots span {
    width: 8px;
    height: 8px;
    background: #007AFF;
    border-radius: 50%;
    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); }
    40% { transform: scale(1); }
}

/* Responsive */
@media (max-width: 900px) {
    .container {
        flex-direction: column;
    }

    .chat-panel {
        min-width: unset;
        flex: none;
        height: 60vh;
    }

    .dashboard-panel {
        width: 100%;
        height: 40vh;
    }
}
