/* =========================================
   Aydin Cloud LLM - Modern Dark Theme
   ========================================= */

:root {
    /* Color Palette - Deep Space Theme */
    --bg-primary: #0a0a0f;
    --bg-secondary: #12121a;
    --bg-tertiary: #1a1a24;
    --bg-chat: #0d0d14;

    /* Accent Colors - Electric Purple & Cyan */
    --accent-primary: #8b5cf6;
    --accent-secondary: #06b6d4;
    --accent-gradient: linear-gradient(135deg, #8b5cf6 0%, #06b6d4 100%);
    --accent-glow: rgba(139, 92, 246, 0.3);

    /* Text Colors */
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-tertiary: #64748b;

    /* Message Colors */
    --user-msg-bg: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    --assistant-msg-bg: #1e1e2e;
    --thinking-bg: rgba(6, 182, 212, 0.1);
    --thinking-border: rgba(6, 182, 212, 0.3);

    /* Borders & Shadows */
    --border-subtle: rgba(255, 255, 255, 0.06);
    --border-accent: rgba(139, 92, 246, 0.3);
    --shadow-lg: 0 20px 40px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 30px rgba(139, 92, 246, 0.2);

    /* Sizing */
    --sidebar-width: 280px;
    --header-height: 64px;
    --input-height: 72px;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;

    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    height: 100dvh;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* =========================================
   App Layout
   ========================================= */

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* =========================================
   Sidebar Styles
   ========================================= */

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-subtle);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: transform var(--transition-normal);
    z-index: 100;
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--border-subtle);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 40px;
    height: 40px;
    background: var(--accent-gradient);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.logo-icon svg {
    width: 22px;
    height: 22px;
    color: white;
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.new-chat-btn {
    margin: 16px;
    padding: 12px 20px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-glow);
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.4);
}

.new-chat-btn svg {
    width: 18px;
    height: 18px;
}

/* Compare Button */
.compare-btn {
    margin: 0 16px 16px;
    padding: 10px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-fast);
}

.compare-btn:hover {
    background: var(--bg-secondary);
    border-color: var(--border-accent);
    color: var(--text-primary);
}

.compare-btn.active {
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.2) 0%, rgba(6, 182, 212, 0.2) 100%);
    border-color: var(--accent-primary);
    color: var(--text-primary);
}

.compare-btn svg {
    width: 16px;
    height: 16px;
}

/* =========================================
   Compare Mode - Split Screen
   ========================================= */

.chat-main.compare-mode {
    display: none;
}

.compare-container {
    display: none;
    flex: 1;
    flex-direction: column;
    background: var(--bg-chat);
    min-width: 0;
}

.compare-container.active {
    display: flex;
}

.compare-header {
    height: var(--header-height);
    padding: 0 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.compare-header h1 {
    flex: 1;
    font-size: 1.1rem;
    font-weight: 600;
}

.compare-panes {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.compare-pane {
    flex: 1;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-subtle);
    min-width: 0;
}

.compare-pane:last-child {
    border-right: none;
}

.pane-header {
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.pane-model-selector {
    position: relative;
    flex: 1;
}

.pane-model-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.pane-model-btn:hover {
    border-color: var(--border-accent);
}

.pane-model-btn .model-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.pane-model-dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    max-height: 250px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-fast);
}

.pane-model-selector.open .pane-model-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.pane-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.compare-input-container {
    padding: 16px 24px;
    background: var(--bg-chat);
    border-top: 1px solid var(--border-subtle);
}

.compare-input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
}

.compare-input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.compare-input-wrapper textarea {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    min-height: 24px;
    max-height: 150px;
    outline: none;
    line-height: 1.5;
}

.compare-input-wrapper textarea::placeholder {
    color: var(--text-tertiary);
}

.sidebar-section {
    padding: 16px;
    flex: 1;
}

.sidebar-section h3 {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 12px;
}

/* Model Selector */
.model-selector {
    position: relative;
}

.model-dropdown-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.model-dropdown-btn:hover {
    border-color: var(--border-accent);
}

.selected-model {
    text-align: left;
}

