/* ==========================================
   Gemini Chat - CSS Styles
   ========================================== */

/* CSS Variables */
:root {
    /* Colors - Light Theme */
    --bg-primary: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f1f3f4;
    --bg-hover: #e8eaed;
    --text-primary: #202124;
    --text-secondary: #5f6368;
    --text-tertiary: #80868b;
    --border-color: #e0e0e0;
    --accent-primary: #4285f4;
    --accent-secondary: #8b5cf6;
    --accent-gradient: linear-gradient(135deg, #4285f4 0%, #8b5cf6 50%, #ec4899 100%);
    --message-user-bg: #e3f2fd;
    --message-ai-bg: #f8f9fa;
    --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 25px rgba(0, 0, 0, 0.1);
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --sidebar-width: 280px;
    --transition: all 0.2s ease;
}

/* Dark Theme */
body.dark-mode,
[data-theme="dark"] {
    --bg-primary: #1e1e2e;
    --bg-secondary: #181825;
    --bg-tertiary: #313244;
    --bg-hover: #45475a;
    --text-primary: #cdd6f4;
    --text-secondary: #a6adc8;
    --text-tertiary: #6c7086;
    --border-color: #313244;
    --accent-primary: #89b4fa;
    --accent-secondary: #cba6f7;
    --accent-gradient: linear-gradient(135deg, #89b4fa 0%, #cba6f7 50%, #f5c2e7 100%);
    --message-user-bg: #313244;
    --message-ai-bg: #181825;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.5);
}

/* Reset & Base */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    overflow: hidden;
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* ==========================================
   Sidebar Styles
   ========================================== */
/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1), transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    flex-shrink: 0;
    white-space: nowrap;
    z-index: 100;
}

/* Sidebar Closed State (Desktop) */
.app-container.sidebar-closed .sidebar {
    width: 0;
    border-right: none;
}

.sidebar-header {
    padding: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    border-bottom: none;
    background: transparent;
}

/* Menu Toggle Button */
.sidebar-menu-toggle {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid var(--accent-primary);
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

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

.sidebar-menu-toggle svg {
    width: 20px;
    height: 20px;
    color: var(--text-primary);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0;
    background: none;
}

.logo-icon {
    display: none;
}

.logo-text {
    font-size: 1.4rem;
    font-weight: 600;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.3px;
    font-family: 'Inter', sans-serif;
}

/* New Chat Button */
.new-chat-sidebar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    cursor: pointer;
    transition: all 0.2s;
    margin: 4px 12px 8px;
}

.new-chat-sidebar:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

