/* Spain Education Research Assistant - Modern Neutral Styling */

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

:root {
    /* Neutral Modern Color Palette */
    --primary-color: #2563eb;        /* Clean blue */
    --primary-hover: #1d4ed8;        /* Darker blue */
    --secondary-color: #64748b;      /* Slate gray */
    --accent-color: #0ea5e9;         /* Sky blue */
    
    /* Background Colors */
    --bg-primary: #ffffff;           /* Pure white */
    --bg-secondary: #f8fafc;         /* Light gray */
    --bg-tertiary: #f1f5f9;          /* Slightly darker gray */
    --bg-accent: linear-gradient(135deg, #e0f2fe 0%, #f0f9ff 100%);
    
    /* Text Colors */
    --text-primary: #1e293b;         /* Dark slate */
    --text-secondary: #475569;       /* Medium slate */
    --text-muted: #94a3b8;           /* Light slate */
    --text-inverse: #ffffff;         /* White */
    
    /* Border Colors */
    --border-light: #e2e8f0;         /* Light border */
    --border-medium: #cbd5e1;        /* Medium border */
    --border-dark: #94a3b8;          /* Dark border */
    
    /* Status Colors */
    --success-color: #10b981;        /* Green */
    --warning-color: #f59e0b;        /* Amber */
    --error-color: #ef4444;          /* Red */
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'Monaco', 'Menlo', 'Consolas', monospace;
}

body {
    font-family: var(--font-family);
    background: var(--bg-accent);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow: hidden;
}

/* Main Container */
.container {
    display: flex;
    height: 100vh;
    gap: 1px;
}

/* Chat Panel - Main Left Area */
.chat-panel {
    flex: 2;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
    border-radius: 16px 0 0 0;
    box-shadow: var(--shadow-lg);
    min-width: 500px;
    overflow: hidden;
}

/* Chat Header */
.chat-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    color: var(--text-inverse);
    padding: 24px;
    position: relative;
}

.header-content {
    margin-bottom: 16px;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 8px;
}

.header-title .material-icons {
    font-size: 32px;
}

.header-title h1 {
    font-size: 28px;
    font-weight: 700;
    margin: 0;
}

.header-subtitle {
    font-size: 16px;
    opacity: 0.9;
    font-weight: 400;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

.status-indicator {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--error-color);
    transition: background-color 0.3s ease;
}

.status-indicator.connected {
    background: var(--success-color);
}

.status-indicator.connecting {
    background: var(--warning-color);
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}


/* Quick Start Section */
.quick-start-section {
    background: var(--bg-tertiary);
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-light);
}

.section-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 16px;
}

.template-buttons {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 12px;
}

.template-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    background: var(--bg-primary);
    border: 1px solid var(--border-medium);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
    color: var(--text-primary);
    text-align: left;
}

.template-btn:hover {
    background: var(--primary-color);
    color: var(--text-inverse);
    border-color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.template-btn .material-icons {
    font-size: 20px;
    flex-shrink: 0;
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    background: var(--bg-secondary);
}

.welcome-message {
    margin-bottom: 24px;
}

.message {
    margin-bottom: 20px;
    animation: fadeInUp 0.4s ease;
}

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

.message-content {
    display: flex;
    gap: 12px;
    align-items: flex-start;
}

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

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-inverse);
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--secondary-color);
}

.message-bubble {
    max-width: 80%;
    padding: 16px 20px;
    border-radius: 20px;
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-sm);
}

.message.user .message-bubble {
    background: var(--primary-color);
    color: var(--text-inverse);
    border-color: var(--primary-color);
}

.message-bubble p {
    margin-bottom: 12px;
}

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

.message-bubble ul {
    margin: 12px 0;
    padding-left: 20px;
}

.message-bubble li {
    margin-bottom: 8px;
}

/* Input Area */
.input-area {
    background: var(--bg-primary);
    padding: 24px;
    border-top: 1px solid var(--border-light);
}

.config-section {
    background: var(--bg-secondary);
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 16px;
}

.config-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.config-row label {
    font-weight: 500;
    color: var(--text-secondary);
    min-width: 100px;
}

.config-row input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    font-size: 14px;
    background: var(--bg-primary);
    transition: border-color 0.2s ease;
}

.config-row input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

/* Export Section */
.export-section {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 16px;
    border: 1px solid var(--border-medium);
}

