* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    /* Base Colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #e9ecef;
    --bg-hover: #f1f3f5;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --text-tertiary: #adb5bd;
    --border-color: #dee2e6;
    
    /* Accent Colors (changed dynamically) */
    --accent-color: #0066ff;
    --accent-hover: #0052cc;
    --accent-light: #e6f0ff;
    --accent-dark: #004099;
    
    /* Status Colors */
    --danger-color: #dc3545;
    --danger-hover: #c82333;
    --success-color: #28a745;
    
    /* Message Backgrounds */
    --user-msg-bg: #f0f4ff;
    --assistant-msg-bg: transparent;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    
    /* Radius & Layout */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --header-height: 60px;
}

[data-theme="dark"] {
    /* Base Colors - Dark */
    --bg-primary: #1a1d21;
    --bg-secondary: #22262b;
    --bg-tertiary: #2c3137;
    --bg-hover: #363b42;
    --text-primary: #e9ecef;
    --text-secondary: #adb5bd;
    --text-tertiary: #6c757d;
    --border-color: #343a40;
    
    /* Message Backgrounds - Dark */
    --user-msg-bg: #1a2332;
    --assistant-msg-bg: transparent;
    
    /* Shadows - Dark */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.4);
}

body {
    font-family: "Poppins-Vazirmatn";
    font-weight: 300;
    /* font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif; */
    background: var(--bg-primary);
    color: var(--text-primary);
    overflow: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
    line-height: 1.6;
}

button, input, textarea, select {
    font-family: "Poppins-Vazirmatn";
}

.app-container {
    display: grid;
    grid-template-columns: 260px 1fr;
    grid-template-rows: var(--header-height) 1fr;
    height: 100vh;
    width: 100%;
}

/* Top Header */
.top-header {
    grid-column: 1 / -1;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.mobile-toggle {
    display: none;
}

.app-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Sidebar */
.sidebar {
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
}

.search-container {
    position: relative;
    display: flex;
    align-items: center;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 8px 12px;
    margin-bottom: 12px;
}

.search-icon {
    color: var(--text-secondary);
    margin-right: 8px;
    flex-shrink: 0;
}

.search-input {
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    width: 100%;
    outline: none;
}

.search-input::placeholder {
    color: var(--text-tertiary);
}

.sidebar-actions {
    padding: 16px 16px;
    display: flex;
    gap: 8px;
    border-bottom: 1px solid var(--border-color);
}

.btn-new-chat {
    flex: 1;
    padding: 12px 16px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: var(--transition);
}

.btn-new-chat:hover {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-import {
    width: 44px;
    height: 44px;
    padding: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-history-item {
    position: relative;
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
    background: transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
}

.chat-history-item:hover {
    background: var(--bg-hover);
}

.chat-history-item.active {
    background: var(--bg-tertiary);
}

.chat-history-item-content {
    flex: 1;
    min-width: 0;
}

.chat-history-item-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-primary);
}

.chat-history-item-date {
    font-size: 12px;
    color: var(--text-secondary);
}

.chat-more-btn {
    opacity: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.chat-history-item:hover .chat-more-btn {
    opacity: 1;
}

.chat-more-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.chat-history-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

/* Main Content */
.main-content {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg-primary);
    min-height: 0; /* Fix for flex children */
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0; /* Fix for flex children */
}

.welcome-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 40px 20px;
}

.welcome-content {
    text-align: center;
    max-width: 500px;
}

.welcome-icon {
    margin-bottom: 24px;
    color: var(--accent-color);
    opacity: 0.8;
}

.welcome-content h2 {
    font-size: 28px;
    margin-bottom: 12px;
    font-weight: 600;
}

.welcome-content p {
    color: var(--text-secondary);
    font-size: 16px;
    line-height: 1.5;
}

/* Messages - ChatGPT Style */
.messages {
    padding: 0;
    width: 100%;
}

.message {
    padding: 24px 20px;
    opacity: 0;
    animation: messageSlideIn 0.3s ease forwards;
    width: 100%;
    border-bottom: 1px solid var(--border-color);
}

.message.user {
    background: var(--bg-secondary);
}

.message.assistant {
    background: var(--bg-primary);
}

@keyframes messageSlideIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.message-avatar {
    width: 30px;
    height: 30px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 13px;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--accent-color);
    color: white;
}

