:root {
    /* Light Theme Colors - Supabase Style */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f1f3f5;
    --bg-hover: #e9ecef;
    --bg-input: #ffffff;
    
    --text-primary: #1a1a1a;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    
    --border-primary: #e5e7eb;
    --border-secondary: #d1d5db;
    
    --accent-primary: #3ecf8e;
    --accent-hover: #2fb57a;
    --accent-light: #e6f9f3;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 12px;
    
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

[data-theme="dark"] {
    /* Dark Theme Colors - Supabase Style */
    --bg-primary: #1a1a1a;
    --bg-secondary: #242424;
    --bg-tertiary: #2e2e2e;
    --bg-hover: #363636;
    --bg-input: #2e2e2e;
    
    --text-primary: #f9fafb;
    --text-secondary: #9ca3af;
    --text-tertiary: #6b7280;
    
    --border-primary: #363636;
    --border-secondary: #4b5563;
    
    --accent-primary: #3ecf8e;
    --accent-hover: #4dd99d;
    --accent-light: #1a3329;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.4), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -2px rgba(0, 0, 0, 0.4);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    background-color: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    transition: var(--transition);
}

.container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Header */
.header {
    background-color: var(--bg-primary);
    border-bottom: 1px solid var(--border-primary);
    padding: 0 24px;
    height: 60px;
    display: flex;
    align-items: center;
    z-index: 100;
}

.header-content {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-primary);
    font-size: 18px;
    font-weight: 600;
}

.logo svg {
    color: var(--accent-primary);
}

.logo-text {
    font-weight: 600;
}

.theme-toggle {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-primary);
}

.theme-toggle:hover {
    background: var(--bg-hover);
}

.theme-toggle .moon-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .sun-icon {
    display: none;
}

[data-theme="dark"] .theme-toggle .moon-icon {
    display: block;
}

/* Main Chat Container */
.chat-container {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-primary);
}

.sidebar-header h2 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 12px;
}

.new-chat-btn {
    width: 100%;
    padding: 10px 16px;
    background: var(--accent-primary);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.new-chat-btn:hover {
    background: var(--accent-hover);
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 12px;
}

.chat-history-item {
    padding: 12px;
    margin-bottom: 4px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-secondary);
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-history-item:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.chat-history-item.active {
    background: var(--accent-light);
    color: var(--accent-primary);
}

/* Chat Area */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

/* Welcome Screen */
.welcome-screen {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    z-index: 1;
    background: var(--bg-primary);
    transition: var(--transition);
}

.welcome-screen.hidden {
    opacity: 0;
    pointer-events: none;
}

.welcome-content {
    max-width: 800px;
    text-align: center;
}

.welcome-content h1 {
    font-size: 48px;
    font-weight: 700;
    margin-bottom: 16px;
    background: linear-gradient(135deg, var(--accent-primary) 0%, #2fb57a 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-content p {
    font-size: 18px;
    color: var(--text-secondary);
    margin-bottom: 40px;
}

.suggestion-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-top: 32px;
}

.suggestion-card {
    padding: 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 12px;
    text-align: left;
}

.suggestion-card:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.suggestion-card svg {
    color: var(--accent-primary);
    flex-shrink: 0;
}

.suggestion-card span {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

/* Messages Container */
.messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.message {
    display: flex;
    gap: 16px;
    animation: fadeIn 0.3s ease-in;
}

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

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-weight: 600;
    font-size: 14px;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.message.assistant .message-avatar {
    background: var(--accent-light);
    color: var(--accent-primary);
}

.message-content {
    flex: 1;
    max-width: 800px;
}

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

.message-author {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.message-time {
    font-size: 12px;
    color: var(--text-tertiary);
}

.message-text {
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.7;
    word-wrap: break-word;
}

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

.message-text code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.message-text pre {
    background: var(--bg-tertiary);
    padding: 16px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 12px 0;
}

.message-text pre code {
    background: none;
    padding: 0;
}

/* Table Styling */
.table-wrapper {
    overflow-x: auto;
    margin: 16px 0;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-primary);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: var(--bg-secondary);
}

.data-table thead {
    background: var(--bg-tertiary);
    border-bottom: 2px solid var(--border-secondary);
}

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.data-table td {
    padding: 10px 16px;
    border-top: 1px solid var(--border-primary);
    color: var(--text-primary);
}

.data-table tbody tr {
    transition: var(--transition);
}

.data-table tbody tr:hover {
    background: var(--bg-hover);
}

.data-table tbody tr:nth-child(even) {
    background: var(--bg-primary);
}

.data-table tbody tr:nth-child(even):hover {
    background: var(--bg-hover);
}

/* Responsive table scrolling */
@media (max-width: 768px) {
    .table-wrapper {
        -webkit-overflow-scrolling: touch;
    }
    
    .data-table {
        font-size: 13px;
    }
    
    .data-table th,
    .data-table td {
        padding: 8px 12px;
    }
}

/* Loading Animation */
.loading-dots {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--accent-primary);
    animation: bounce 1.4s infinite ease-in-out;
}

.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.6);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Streaming cursor animation */
.cursor {
    display: inline-block;
    color: var(--accent-primary);
    animation: blink 1s infinite;
    margin-left: 2px;
}

@keyframes blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

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

.input-form {
    display: flex;
    gap: 12px;
    align-items: flex-end;
    background: var(--bg-input);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    padding: 12px;
    transition: var(--transition);
}

.input-form:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.message-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 15px;
    font-family: inherit;
    resize: none;
    max-height: 80px;
    line-height: 1.5;
}

.message-input::placeholder {
    color: var(--text-tertiary);
}

.send-btn {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    border: none;
    background: var(--accent-primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.input-footer {
    margin-top: 12px;
    text-align: center;
}

.footer-text {
    font-size: 12px;
    color: var(--text-tertiary);
}

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

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

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 60px;
        height: calc(100vh - 60px);
        z-index: 99;
        transition: var(--transition);
    }

    .sidebar.open {
        left: 0;
    }

    .chat-container {
        width: 100%;
    }

    .welcome-content h1 {
        font-size: 32px;
    }

    .suggestion-cards {
        grid-template-columns: 1fr;
    }

    .messages {
        padding: 16px;
    }

    .input-area {
        padding: 16px;
    }
}

/* Chart Styles */
.message canvas {
    max-width: 100%;
    height: auto;
    margin: 10px 0;
    border-radius: var(--radius-md);
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
}

@media (max-width: 480px) {
    .header {
        padding: 0 16px;
    }

    .logo-text {
        display: none;
    }

    .message-text {
        font-size: 14px;
    }
}
