:root {
    /* Dark Theme (Default) */
    --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --secondary-gradient: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    --bg-primary: #0a0a0f;
    --bg-secondary: #151520;
    --bg-tertiary: #1e1e2d;
    --bg-sidebar: #11111a;
    --bg-input: #1a1a2e;
    --text-primary: #f0f0f5;
    --text-secondary: #a0a0c0;
    --text-tertiary: #7a7a9a;
    --border-color: #2a2a3a;
    --border-light: #3a3a4a;
    --accent-primary: #6366f1;
    --accent-secondary: #8b5cf6;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --error-color: #ef4444;
    --info-color: #3b82f6;
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.2);
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.15);
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

[data-theme="light"] {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-tertiary: #f1f5f9;
    --bg-sidebar: #ffffff;
    --bg-input: #ffffff;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-tertiary: #94a3b8;
    --border-color: #e2e8f0;
    --border-light: #cbd5e1;
    --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.08);
    --shadow-md: 0 10px 30px rgba(0, 0, 0, 0.05);
    --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.03);
}

/* Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
    transition: background-color var(--transition-normal);
}

/* Layout */
body {
    display: flex;
}

.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 1000;
    background: var(--bg-tertiary);
    border: none;
    color: var(--text-primary);
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-sm);
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-sidebar);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    transition: transform var(--transition-normal);
    z-index: 100;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
}

.logo-text h2 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 4px;
}

.logo-text p {
    font-size: 12px;
    color: var(--text-tertiary);
    font-weight: 500;
}

.new-chat-btn {
    width: 100%;
    padding: 14px 20px;
    background: var(--primary-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: transform var(--transition-fast);
}

.new-chat-btn:hover {
    transform: translateY(-2px);
}

.chat-history {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.history-title {
    font-size: 12px;
    text-transform: uppercase;
    color: var(--text-tertiary);
    letter-spacing: 1px;
    margin-bottom: 16px;
    font-weight: 600;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.history-item {
    padding: 12px 16px;
    background: transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all var(--transition-fast);
}

.history-item:hover {
    background: var(--bg-tertiary);
}

.history-item.active {
    background: var(--accent-primary);
    color: white;
}

.history-icon {
    font-size: 14px;
    opacity: 0.7;
}

.history-text {
    flex: 1;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 40px;
    height: 40px;
    background: var(--bg-tertiary);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
}

.user-info .username {
    font-weight: 600;
    font-size: 14px;
    margin-bottom: 2px;
}

.user-info .user-status {
    font-size: 12px;
    color: var(--text-tertiary);
}

.settings-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.settings-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background: var(--bg-primary);
}

.main-header {
    padding: 20px 32px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-secondary);
}

.header-left h1 {
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 4px;
}

.chat-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
}

.header-actions {
    display: flex;
    gap: 8px;
}