.message.assistant .message-avatar {
    background: #10a37f;
    color: white;
}

.message-role {
    font-weight: 600;
    font-size: 14px;
    color: var(--text-primary);
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.message-timestamp {
    font-size: 12px;
    color: var(--text-tertiary);
    cursor: default;
}

/* Edit Button - Modern & Clean */
.btn-edit-message {
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s ease;
}

.message:hover .btn-edit-message {
    opacity: 1;
}

.btn-edit-message:hover {
    background: var(--bg-hover);
    color: var(--accent-color);
    transform: scale(1.1);
}

.btn-edit-message svg {
    width: 14px;
    height: 14px;
}

/* Model Badge in Message */
.model-badge-message {
    font-size: 11px;
    padding: 2px 8px;
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border-radius: 10px;
    font-weight: 500;
    margin-inline-start: 10px;
}

.message-content {
    line-height: 1.75;
    font-size: 16px;
    max-width: 800px;
    margin: 0 auto;
    color: var(--text-primary);
}

.message.user .message-content {
    padding: 0;
    background: none;
}

.message-content > .code-block-wrapper:first-child {
    margin-top: 0;
}

.message-content > .code-block-wrapper:last-child {
    margin-bottom: 0;
}

.message-image {
    margin-top: 12px;
    max-width: 400px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
}

/* Code Blocks - Clean & Modern */
.code-block-wrapper {
    position: relative;
    margin: 16px 0;
}

.code-block-wrapper pre {
    margin: 0;
    border-radius: 8px;
    overflow: hidden;
    background: #282c34;
}

.code-block-wrapper pre code {
    display: block;
    padding: 16px;
    overflow-x: auto;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre;
    color: #abb2bf;
    direction: ltr;
    text-align: left;
}

/* Copy Button - Fixed Position, Minimal */
.copy-code-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    padding: 0;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 6px;
    color: #abb2bf;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all 0.2s ease;
    z-index: 10;
}

.code-block-wrapper:hover .copy-code-btn {
    opacity: 1;
}

.copy-code-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.copy-code-btn svg {
    width: 14px;
    height: 14px;
}

/* Inline Code */
code.inline-code {
    background: var(--bg-tertiary);
    color: #eb5757;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
    font-weight: 500;
}

.message-content p {
    margin: 8px 0;
}

.message-content p:first-child {
    margin-top: 0;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content strong {
    font-weight: 600;
    color: var(--text-primary);
}

.message-content em {
    font-style: italic;
}

.message-content a {
    color: var(--accent-color);
    text-decoration: none;
    transition: var(--transition);
}

.message-content a:hover {
    text-decoration: underline;
    color: var(--accent-hover);
}

/* Prism.js handles syntax highlighting now */

/* Input Area */
.input-area {
    padding: 10px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
}

.input-wrapper {
    max-width: 800px;
    margin: 0 auto;
}

.model-selector-container {
    margin-bottom: 12px;
}

.select-model {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-primary);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    transition: var(--transition);
    font-weight: 500;
}

.select-model:hover {
    border-color: var(--accent-color);
}

.select-model:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

.image-preview {
    margin-bottom: 12px;
    position: relative;
    display: inline-block;
}

.image-preview img {
    max-width: 200px;
    max-height: 200px;
    border-radius: var(--radius-sm);
    border: 2px solid var(--border-color);
}

.btn-remove-image {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--danger-color);
    color: white;
    border: 2px solid var(--bg-secondary);
    cursor: pointer;
    font-size: 16px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-remove-image:hover {
    background: var(--danger-hover);
}

.input-container {
    display: flex;
    gap: 10px;
    align-items: flex-end;
    background: var(--bg-primary);
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 8px;
    transition: var(--transition);
}

.input-container:focus-within {
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

#messageInput {
    flex: 1;
    padding: 8px 4px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 15px;
    resize: none;
    min-height: 24px;
    max-height: 200px;
    line-height: 1.5;
    overflow-y: auto;
}

#messageInput:focus {
    outline: none;
}

#messageInput::placeholder {
    color: var(--text-tertiary);
}

/* Buttons */
.btn-icon {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-icon.active {
    background: var(--accent-color);
    color: white;
}

.btn-send {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--accent-color);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-send:hover:not(:disabled) {
    background: var(--accent-hover);
    transform: translateY(-1px);
}

.btn-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-stop {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--danger-color);
    color: white;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    flex-shrink: 0;
}

