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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: linear-gradient(135deg, #204946 0%, #2d5f5c 100%);
    color: white;
    padding: 1rem 2rem;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
}

.header-text {
    flex: 1;
}

.header h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

.language-toggle {
    margin-left: 2rem;
}

.language-select {
    padding: 0.5rem 1rem;
    border: 2px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    background: rgba(255,255,255,0.1);
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.3s ease;
}

.language-select:hover {
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
}

.language-select:focus {
    outline: none;
    border-color: rgba(255,255,255,0.8);
    box-shadow: 0 0 0 3px rgba(32,73,70,0.2);
}

.language-select option {
    background: #204946;
    color: white;
}

/* Main Content */
.main-content {
    display: flex;
    flex: 1;
    gap: 1rem;
    padding: 1rem;
}

/* Sidebar */
.sidebar {
    width: 320px;
    background: white;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    height: fit-content;
    position: sticky;
    top: 1rem;
}

.sidebar h3 {
    color: #204946;
    margin-bottom: 1rem;
    font-size: 1.2rem;
    border-bottom: 2px solid #eee;
    padding-bottom: 0.5rem;
}

.session-info, .agents-info, .system-info {
    margin-bottom: 2rem;
}

.session-info p {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

#session-details {
    background: #f8f9fa;
    padding: 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
}

/* Agent Cards */
.agent-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.agent-card h4 {
    color: #204946;
    margin-bottom: 0.5rem;
}

.agent-card p {
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

.capabilities ul {
    list-style: none;
    padding-left: 0;
}

.capabilities li {
    background: #d4f1e9;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    margin: 0.2rem 0;
    font-size: 0.8rem;
}

/* Chat Area */
.chat-area {
    flex: 1;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
}

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

.chat-header h2 {
    color: #204946;
    font-size: 1.5rem;
}

.chat-actions {
    display: flex;
    gap: 0.5rem;
}

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem 1.5rem;
    background: #fafafa;
}

.message {
    margin-bottom: 1rem;
    max-width: 80%;
    animation: fadeIn 0.3s ease-in;
}

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

.user-message {
    margin-left: auto;
    text-align: right;
}

.assistant-message {
    margin-right: auto;
}

.system-message {
    margin: 0 auto;
    text-align: center;
    max-width: 60%;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 8px;
    font-size: 0.8rem;
}

.error-message {
    margin: 0 auto;
    text-align: center;
    max-width: 60%;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    font-size: 0.8rem;
}

.typing-indicator {
    margin: 0 auto;
    text-align: center;
    max-width: 60%;
    background: #e3f2fd;
    border: 1px solid #bbdefb;
    border-radius: 8px;
    font-style: italic;
    font-size: 0.8rem;
}

.message-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.message-role {
    font-weight: bold;
    color: #204946;
    font-size: 0.9rem;
}

.message-time {
    font-size: 0.8rem;
    color: #666;
}

.message-content {
    background: white;
    padding: 1rem;
    border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    word-wrap: break-word;
    word-break: break-word;
    overflow-wrap: break-word;
    hyphens: auto;
    font-size: 0.85rem;
    line-height: 1.4;
}

.user-message .message-content {
    background: #204946;
    color: white;
    margin-left: auto;
}

.assistant-message .message-content {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
}

/* Input Area */
.input-area {
    padding: 1rem 1.5rem;
    border-top: 1px solid #eee;
    background: white;
}

.input-container {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

#message-input {
    flex: 1;
    padding: 0.8rem;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 1rem;
    resize: vertical;
    min-height: 60px;
    transition: border-color 0.3s ease;
}

#message-input:focus {
    outline: none;
    border-color: #204946;
}

#message-input:disabled {
    background: #f8f9fa;
    cursor: not-allowed;
}

.input-actions {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
}

.status-indicator {
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
}

.status-indicator.connected {
    background: #d4f1e9;
    color: #204946;
}

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

/* Buttons */
.btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 500;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn-primary {
    background: #204946;
    color: white;
}

.btn-primary:hover {
    background: #1a3836;
    transform: translateY(-1px);
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-1px);
}

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    animation: fadeIn 0.3s ease-in;
}