.selected-model .model-name {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.selected-model .model-provider {
    display: block;
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.dropdown-arrow {
    width: 16px;
    height: 16px;
    color: var(--text-tertiary);
    transition: transform var(--transition-fast);
}

.model-selector.open .dropdown-arrow {
    transform: rotate(180deg);
}

.model-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 200;
    max-height: 300px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all var(--transition-fast);
}

.model-selector.open .model-dropdown {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.model-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 14px;
    cursor: pointer;
    transition: background var(--transition-fast);
    border-bottom: 1px solid var(--border-subtle);
}

.model-option:last-child {
    border-bottom: none;
}

.model-option:hover {
    background: var(--bg-tertiary);
}

.model-option.selected {
    background: rgba(139, 92, 246, 0.1);
    border-left: 2px solid var(--accent-primary);
}

.model-option-info {
    flex: 1;
}

.model-option-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-primary);
}

.model-option-provider {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    margin-top: 2px;
}

.model-option-context {
    font-size: 0.65rem;
    padding: 3px 8px;
    background: var(--bg-primary);
    border-radius: 4px;
    color: var(--text-tertiary);
}

.model-option.supports-thinking .model-option-context {
    background: rgba(6, 182, 212, 0.15);
    color: var(--accent-secondary);
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    margin-bottom: 8px;
}

.setting-item label {
    cursor: pointer;
}

.setting-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
}

.setting-desc {
    display: block;
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 2px;
}

/* Toggle Switch */
.toggle {
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-primary);
    border-radius: 24px;
    transition: var(--transition-fast);
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: var(--text-tertiary);
    border-radius: 50%;
    transition: var(--transition-fast);
}

.toggle input:checked+.toggle-slider {
    background: var(--accent-primary);
}

.toggle input:checked+.toggle-slider::before {
    transform: translateX(20px);
    background: white;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-subtle);
}

.powered-by {
    text-align: center;
}

.powered-by>span {
    font-size: 0.7rem;
    color: var(--text-tertiary);
    display: block;
    margin-bottom: 8px;
}

.nvidia-badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: linear-gradient(135deg, #76b900 0%, #4a7a00 100%);
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
}

.nvidia-logo {
    width: 18px;
    height: 18px;
}

/* =========================================
   Main Chat Area
   ========================================= */

.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-chat);
    min-width: 0;
}

.chat-header {
    height: var(--header-height);
    padding: 0 24px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-subtle);
    display: flex;
    align-items: center;
    gap: 16px;
    flex-shrink: 0;
}

.mobile-menu-btn {
    display: none;
    padding: 8px;
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: var(--radius-sm);
}

.mobile-menu-btn:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.mobile-menu-btn svg {
    width: 24px;
    height: 24px;
}

.chat-title {
    flex: 1;
}

.chat-title h1 {
    font-size: 1.1rem;
    font-weight: 600;
}

.model-badge {
    display: inline-block;
    font-size: 0.7rem;
    color: var(--text-tertiary);
    background: var(--bg-tertiary);
    padding: 2px 8px;
    border-radius: 4px;
    margin-top: 4px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    padding: 10px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.icon-btn:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--border-accent);
}

.icon-btn svg {
    width: 18px;
    height: 18px;
    display: block;
}

/* =========================================
   Chat Messages
   ========================================= */

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    scroll-behavior: smooth;
}

/* Custom Scrollbar */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: var(--bg-tertiary);
    border-radius: 3px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--text-tertiary);
}

/* Welcome Container */
.welcome-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 60px 20px;
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: var(--accent-gradient);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    box-shadow: var(--shadow-glow);
    animation: float 3s ease-in-out infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-10px);
    }
}

.welcome-icon svg {
    width: 40px;
    height: 40px;
    color: white;
}

.welcome-container h2 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 8px;
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-container p {
    color: var(--text-secondary);
    max-width: 400px;
    margin-bottom: 32px;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    max-width: 600px;
}