.new-chat-sidebar svg {
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

body.dark-mode .new-chat-sidebar svg {
    color: #bdc1c6;
}

.new-chat-sidebar span {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* Sidebar Search Box */
.sidebar-search {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 8px 12px;
    padding: 10px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    transition: all 0.2s;
}

.sidebar-search:focus-within {
    border-color: var(--accent-primary);
    background: var(--bg-primary);
}

.sidebar-search .search-icon {
    width: 18px;
    height: 18px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.sidebar-search input {
    flex: 1;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.9rem;
    outline: none;
}

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

/* Search Empty State */
.search-empty {
    padding: 24px 16px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 0.9rem;
}

/* Chat Item Info (for search results) */
.chat-item-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.chat-item-preview {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Remove the pseudo-element title */
.chat-list::before {
    display: none;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    margin-top: 4px;
    border-top: 1px solid var(--border-color);
}

.chat-item {
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    margin-bottom: 4px;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
    background: transparent;
    border: none;
}

.chat-item:hover {
    background: var(--bg-hover);
}

.chat-item.active {
    background: var(--bg-tertiary);
}

.chat-item-icon {
    width: 18px;
    height: 18px;
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.chat-item.active .chat-item-icon {
    color: var(--accent-primary);
}

.chat-item-title {
    flex: 1;
    font-size: 0.875rem;
    font-weight: 400;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chat-item-delete {
    opacity: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: var(--text-tertiary);
}

.chat-item:hover .chat-item-delete {
    opacity: 1;
}

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

.chat-item-delete svg {
    width: 16px;
    height: 16px;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 8px;
}

.settings-btn {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-secondary);
    font-size: 0.875rem;
    transition: var(--transition);
}

.settings-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.settings-btn svg {
    width: 18px;
    height: 18px;
}

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

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

.theme-toggle svg {
    width: 20px;
    height: 20px;
}

.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 Content
   ========================================== */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    background: var(--bg-primary);
}

/* Main Content Layout */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: var(--bg-primary);
}

/* Chat Header */
.chat-header {
    height: 60px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: var(--bg-primary);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.new-chat-btn-header {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 6px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    height: 36px;
}

.new-chat-btn-header:hover {
    background: var(--bg-hover);
    border-color: var(--accent-primary);
}

.new-chat-btn-header svg {
    width: 16px;
    height: 16px;
}

/* Hide text on small screens */
@media (max-width: 600px) {
    .new-chat-btn-header span {
        display: none;
    }
}

/* User Profile Modal Styles */
.user-profile-modal-content {
    max-width: 400px;
    width: 90%;
}

.profile-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 32px 24px;
    text-align: center;
}

.profile-avatar-large {
    width: 80px;
    height: 80px;
    background: var(--accent-gradient);
    border-radius: 50%;
    color: white;
    font-size: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    font-weight: 600;
    box-shadow: var(--shadow-md);
}

.profile-name {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.profile-id {
    color: var(--text-secondary);
    font-size: 0.9rem;
    margin-bottom: 24px;
    font-family: monospace;
    background: var(--bg-secondary);
    padding: 4px 8px;
    border-radius: 4px;
}

.profile-stats {
    display: flex;
    gap: 32px;
    margin-top: 8px;
    width: 100%;
    justify-content: center;
}

.stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

.sidebar-toggle-btn {
    display: none;
    /* Hidden on mobile by default */
}

@media (min-width: 769px) {
    .sidebar-toggle-btn {
        display: flex;
    }
}

.header-model-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    /* Align to right */
    justify-content: center;
    line-height: 1.2;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background-color 0.2s;
    text-align: right;
}

/* ... */

.header-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.header-subtitle {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

.header-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: var(--transition);
}

.icon-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.icon-btn svg {
    width: 20px;
    height: 20px;
}

.user-avatar-btn {
    width: 36px;
    height: 36px;
    border: none;
    padding: 0;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
}

.user-avatar-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f59e0b, #ec4899);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.9rem;
}

/* Chat Area Adjustments */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    padding-bottom: 0;
    /* Handled by input area */
}

/* Welcome Screen Refined */
.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

.welcome-screen.hidden {
    display: none;
}

.welcome-icon {
    margin-bottom: 24px;
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.welcome-title {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.welcome-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 48px;
    max-width: 600px;
    line-height: 1.6;
}

.quick-prompts {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    max-width: 600px;
}

.quick-prompt {
    padding: 12px 20px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    font-size: 0.9rem;
    color: var(--text-primary);
    cursor: pointer;
    transition: var(--transition);
}

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

/* Messages Container */
.messages-container {
    flex: 1;
    padding: 20px;
    max-width: 900px;
    width: 100%;
    margin: 0 auto;
}

.messages-container.hidden {
    display: none;
}

/* Message Styles */
/* Message Styles */
.message {
    display: flex;
    gap: 16px;
    margin-bottom: 32px;
    /* Increased spacing */
    animation: fadeIn 0.3s ease;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 38px;
    /* Slightly larger */
    height: 38px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: var(--shadow-sm);
}

.message.user .message-avatar {
    background: var(--accent-gradient);
}

.message.assistant .message-avatar {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
}

.message-avatar svg {
    width: 22px;
    height: 22px;
    color: white;
}

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

.message-content {
    flex: 1;
    min-width: 0;
    padding-top: 2px;
}

.message-role {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 8px;
}

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

/* Enhanced Message Bubbles */
.message.user .message-text {
    background: var(--bg-tertiary);
    padding: 12px 16px;
    border-radius: 12px;
    border-top-left-radius: 2px;
    display: inline-block;
}

/* ==========================================
   Markdown Styles
   ========================================== */

/* Paragraphs */
.message-text p {
    margin-bottom: 16px;
}

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

/* Headings */
.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 {
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.4;
    margin-top: 24px;
    margin-bottom: 12px;
}

.message-text h1:first-child,
.message-text h2:first-child,
.message-text h3:first-child {
    margin-top: 0;
}

.message-text h1 {
    font-size: 1.5rem;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
}

.message-text h2 {
    font-size: 1.3rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 6px;
}

.message-text h3 {
    font-size: 1.15rem;
}

.message-text h4 {
    font-size: 1.05rem;
}

/* Lists */
.message-text ul,
.message-text ol {
    margin: 12px 0;
    padding-left: 24px;
}

.message-text li {
    margin-bottom: 8px;
    line-height: 1.6;
}

.message-text li::marker {
    color: var(--accent-primary);
}

.message-text ul li {
    list-style-type: disc;
}

.message-text ol li {
    list-style-type: decimal;
}

.message-text li>ul,
.message-text li>ol {
    margin-top: 8px;
    margin-bottom: 0;
}

/* Blockquotes */
.message-text blockquote {
    border-left: 4px solid var(--accent-primary);
    background: var(--bg-tertiary);
    margin: 16px 0;
    padding: 12px 16px;
    border-radius: 0 8px 8px 0;
    color: var(--text-secondary);
    font-style: italic;
}

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

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

/* Horizontal Rule */
.message-text hr {
    border: none;
    height: 1px;
    background: var(--border-color);
    margin: 24px 0;
}

/* Links */
.message-text a {
    color: var(--accent-primary);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: all 0.2s;
}

.message-text a:hover {
    border-bottom-color: var(--accent-primary);
}

/* Tables */
.message-text table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 0.9rem;
    overflow-x: auto;
    display: block;
}

.message-text thead {
    background: var(--bg-tertiary);
}

.message-text th,
.message-text td {
    padding: 10px 14px;
    text-align: left;
    border: 1px solid var(--border-color);
}

.message-text th {
    font-weight: 600;
    color: var(--text-primary);
}

.message-text tr:nth-child(even) {
    background: var(--bg-secondary);
}

/* Images */
.message-text img {
    max-width: 100%;
    max-height: 400px;
    width: auto;
    border-radius: 12px;
    box-shadow: var(--shadow-md);
    margin: 12px 0;
    display: block;
    object-fit: contain;
    background: var(--bg-tertiary);
}

.message-text img:hover {
    cursor: zoom-in;
    box-shadow: var(--shadow-lg);
}

/* Inline Code */
.message-text code {
    background: var(--bg-tertiary);
    padding: 3px 7px;
    border-radius: 6px;
    font-family: 'SF Mono', Monaco, Consolas, monospace;
    font-size: 0.88em;
    color: var(--accent-primary);
    word-break: break-word;
    border: 1px solid var(--border-color);
}

/* Code Blocks */
.message-text pre {
    background: #1a1a1a;
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
    margin: 16px 0;
    position: relative;
    box-shadow: var(--shadow-md);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Code Block Header */
.code-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.05);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.code-lang {
    font-size: 0.8rem;
    color: #888;
    font-family: inherit;
    text-transform: lowercase;
}

.code-actions {
    display: flex;
    gap: 8px;
}

.code-action-btn {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 8px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: #888;
    font-size: 0.75rem;
    cursor: pointer;
    transition: all 0.2s;
}

.code-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.code-action-btn svg {
    width: 14px;
    height: 14px;
}

.message-text pre code {
    display: block;
    background: transparent;
    padding: 16px;
    color: #e8e8e8;
    font-size: 0.9rem;
    word-break: normal;
    overflow-x: auto;
    border: none;
}

/* Legacy Copy Button (fallback) */
.copy-code-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    padding: 6px 10px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 6px;
    color: #a0a0a0;
    font-size: 0.75rem;
    cursor: pointer;
    transition: var(--transition);
}