.export-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    font-size: 14px;
}

.beta-badge {
    background: var(--warning-color);
    color: var(--text-inverse);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
    margin-left: auto;
}

.export-buttons {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.export-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border-medium);
    border-radius: 8px;
    cursor: not-allowed;
    font-size: 12px;
    color: var(--text-muted);
    transition: all 0.2s ease;
}

.export-btn:disabled {
    opacity: 0.6;
}

.export-btn .material-icons {
    font-size: 16px;
}

.message-input-container {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.message-input {
    flex: 1;
    padding: 16px 20px;
    border: 2px solid var(--border-medium);
    border-radius: 24px;
    font-size: 16px;
    font-family: var(--font-family);
    resize: none;
    min-height: 56px;
    max-height: 120px;
    background: var(--bg-primary);
    transition: border-color 0.2s ease;
}

.message-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgb(37 99 235 / 0.1);
}

.send-button {
    display: flex;
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--accent-color) 100%);
    color: var(--text-inverse);
    border: none;
    padding: 16px 24px;
    border-radius: 24px;
    cursor: pointer;
    font-weight: 600;
    font-size: 16px;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
    min-height: 56px;
}

.send-button:hover:not(:disabled) {
    background: linear-gradient(135deg, var(--primary-hover) 0%, var(--primary-color) 100%);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.send-button:disabled {
    background: var(--border-medium);
    cursor: not-allowed;
    transform: none;
}

.send-button .material-icons {
    font-size: 20px;
}

/* Context Panel - Right Sidebar */
.context-panel {
    flex: 1;
    min-width: 350px;
    max-width: 400px;
    background: var(--bg-primary);
    border-radius: 0 16px 16px 0;
    display: flex;
    flex-direction: column;
    border-left: 1px solid var(--border-light);
    box-shadow: var(--shadow-lg);
}

.panel-header {
    background: var(--text-primary);
    color: var(--text-inverse);
    padding: 20px;
    font-weight: 600;
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.context-section {
    padding: 20px;
    border-bottom: 1px solid var(--border-light);
}

.context-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    font-size: 14px;
}

.dataset-status, .tool-status {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.dataset-item, .tool-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-size: 14px;
}

.dataset-name {
    font-weight: 500;
}

.dataset-count {
    background: var(--primary-color);
    color: var(--text-inverse);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.tool-item {
    gap: 8px;
}

.tool-status-indicator {
    background: var(--success-color);
    color: var(--text-inverse);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.activity-log {
    max-height: 200px;
    overflow-y: auto;
}

.activity-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    margin-bottom: 8px;
    font-size: 13px;
}

.activity-time {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 12px;
}

.activity-desc {
    color: var(--text-primary);
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-overlay.active {
    display: flex;
}

.loading-content {
    background: var(--bg-primary);
    padding: 32px;
    border-radius: 16px;
    text-align: center;
    box-shadow: var(--shadow-lg);
}

.loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-light);
    border-left: 4px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 16px;
}

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

/* Responsive Design */
@media (max-width: 1200px) {
    .context-panel {
        min-width: 300px;
        max-width: 320px;
    }
}

@media (max-width: 768px) {
    .container {
        flex-direction: column;
    }
    
    .chat-panel {
        border-radius: 0;
        min-width: unset;
    }
    
    .context-panel {
        border-radius: 0;
        min-width: unset;
        max-width: unset;
        max-height: 300px;
        border-left: none;
        border-top: 1px solid var(--border-light);
    }
    
    .template-buttons {
        grid-template-columns: 1fr;
    }
    
    .message-input-container {
        flex-direction: column;
        align-items: stretch;
    }
    
    .send-button {
        align-self: flex-end;
        width: auto;
    }
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-secondary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-medium);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--border-dark);
}

/* Utilities */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Data visualization helpers */
.data-card {
    background: var(--bg-primary);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 16px;
    margin: 12px 0;
    box-shadow: var(--shadow-sm);
}

.data-card-header {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 14px;
}

.data-table th,
.data-table td {
    padding: 8px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border-light);
}

.data-table th {
    background: var(--bg-secondary);
    font-weight: 600;
    color: var(--text-primary);
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
    margin: 12px 0;
}

.stat-item {
    text-align: center;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
}

.stat-number {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary-color);
    display: block;
}

.stat-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