.header-btn {
    width: 44px;
    height: 44px;
    background: var(--bg-tertiary);
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.header-btn:hover {
    background: var(--accent-primary);
    color: white;
    transform: translateY(-2px);
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.welcome-section {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.welcome-card {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 48px;
    max-width: 600px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: var(--primary-gradient);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 24px;
    font-size: 32px;
    color: white;
}

.welcome-card h2 {
    font-size: 28px;
    margin-bottom: 12px;
    font-weight: 700;
}

.welcome-card p {
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-size: 16px;
}

.quick-questions {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-top: 24px;
}

.quick-btn {
    padding: 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

.quick-btn:hover {
    background: var(--accent-primary);
    color: white;
    transform: translateY(-2px);
    border-color: var(--accent-primary);
}

/* Message Bubbles */
.message {
    display: flex;
    max-width: 85%;
    animation: messageAppear 0.3s ease-out;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-user {
    align-self: flex-end;
}

.message-ai {
    align-self: flex-start;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    margin-top: 4px;
    flex-shrink: 0;
}

.message-user .message-avatar {
    background: var(--secondary-gradient);
    color: white;
}

.message-ai .message-avatar {
    background: var(--primary-gradient);
    color: white;
}

.message-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    padding: 20px;
    position: relative;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.message-user .message-content {
    background: var(--accent-primary);
    color: white;
    border-top-right-radius: 4px;
}

.message-ai .message-content {
    border-top-left-radius: 4px;
}

.message-text {
    font-size: 15px;
    line-height: 1.7;
}

.message-text pre {
    background: var(--bg-primary);
    padding: 16px;
    border-radius: var(--radius-md);
    overflow-x: auto;
    margin: 12px 0;
    border: 1px solid var(--border-color);
}

.message-text code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.9em;
    color: var(--accent-secondary);
}

.message-text p {
    margin-bottom: 12px;
}

.message-text p:last-child {
    margin-bottom: 0;
}

.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.message-content:hover .message-actions {
    opacity: 1;
}

.message-action-btn {
    background: var(--bg-tertiary);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.message-action-btn:hover {
    background: var(--accent-primary);
    color: white;
}

.message-timestamp {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 8px;
    display: block;
}

/* Input Area */
.input-area {
    padding: 20px 32px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.input-container {
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px 20px;
    display: flex;
    align-items: flex-end;
    gap: 16px;
    transition: all var(--transition-fast);
}

.input-container:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.input-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.action-btn {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.action-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.text-input-wrapper {
    flex: 1;
    position: relative;
}

textarea {
    width: 100%;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-family: 'Inter', sans-serif;
    font-size: 15px;
    resize: none;
    outline: none;
    padding: 8px 0;
    min-height: 24px;
    max-height: 150px;
    line-height: 1.5;
}

textarea::placeholder {
    color: var(--text-tertiary);
}

.input-indicators {
    position: absolute;
    right: 0;
    bottom: -20px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.send-container {
    align-self: flex-end;
}

.send-btn {
    width: 48px;
    height: 48px;
    background: var(--primary-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.send-btn:hover {
    transform: translateY(-2px) scale(1.05);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 12px;
}

.disclaimer {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.disclaimer i {
    color: var(--success-color);
}

.model-info {
    display: flex;
    gap: 8px;
}

.model-tag {
    background: var(--bg-tertiary);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Typing Indicator */
.typing-indicator {
    display: none;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    margin: 0 32px 24px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.typing-indicator.active {
    display: flex;
}

.typing-dots {
    display: flex;
    gap: 4px;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
    }

    30% {
        transform: translateY(-6px);
    }
}

/* Toast Notification */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--success-color);
    color: white;
    padding: 16px 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: all var(--transition-normal);
    z-index: 1000;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-secondary);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    transition: color var(--transition-fast);
}

.modal-close:hover {
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.setting-group {
    margin-bottom: 32px;
}

.setting-group h4 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-tertiary);
    margin-bottom: 16px;
    font-weight: 600;
}

.theme-selector {
    display: flex;
    gap: 12px;
}

.theme-option {
    flex: 1;
    background: var(--bg-tertiary);
    border: 2px solid transparent;
    border-radius: var(--radius-md);
    padding: 16px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.theme-option.active {
    border-color: var(--accent-primary);
    background: var(--bg-secondary);
}

.theme-preview {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-sm);
}

.theme-preview.dark {
    background: linear-gradient(135deg, #0a0a0f 0%, #1e1e2d 100%);
}

.theme-preview.light {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
}

.theme-preview.auto {
    background: linear-gradient(45deg, #f8fafc 50%, #0a0a0f 50%);
}

.slider-container {
    margin-bottom: 24px;
}

.slider-container label {
    display: block;
    margin-bottom: 12px;
    font-weight: 500;
}

.slider-container input[type="range"] {
    width: 100%;
    height: 6px;
    background: var(--bg-tertiary);
    border-radius: 3px;
    outline: none;
    -webkit-appearance: none;
}

.slider-container input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 20px;
    height: 20px;
    background: var(--accent-primary);
    border-radius: 50%;
    cursor: pointer;
}

.slider-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 8px;
    font-size: 12px;
    color: var(--text-tertiary);
}

.setting-btn {
    width: 100%;
    padding: 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.setting-btn:hover {
    background: var(--error-color);
    color: white;
    border-color: var(--error-color);
}

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: var(--text-tertiary);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Responsive Design */
@media (max-width: 1024px) {
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100%;
    }

    .sidebar.active {
        left: 0;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .main-content {
        width: 100%;
    }

    .quick-questions {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    .main-header {
        padding: 16px;
    }

    .chat-container {
        padding: 16px;
    }

    .input-area {
        padding: 16px;
    }

    .welcome-card {
        padding: 32px 24px;
    }

    .message {
        max-width: 95%;
    }
}