.modal-content {
    background-color: white;
    margin: 5% auto;
    padding: 0;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from { transform: translateY(-50px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

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

.modal-header h3 {
    color: #204946;
    margin: 0;
}

.close-btn {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #666;
    padding: 0;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.3s ease;
}

.close-btn:hover {
    background: #f8f9fa;
    color: #333;
}

.modal-body {
    padding: 1.5rem;
}

.feedback-options {
    margin: 1rem 0;
}

.feedback-option {
    display: block;
    margin: 0.5rem 0;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background-color 0.3s ease;
}

.feedback-option:hover {
    background: #f8f9fa;
}

.feedback-option input {
    margin-right: 0.5rem;
}

#feedback-text-response {
    width: 100%;
    padding: 0.8rem;
    border: 2px solid #e9ecef;
    border-radius: 6px;
    font-size: 1rem;
    resize: vertical;
    min-height: 80px;
}

.feedback-actions {
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 1rem;
}

/* Session Cards */
.session-card {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.session-card h4 {
    color: #204946;
    margin-bottom: 0.5rem;
    font-size: 1rem;
}

.session-card p {
    margin-bottom: 0.3rem;
    font-size: 0.9rem;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        position: static;
        margin-bottom: 1rem;
    }
    
    .chat-area {
        height: 60vh;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 0.5rem;
    }
    
    .header {
        padding: 1rem;
    }
    
    .header h1 {
        font-size: 1.5rem;
    }
    
    .main-content {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .sidebar {
        padding: 1rem;
    }
    
    .chat-header {
        flex-direction: column;
        gap: 1rem;
        align-items: flex-start;
    }
    
    .chat-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .message {
        max-width: 90%;
    }
    
    .input-container {
        flex-direction: column;
    }
    
    .btn {
        padding: 0.6rem 1rem;
        font-size: 0.9rem;
    }
    
    .modal-content {
        width: 95%;
        margin: 10% auto;
    }
}

@media (max-width: 480px) {
    .header h1 {
        font-size: 1.2rem;
    }
    
    .header p {
        font-size: 1rem;
    }
    
    .sidebar {
        padding: 0.8rem;
    }
    
    .chat-messages {
        padding: 0.8rem;
    }
    
    .input-area {
        padding: 0.8rem;
    }
    
    .modal-body {
        padding: 1rem;
    }
    
    .message {
        max-width: 95%;
    }
}

/* Scrollbar Styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Loading Animation */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #204946;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Utility Classes */
.text-center {
    text-align: center;
}

.text-muted {
    color: #666;
}

.mb-1 {
    margin-bottom: 0.5rem;
}

.mb-2 {
    margin-bottom: 1rem;
}

.mb-3 {
    margin-bottom: 1.5rem;
}

/* Data Table Styles */
.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 10px 0;
    font-size: 14px;
}

/* Key Icon Styles */
.key-icon {
    display: inline-block;
    width: 18px;
    height: 18px;
    margin-right: 6px;
    text-align: center;
    font-size: 14px;
    line-height: 18px;
    vertical-align: middle;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.1));
    transition: transform 0.2s ease;
}

.key-icon:hover {
    transform: scale(1.1);
}

/* Different icon colors for different categories */
.key-icon.user-icon { color: #2196F3; }
.key-icon.market-icon { color: #4CAF50; }
.key-icon.decision-icon { color: #FF9800; }
.key-icon.recommend-icon { color: #9C27B0; }
.key-icon.analysis-icon { color: #607D8B; }
.key-icon.time-icon { color: #795548; }
.key-icon.system-icon { color: #F44336; }
.key-icon.agent-icon { color: #00BCD4; }
.key-icon.default-icon { color: #9E9E9E; }

.data-table td {
    padding: 6px 8px;
    border: 1px solid #e0e0e0;
    vertical-align: top;
}

.data-table .key-cell {
    background-color: #f8f9fa;
    font-weight: 600;
    color: #495057;
    width: 30%;
    word-break: break-word;
}

.data-table .value-cell {
    background-color: #ffffff;
    color: #212529;
    word-break: break-word;
}

/* Agent Info Compact Display */
.agent-info-key {
    background-color: #e3f2fd !important;
    color: #1565c0 !important;
    font-size: 12px;
    position: relative;
    padding-left: 25px !important;
}

.agent-info-key::before {
    content: "🤖";
    position: absolute;
    left: 5px;
    top: 50%;
    transform: translateY(-50%);
}

.agent-info-value {
    background-color: #f3e5f5 !important;
    color: #6a1b9a !important;
    font-size: 12px;
    font-family: 'Courier New', monospace;
}

/* Compact value indicators */
.data-table .null-value {
    color: #6c757d;
    font-style: italic;
}

.data-table .string-value {
    color: #0d6efd;
}

.data-table .number-value {
    color: #198754;
    font-weight: 600;
}

.data-table .boolean-value {
    color: #dc3545;
    font-weight: 600;
}

.data-table .array-value {
    color: #fd7e14;
    font-family: 'Courier New', monospace;
}

/* Indentation for nested items */
.indent-1 {
    padding-left: 20px !important;
}

.indent-2 {
    padding-left: 40px !important;
}