.copy-code-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    color: white;
}

/* Strong & Emphasis */
.message-text strong {
    font-weight: 600;
    color: var(--text-primary);
}

.message-text em {
    font-style: italic;
}

/* Strikethrough */
.message-text del {
    text-decoration: line-through;
    color: var(--text-tertiary);
}

/* Task Lists */
.message-text input[type="checkbox"] {
    margin-right: 8px;
    accent-color: var(--accent-primary);
}

/* Message Action Buttons */
.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    opacity: 0;
    transition: opacity 0.2s;
}

.message:hover .message-actions {
    opacity: 1;
}

.msg-action-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    color: var(--text-secondary);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
}

.msg-action-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.msg-action-btn svg {
    width: 14px;
    height: 14px;
}

.msg-action-btn span {
    font-size: 0.8rem;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
    margin-left: 12px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: var(--text-tertiary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
}

.typing-indicator span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* ==========================================
   Input Area Optimized
   ========================================== */
.input-area {
    padding: 20px 24px 32px;
    background: linear-gradient(to top, var(--bg-primary) 85%, transparent);
}

.input-container {
    max-width: 800px;
    margin: 0 auto;
    position: relative;
    /* For positioning tweaks */
}

.input-wrapper {
    display: flex;
    align-items: center;
    /* Center content vertically */
    gap: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 28px;
    /* Slightly more rounded */
    padding: 10px 24px;
    /* Balanced padding */
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
    min-height: 56px;
    /* Ensure consistent height */
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(236, 72, 153, 0.15), var(--shadow-md);
    background: var(--bg-primary);
    /* Slight contrast on focus */
}

.input-wrapper textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-family: inherit;
    font-size: 1.05rem;
    /* Larger font */
    color: var(--text-primary);
    line-height: 1.5;
    max-height: 200px;
    outline: none;
    padding: 4px 0;
    /* Vertical spacing */
}

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