.chip {
    padding: 12px 18px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    color: var(--text-secondary);
    font-size: 0.85rem;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.chip:hover {
    background: var(--bg-tertiary);
    border-color: var(--border-accent);
    color: var(--text-primary);
    transform: translateY(-2px);
}

/* Message Bubbles */
.message {
    display: flex;
    gap: 16px;
    max-width: 900px;
    animation: messageIn 0.3s ease;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.user {
    flex-direction: row-reverse;
    margin-left: auto;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1rem;
}

.message.user .message-avatar {
    background: var(--user-msg-bg);
}

.message.assistant .message-avatar {
    background: var(--accent-gradient);
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message.user .message-content {
    display: flex;
    justify-content: flex-end;
}

.message-bubble {
    padding: 14px 18px;
    border-radius: var(--radius-lg);
    line-height: 1.6;
    word-wrap: break-word;
}

.message.user .message-bubble {
    background: var(--user-msg-bg);
    color: white;
    border-bottom-right-radius: var(--radius-sm);
}

.message.assistant .message-bubble {
    background: var(--assistant-msg-bg);
    border: 1px solid var(--border-subtle);
    border-bottom-left-radius: var(--radius-sm);
}

/* Thinking Block */
.thinking-block {
    background: var(--thinking-bg);
    border: 1px solid var(--thinking-border);
    border-radius: var(--radius-md);
    margin-bottom: 12px;
    overflow: hidden;
}

.thinking-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: rgba(6, 182, 212, 0.1);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--accent-secondary);
    border-bottom: 1px solid var(--thinking-border);
}

.thinking-header svg {
    width: 16px;
    height: 16px;
    transition: transform var(--transition-fast);
}

.thinking-block.collapsed .thinking-header svg {
    transform: rotate(-90deg);
}

.thinking-block.collapsed .thinking-content {
    display: none;
}

.thinking-content {
    padding: 12px 14px;
    font-size: 0.85rem;
    color: var(--text-secondary);
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
}

/* Loading Animation */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 14px 18px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Code Blocks in Messages */
.message-bubble pre {
    background: #0d1117;
    border-radius: var(--radius-sm);
    padding: 16px;
    margin: 12px 0;
    overflow-x: auto;
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
}

.message-bubble pre code {
    background: none;
    padding: 0;
    border-radius: 0;
    font-size: 0.85rem;
}

.message-bubble code {
    font-family: 'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    font-size: 0.85rem;
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Markdown Elements in Messages */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4 {
    margin-top: 16px;
    margin-bottom: 8px;
    font-weight: 600;
    line-height: 1.4;
}

.message-bubble h1 {
    font-size: 1.4em;
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: 8px;
}

.message-bubble h2 {
    font-size: 1.25em;
}

.message-bubble h3 {
    font-size: 1.1em;
}

.message-bubble h4 {
    font-size: 1em;
}

.message-bubble p {
    margin: 8px 0;
}

.message-bubble ul,
.message-bubble ol {
    margin: 8px 0;
    padding-left: 24px;
}

.message-bubble li {
    margin: 4px 0;
}

.message-bubble blockquote {
    margin: 12px 0;
    padding: 8px 16px;
    border-left: 4px solid var(--accent-primary);
    background: rgba(139, 92, 246, 0.1);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.message-bubble blockquote p {
    margin: 0;
}

.message-bubble table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 0.9rem;
}

.message-bubble th,
.message-bubble td {
    padding: 8px 12px;
    border: 1px solid var(--border-subtle);
    text-align: left;
}

.message-bubble th {
    background: var(--bg-tertiary);
    font-weight: 600;
}

.message-bubble tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

.message-bubble a {
    color: var(--accent-secondary);
    text-decoration: none;
}

.message-bubble a:hover {
    text-decoration: underline;
}

.message-bubble hr {
    border: none;
    border-top: 1px solid var(--border-subtle);
    margin: 16px 0;
}

.message-bubble img {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin: 8px 0;
}

/* =========================================
   Input Area
   ========================================= */

.chat-input-container {
    padding: 16px 24px 24px;
    background: var(--bg-chat);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-subtle);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--accent-primary);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-wrapper textarea {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    resize: none;
    min-height: 24px;
    max-height: 150px;
    outline: none;
    line-height: 1.5;
}

.input-wrapper textarea::placeholder {
    color: var(--text-tertiary);
}

.send-btn {
    width: 40px;
    height: 40px;
    background: var(--accent-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);
    flex-shrink: 0;
}

.send-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.send-btn:not(:disabled):hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.send-btn svg {
    width: 18px;
    height: 18px;
}

.input-footer {
    text-align: center;
    margin-top: 12px;
    font-size: 0.75rem;
    color: var(--text-tertiary);
}

/* =========================================
   Mobile Overlay
   ========================================= */

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 99;
    backdrop-filter: blur(4px);
}

/* =========================================
   Responsive Design
   ========================================= */

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.open+.chat-main+.sidebar-overlay {
        display: block;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .chat-header {
        padding: 0 16px;
    }

    .chat-messages {
        padding: 16px;
    }

    .chat-input-container {
        padding: 12px 16px;
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 20px));
        position: sticky;
        bottom: 0;
        z-index: 50;
    }

    .welcome-container {
        padding: 40px 16px;
    }

    .suggestion-chips {
        flex-direction: column;
    }

    .chip {
        width: 100%;
    }
}