.btn-stop:hover {
    background: var(--danger-hover);
    transform: translateY(-1px);
}

/* Scroll to Bottom Button */
.scroll-to-bottom {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--accent-color);
    color: white;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
    transition: var(--transition);
    z-index: 100;
}

.scroll-to-bottom:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

@media (max-width: 768px) {
    .scroll-to-bottom {
        bottom: 90px;
        right: 20px;
    }
}

.btn-primary {
    padding: 10px 20px;
    border-radius: var(--radius-sm);
    border: none;
    background: var(--accent-color);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary:hover {
    background: var(--accent-hover);
}

.btn-secondary {
    padding: 10px 16px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal.show {
    display: flex;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        transform: scale(0.95) translateY(-10px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
}

.btn-close {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
    transition: var(--transition);
}

.btn-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.form-group {
    margin-bottom: 20px;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 14px;
    transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

.form-group small {
    display: block;
    margin-top: 6px;
    color: var(--text-secondary);
    font-size: 12px;
}

/* Export Options */
.export-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 12px;
}

.export-option {
    padding: 20px 16px;
    border: 2px solid var(--border-color);
    border-radius: var(--radius-md);
    background: var(--bg-secondary);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
}

.export-option:hover {
    border-color: var(--accent-color);
    background: var(--bg-hover);
}

/* Context Menu */
.context-menu {
    position: fixed;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    min-width: 160px;
    z-index: 2000;
    overflow: hidden;
    animation: contextMenuSlideIn 0.15s ease;
}

@keyframes contextMenuSlideIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.context-menu-item {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    color: var(--text-primary);
    transition: var(--transition);
}

.context-menu-item:hover {
    background: var(--bg-hover);
}

.context-menu-item.danger {
    color: var(--danger-color);
}

.context-menu-item.danger:hover {
    background: var(--danger-color);
    color: white;
}

/* Thinking Mode */
.thinking-block {
    margin: 12px 0;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-left: 3px solid var(--accent-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.thinking-block:hover {
    background: var(--bg-hover);
}

.thinking-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.thinking-toggle {
    font-size: 12px;
    color: var(--accent-color);
}

.thinking-content {
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
    font-style: italic;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
}

.thinking-block.expanded .thinking-content {
    max-height: 1000px;
    margin-top: 8px;
}

.thinking-block.expanded .thinking-toggle::after {
    content: ' ▼';
}

.thinking-block:not(.expanded) .thinking-toggle::after {
    content: ' ▶';
}

/* Loading Animation */
.loading {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.loading::after {
    content: '';
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse 1.4s ease-in-out infinite;
}

@keyframes pulse {
    0%, 80%, 100% {
        opacity: 0.3;
    }
    40% {
        opacity: 1;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Responsive */
@media (max-width: 768px) {
    .app-container {
        grid-template-columns: 1fr;
        height: 100vh;
        height: 100dvh; /* Use dynamic viewport height on mobile */
    }

    .sidebar {
        position: fixed;
        left: -280px;
        height: calc(100vh - var(--header-height));
        height: calc(100dvh - var(--header-height));
        top: var(--header-height);
        width: 280px;
        z-index: 99;
        transition: left 0.3s ease;
    }

    .sidebar.open {
        left: 0;
    }

    .mobile-toggle {
        display: flex;
    }

    .welcome-content h2 {
        font-size: 24px;
    }

    .messages {
        padding: 4px;
    }

    .message.user .message-content {
        max-width: 90%;
    }

    .export-options {
        grid-template-columns: 1fr;
    }

    .input-area {
        padding: 12px;
    }

    .input-container {
        padding: 6px;
    }

    .btn-icon {
        width: 36px;
        height: 36px;
    }

    .btn-send {
        width: 36px;
        height: 36px;
    }
}

@media (max-width: 480px) {
    .app-title {
        font-size: 18px;
    }

    .header-left {
        gap: 10px;
    }

    .messages {
        padding: 4px;
    }

    .message-content {
        font-size: 14px;
    }

    .code-block {
        font-size: 13px;
    }
}

/* Fix for iOS Safari viewport */
@supports (-webkit-touch-callout: none) {
    .app-container {
        height: -webkit-fill-available;
    }
}

/* Model Selector Dropdown */
.model-dropdown {
    display: flex;
    position: fixed;
    background: var(--bg-primary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    max-width: 400px;
    width: 90vw;
    max-height: 400px;
    overflow: hidden;
    z-index: 1000;
    flex-direction: column;
}

.model-dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    font-size: 15px;
}

.btn-close-dropdown {
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-close-dropdown:hover {
    color: var(--text-primary);
}

.model-list {
    overflow-y: auto;
    flex: 1;
    padding: 8px;
}

.model-item {
    padding: 12px 16px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: var(--transition);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 4px;
}

.model-item:hover {
    background: var(--bg-hover);
}

.model-item.active {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--accent-color);
}

.model-name {
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
}

.model-size {
    font-size: 12px;
    color: var(--text-secondary);
}

.model-item-empty {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 14px;
}

.model-badge {
    display: none;
    position: absolute;
    top: -8px;
    background: var(--accent-color);
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 600;
}

/* Thinking Text Styles */
.thinking-text {
    background: var(--bg-tertiary);
    border-left: 3px solid var(--text-tertiary);
    padding: 12px 16px;
    margin: 12px 0;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: var(--transition);
}

.thinking-text:hover {
    background: var(--bg-hover);
}

.thinking-label {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    display: block;
    margin-bottom: 8px;
}

.thinking-content {
    color: var(--text-tertiary);
    font-size: 13px;
    line-height: 1.6;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition: all 0.3s ease;
}

.thinking-text.expanded .thinking-content {
    max-height: 1000px;
    opacity: 1;
    margin-top: 8px;
}

.thinking-text.expanded {
    background: var(--bg-hover);
    border-left-color: var(--accent-color);
}

/* RTL Support */
[dir="rtl"] {
    direction: rtl;
    text-align: right;
}

[dir="rtl"] .message-header {
    flex-direction: row-reverse;
}

[dir="rtl"] .message-content {
    text-align: right;
}

[dir="rtl"] .thinking-text {
    border-left: none;
    border-right: 3px solid var(--text-tertiary);
}

[dir="rtl"] .thinking-text.expanded {
    border-right-color: var(--accent-color);
}

/* Rename Modal - Smaller */
.modal-small .modal-content {
    max-width: 400px;
}

.input-full {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: var(--transition);
}

.input-full:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.1);
}

/* Theme Color Selector */
.theme-colors {
    display: flex;
    gap: 16px;
    padding: 8px 0;
    flex-wrap: wrap;
}

.theme-color-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    border: 3px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.theme-color-btn:hover {
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.theme-color-btn[data-theme="blue"]:hover,
.theme-color-btn[data-theme="green"]:hover,
.theme-color-btn[data-theme="purple"]:hover,
.theme-color-btn[data-theme="red"]:hover,
.theme-color-btn[data-theme="orange"]:hover {
    border-color: rgba(255, 255, 255, 0.5);
}

.theme-color-btn::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    width: 16px;
    height: 16px;
    background: white;
    border-radius: 50%;
    transition: transform 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* Highlight.js Code Styles Override */
pre code.hljs {
    display: block;
    overflow-x: auto;
    padding: 16px;
    background: #282c34;
    color: #abb2bf;
    white-space: pre !important;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.6;
}

pre {
    margin: 0;
    padding: 0;
    background: #282c34;
    border-radius: 8px;
}

/* Loading Animation */
.loading {
    display: inline-block;
    position: relative;
    color: var(--text-secondary);
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.loading::after {
    content: '...';
    position: absolute;
    animation: dots 1.5s steps(4) infinite;
}

@keyframes dots {
    0%, 20% { content: '.'; }
    40% { content: '..'; }
    60%, 100% { content: '...'; }
}

/* Model Selector Button in Input */
#modelSelectorBtn {
    position: relative;
}

#modelSelectorBtn .model-badge {
    display: inline-block;
}

/* Hide hamburger on desktop */
@media (min-width: 769px) {
    .mobile-toggle {
        display: none !important;
    }
}

/* Responsive Model Dropdown */
@media (max-width: 768px) {
    .model-dropdown {
        left: 50% !important;
        transform: translateX(-50%);
        bottom: 80px !important;
        top: auto !important;
    }
}