.input-actions {
    display: flex;
    gap: 8px;
}

.send-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--accent-gradient);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    opacity: 0.5;
}

.send-btn:not(:disabled) {
    opacity: 1;
}

.send-btn:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

.send-btn svg {
    width: 18px;
    height: 18px;
    color: white;
}

/* Function Button (Mic, Attach) */
.func-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: transparent;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-tertiary);
    transition: var(--transition);
    flex-shrink: 0;
}

.func-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
    transform: scale(1.05);
}

.func-btn svg {
    width: 20px;
    height: 20px;
}

/* Upload Button */
.upload-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--bg-tertiary);
    border-radius: 50%;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
    color: var(--text-secondary);
    flex-shrink: 0;
    margin-right: 4px;
}

.upload-btn:hover {
    background: var(--bg-hover);
    color: var(--accent-primary);
    transform: scale(1.05);
}

.upload-btn svg {
    width: 20px;
    height: 20px;
}

/* Show upload button only in image mode */
body.image-mode .upload-btn {
    display: flex;
}

/* Image Preview Area */
.image-preview-area {
    display: none;
    margin-bottom: 12px;
}

.image-preview-area.has-image {
    display: block;
}

.image-preview {
    position: relative;
    display: inline-block;
    max-width: 200px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 2px solid var(--border-color);
}

.image-preview img {
    display: block;
    max-width: 100%;
    max-height: 150px;
    object-fit: contain;
}

.remove-image-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border: none;
    background: rgba(220, 53, 69, 0.9);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    transition: var(--transition);
}

.remove-image-btn:hover {
    background: #dc3545;
    transform: scale(1.1);
}

.remove-image-btn svg {
    width: 14px;
    height: 14px;
}

/* Image Config */
.image-config {
    display: none;
    gap: 12px;
    margin-bottom: 12px;
    justify-content: center;
    flex-wrap: wrap;
}

body.image-mode .image-config {
    display: flex;
}

.config-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.config-item label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
}