/* =========================================
   Error State
   ========================================= */

.error-message {
    padding: 14px 18px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: var(--radius-md);
    color: #ef4444;
    display: flex;
    align-items: center;
    gap: 10px;
}

.error-message svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* =========================================
   Mobile Mode (Toggleable)
   ========================================= */

body.mobile-mode .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 100;
}

body.mobile-mode .sidebar.open {
    transform: translateX(0);
}

body.mobile-mode .sidebar.open~.sidebar-overlay {
    display: block;
}

body.mobile-mode .mobile-menu-btn {
    display: flex;
    padding: 12px;
}

body.mobile-mode .chat-header {
    padding: 0 12px;
}

body.mobile-mode .chat-main {
    height: 100vh;
    height: 100dvh;
    /* Dynamic viewport height for mobile browsers */
    display: flex;
    flex-direction: column;
}

body.mobile-mode .chat-title h1 {
    font-size: 1rem;
}

body.mobile-mode .chat-messages {
    flex: 1;
    padding: 12px;
    gap: 16px;
    overflow-y: auto;
    min-height: 0;
    /* Important for flex overflow */
}

body.mobile-mode .chat-input-container {
    flex-shrink: 0;
    padding: 8px 12px 12px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 20px));
    /* Extra padding for mobile browser UI + iOS safe area */
    background: var(--bg-chat);
    position: sticky;
    bottom: 0;
    z-index: 50;
}

body.mobile-mode .message {
    gap: 10px;
}

body.mobile-mode .message-avatar {
    width: 32px;
    height: 32px;
    font-size: 0.9rem;
}

body.mobile-mode .message-bubble {
    padding: 12px 14px;
    font-size: 0.95rem;
}

body.mobile-mode .input-wrapper {
    padding: 10px 12px;
}

body.mobile-mode .input-wrapper textarea {
    font-size: 16px;
    /* Prevents iOS zoom */
}

body.mobile-mode .send-btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
}

body.mobile-mode .icon-btn {
    padding: 12px;
    min-width: 44px;
    min-height: 44px;
}

body.mobile-mode .welcome-container {
    padding: 30px 16px;
}

body.mobile-mode .welcome-icon {
    width: 60px;
    height: 60px;
}

body.mobile-mode .welcome-icon svg {
    width: 30px;
    height: 30px;
}

body.mobile-mode .welcome-container h2 {
    font-size: 1.4rem;
}

body.mobile-mode .suggestion-chips {
    flex-direction: column;
    width: 100%;
    max-width: 100%;
}

body.mobile-mode .chip {
    width: 100%;
    padding: 14px 16px;
    font-size: 0.9rem;
    justify-content: flex-start;
}

/* Mobile mode for compare */
body.mobile-mode .compare-panes {
    flex-direction: column;
}

body.mobile-mode .compare-pane {
    border-right: none;
    border-bottom: 1px solid var(--border-subtle);
    min-height: 40vh;
}

body.mobile-mode .compare-pane:last-child {
    border-bottom: none;
}

body.mobile-mode .pane-header {
    padding: 10px 12px;
}

body.mobile-mode .pane-messages {
    padding: 12px;
}

body.mobile-mode .compare-input-container {
    padding: 8px 12px 12px;
    padding-bottom: calc(20px + env(safe-area-inset-bottom, 20px));
    position: sticky;
    bottom: 0;
    z-index: 50;
}

body.mobile-mode .compare-input-wrapper {
    padding: 10px 12px;
}

body.mobile-mode .compare-input-wrapper textarea {
    font-size: 16px;
}

/* Touch-friendly toggles in mobile mode */
body.mobile-mode .toggle {
    width: 52px;
    height: 28px;
}

body.mobile-mode .toggle-slider::before {
    width: 22px;
    height: 22px;
}

body.mobile-mode .toggle input:checked+.toggle-slider::before {
    transform: translateX(24px);
}

body.mobile-mode .setting-item {
    padding: 14px;
}

/* Model dropdown touch friendly */
body.mobile-mode .model-dropdown-btn {
    padding: 14px 16px;
}

body.mobile-mode .model-option {
    padding: 14px 16px;
}

/* Sidebar touch improvements */
body.mobile-mode .new-chat-btn,
body.mobile-mode .compare-btn {
    padding: 14px 20px;
    font-size: 0.95rem;
}