.config-item select {
    padding: 6px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    background: var(--bg-secondary);
    color: var(--text-primary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.config-item select:hover {
    border-color: var(--accent-primary);
}

.config-item select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 2px rgba(236, 72, 153, 0.2);
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding: 0 8px;
}

.model-indicator {
    font-size: 0.75rem;
    color: var(--accent-primary);
    background: rgba(66, 133, 244, 0.1);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
}

.input-hint {
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* Mode Selector */
.mode-selector {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-bottom: 20px;
    background: var(--bg-secondary);
    padding: 6px;
    border-radius: 20px;
    border: 1px solid var(--border-color);
    width: fit-content;
    margin-left: auto;
    margin-right: auto;
    box-shadow: var(--shadow-sm);
}

.mode-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 16px;
    border: 1px solid transparent;
    background: transparent;
    border-radius: 16px;
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.mode-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.mode-btn.active {
    background: var(--accent-gradient);
    color: white;
    box-shadow: var(--shadow-sm);
    border-color: transparent;
}

.mode-btn svg {
    width: 16px;
    height: 16px;
}

.mode-btn.active svg {
    color: white;
}

/* Mode colors */
.mode-btn[data-mode="simple"].active {
    background: linear-gradient(135deg, #10b981, #06b6d4);
}

.mode-btn[data-mode="complex"].active {
    background: linear-gradient(135deg, #4285f4, #8b5cf6);
}

.mode-btn[data-mode="thinking"].active {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
}

.mode-btn[data-mode="image"].active {
    background: linear-gradient(135deg, #ec4899, #8b5cf6);
}

/* Mode Indicator */
.mode-indicator {
    font-size: 0.75rem;
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
    padding: 4px 10px;
    border-radius: var(--radius-sm);
    margin-left: 8px;
}

.mode-indicator.complex {
    color: #8b5cf6;
    background: rgba(139, 92, 246, 0.1);
}

.mode-indicator.thinking {
    color: #f59e0b;
    background: rgba(245, 158, 11, 0.1);
}

.mode-indicator.image {
    color: #ec4899;
    background: rgba(236, 72, 153, 0.1);
}

/* ==========================================
   Modal Styles
   ========================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    transition: var(--transition);
}

.modal-overlay.active .modal {
    transform: scale(1);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(90vh - 140px);
}

.setting-group {
    margin-bottom: 20px;
}

.setting-group:last-child {
    margin-bottom: 0;
}

.setting-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.setting-group input,
.setting-group select {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    background: var(--bg-secondary);
    color: var(--text-primary);
    transition: var(--transition);
}

.setting-group input:focus,
.setting-group select:focus {
    outline: none;
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}

.setting-hint {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 6px;
}

.modal-footer {
    display: flex;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

.btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
}

.btn-primary {
    background: var(--accent-gradient);
    color: white;
}

.btn-primary:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: var(--bg-hover);
}

/* ==========================================
   Mobile Menu Button
   ========================================== */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    width: 44px;
    height: 44px;
    border: none;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    z-index: 99;
    box-shadow: var(--shadow-md);
}

.mobile-menu-btn svg {
    width: 24px;
    height: 24px;
    color: var(--text-primary);
}

/* ==========================================
   Responsive Styles
   ========================================== */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: 0;
        bottom: 0;
        z-index: 100;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open {
        left: 0;
    }

    .mobile-menu-btn {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .messages-container {
        padding: 16px;
    }

    .welcome-title {
        font-size: 1.5rem;
    }

    .quick-prompts {
        flex-direction: column;
        align-items: stretch;
    }

    .input-wrapper {
        padding: 10px 14px;
    }

    .modal {
        margin: 16px;
        max-width: calc(100% - 32px);
    }
}

/* iPhone / Mobile Adaptation */
@media (max-width: 480px) {
    .mode-selector {
        gap: 6px;
        padding: 4px;
        width: 100%;
        overflow-x: auto;
        justify-content: flex-start;
        border-radius: 16px;
        /* Hide scrollbar */
        scrollbar-width: none;
        -ms-overflow-style: none;
    }

    .mode-selector::-webkit-scrollbar {
        display: none;
    }

    .mode-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
        flex-shrink: 0;
    }

    .image-config {
        padding: 8px;
        gap: 8px;
    }

    .config-item label {
        display: none;
        /* Save space */
    }

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

    .input-wrapper {
        padding: 8px 12px;
        border-radius: 20px;
    }

    .message {
        gap: 8px;
        margin-bottom: 24px;
    }

    .message-avatar {
        width: 32px;
        height: 32px;
    }

    .message-avatar svg {
        width: 18px;
        height: 18px;
    }

    .message-text {
        font-size: 0.95rem;
    }

    /* Optimize messages for small screen */
    .message.user .message-text {
        padding: 10px 14px;
    }

    /* Message actions always visible on mobile */
    .message-actions {
        opacity: 1;
        flex-wrap: wrap;
    }

    .msg-action-btn {
        padding: 5px 10px;
    }

    .msg-action-btn span {
        font-size: 0.75rem;
    }

    /* Search box mobile optimization */
    .sidebar-search {
        margin: 6px 8px;
        padding: 8px 12px;
    }

    .sidebar-search input {
        font-size: 0.85rem;
    }

    /* New chat button mobile */
    .new-chat-sidebar {
        padding: 10px 14px;
        margin: 4px 8px 6px;
    }

    /* Sidebar header mobile */
    .sidebar-header {
        padding: 12px;
        gap: 12px;
    }

    .sidebar-menu-toggle {
        width: 40px;
        height: 40px;
    }

    .logo-text {
        font-size: 1.2rem;
    }
}

/* ==========================================
   Scrollbar Styles
   ========================================== */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

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

/* ==========================================
   Utilities
   ========================================== */
.hidden {
    display: none !important;
}