/* ============================================
   Gemini AI Chat - Premium Dark Theme
   ChatGPT-inspired UI with modern aesthetics
   ============================================ */

/* CSS Variables */
:root {
    /* Dark theme colors */
    --bg-primary: #0d0d0d;
    --bg-secondary: #171717;
    --bg-tertiary: #212121;
    --bg-hover: #2a2a2a;
    --bg-active: #343434;

    /* Accent colors */
    --accent-primary: #10a37f;
    --accent-secondary: #1a7f64;
    --accent-gradient: linear-gradient(135deg, #10a37f 0%, #1ed9a4 100%);
    --accent-glow: rgba(16, 163, 127, 0.3);

    /* Text colors */
    --text-primary: #ececec;
    --text-secondary: #b4b4b4;
    --text-muted: #8e8e8e;
    --text-placeholder: #6b6b6b;

    /* Border colors */
    --border-primary: #2f2f2f;
    --border-secondary: #404040;
    --border-focus: #10a37f;

    /* Status colors */
    --success: #10a37f;
    --error: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;

    /* Shadows */
    --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);
    --shadow-glow: 0 0 20px var(--accent-glow);

    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
    --transition-slow: 0.4s ease;

    /* Sizing */
    --sidebar-width: 260px;
    --input-max-width: 768px;
    --message-max-width: 768px;

    /* Border radius */
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Dynamic settings (set by JS) */
    --message-font-size: 15px;
    --message-spacing: 16px;
}

/* Animation preferences */
body.no-animations * {
    animation-duration: 0s !important;
    transition-duration: 0s !important;
}

/* Compact mode */
body.compact-mode .message {
    padding: 12px 0;
}

body.compact-mode .message-avatar {
    width: 28px;
    height: 28px;
}

/* Reset & Base */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 16px;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-primary);
    overflow: hidden;
}

/* Typography */
h1,
h2,
h3,
h4,
h5,
h6 {
    font-weight: 600;
    line-height: 1.3;
}

a {
    color: var(--accent-primary);
    text-decoration: none;
    transition: color var(--transition-fast);
}

a:hover {
    color: var(--accent-secondary);
    text-decoration: underline;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: var(--border-secondary);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ============================================
   Layout Structure
   ============================================ */

.app-container {
    display: flex;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    height: 100%;
    background: var(--bg-secondary);
    border-right: 1px solid var(--border-primary);
    display: flex;
    flex-direction: column;
    transition: transform var(--transition-normal), width var(--transition-normal);
    overflow: hidden;
    /* Fix content leaking when collapsed */
}

.sidebar.collapsed {
    width: 0;
    min-width: 0;
    /* Remove transform allows main content to flow into space */
    transform: none;
}

.sidebar-header {
    padding: 12px;
    border-bottom: 1px solid var(--border-primary);
}

.new-chat-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: transparent;
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.new-chat-btn:hover {
    background: var(--bg-hover);
    border-color: var(--border-focus);
}

.new-chat-btn svg {
    width: 20px;
    height: 20px;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.conversation-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

/* Bulk Actions Bar */
.bulk-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-primary);
    animation: slideDown 0.2s ease-out;
}

.bulk-actions.hidden {
    display: none;
}

.bulk-count {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

.bulk-buttons {
    display: flex;
    gap: 8px;
}

.bulk-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.bulk-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.bulk-btn.danger:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

@keyframes slideDown {
    from {
        transform: translateY(-10px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.conversation-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
    position: relative;
    user-select: none;
}

.conversation-item:hover {
    background: var(--bg-hover);
}

.conversation-item.active {
    background: var(--bg-active);
}

.conversation-item.selected {
    background: rgba(var(--accent-primary-rgb), 0.1);
    border: 1px solid var(--accent-primary);
}

/* Checkbox for selection mode */
.conversation-checkbox {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid var(--text-muted);
    border-radius: 4px;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.select-mode .conversation-checkbox {
    display: flex;
}

.select-mode .conversation-item.selected .conversation-checkbox {
    background: var(--accent-primary);
    border-color: var(--accent-primary);
}

.select-mode .conversation-item.selected .conversation-checkbox::after {
    content: "✓";
    color: white;
    font-size: 12px;
    font-weight: bold;
}

/* Hide icons in select mode to make space */
.select-mode .conversation-item .icon {
    display: none;
}

.conversation-item .icon {
    width: 18px;
    height: 18px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.conversation-item .title {
    flex: 1;
    font-size: 14px;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conversation-item .delete-btn {
    opacity: 0;
    padding: 4px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.conversation-item:hover .delete-btn {
    opacity: 1;
}

.conversation-item .delete-btn:hover {
    background: var(--bg-hover);
    color: var(--error);
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid var(--border-primary);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: background var(--transition-fast);
}

.user-menu:hover {
    background: var(--bg-hover);
}

.user-avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: white;
}

.user-info {
    flex: 1;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
    position: relative;
}

/* Header */
.main-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-primary);
    background: var(--bg-primary);
    z-index: 10;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toggle-sidebar-btn {
    padding: 8px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.toggle-sidebar-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.model-selector {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.model-selector:hover {
    border-color: var(--border-secondary);
}

.model-selector select {
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    outline: none;
}

.model-selector select option {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.header-btn {
    padding: 8px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.header-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* Chat Area */
.chat-area {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px;
}

.chat-messages {
    max-width: var(--message-max-width);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 24px;
    text-align: center;
}

.welcome-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 24px;
    background: var(--accent-gradient);
    border-radius: var(--radius-xl);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.welcome-logo svg {
    width: 48px;
    height: 48px;
    color: white;
}

.welcome-title {
    font-size: 28px;
    font-weight: 600;
    margin-bottom: 8px;
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--text-secondary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    max-width: 400px;
}

/* Message Styles */
.message {
    display: flex;
    gap: 16px;
    animation: messageIn 0.3s ease;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message.user .message-avatar {
    background: var(--bg-active);
}

.message.assistant .message-avatar {
    background: var(--accent-gradient);
}

.message-avatar svg {
    width: 20px;
    height: 20px;
    color: white;
}

.message-content {
    flex: 1;
    min-width: 0;
}

.message-role {
    font-size: 14px;
    font-weight: 600;
    margin-bottom: 4px;
    color: var(--text-primary);
}

.message-text {
    font-size: 15px;
    line-height: 1.8;
    color: var(--text-primary);
}

.message-text p {
    margin-bottom: 16px;
}

.message-text p:last-child {
    margin-bottom: 0;
}

/* Add space after line breaks using adjacent sibling */
.message-text br+* {
    margin-top: 16px !important;
}

/* Better spacing between block elements */
.message-text h1,
.message-text h2,
.message-text h3,
.message-text h4,
.message-text h5,
.message-text h6 {
    margin-top: 20px;
    margin-bottom: 12px;
}

.message-text ul,
.message-text ol {
    margin: 16px 0;
    padding-left: 24px;
}

.message-text li {
    margin-bottom: 8px;
}

.message-text blockquote {
    margin: 16px 0;
    padding: 12px 20px;
    border-left: 3px solid var(--accent-primary);
    background: var(--bg-tertiary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.message-text hr {
    margin: 24px 0;
    border: none;
    height: 1px;
    background: var(--border-primary);
}

.message-text code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: var(--radius-sm);
    font-family: 'Fira Code', 'Consolas', monospace;
    font-size: 14px;
}

.message-text pre {
    background: var(--bg-tertiary);
    padding: 16px;
    overflow-x: auto;
    margin: 12px 0;
}

.message-text pre code {
    background: transparent;
    padding: 0;
}

/* Beautiful Table Styling */
.message-text table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin: 16px 0;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.message-text thead {
    background: linear-gradient(135deg, var(--accent-primary) 0%, var(--accent-secondary) 100%);
}

.message-text th {
    padding: 14px 16px;
    text-align: left;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: white;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
}

.message-text td {
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border-bottom: 1px solid var(--border-primary);
    transition: background var(--transition-fast);
}

.message-text tr:last-child td {
    border-bottom: none;
}

.message-text tbody tr:hover td {
    background: var(--bg-hover);
}

/* Alternating row colors */
.message-text tbody tr:nth-child(even) td {
    background: rgba(255, 255, 255, 0.02);
}

.message-text tbody tr:nth-child(even):hover td {
    background: var(--bg-hover);
}

/* Center alignment for specific columns */
.message-text th:nth-child(n+2),
.message-text td:nth-child(n+2) {
    text-align: center;
}

/* Grounding/Citations */
.message-sources {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border-left: 3px solid var(--accent-primary);
}

.sources-title {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.source-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    font-size: 13px;
}

.source-item a {
    color: var(--accent-primary);
}

/* Message Image */
.message-image {
    max-width: 400px;
    margin-top: 12px;
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
}

.message-image img {
    width: 100%;
    height: auto;
    display: block;
}

.image-filename {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 4px 8px;
    border-radius: var(--radius-sm);
    font-size: 11px;
    font-family: 'Fira Code', monospace;
    backdrop-filter: blur(4px);
}

/* ============================================
   Inline Function Blocks
   ============================================ */

.function-block {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    margin: 16px 0;
    overflow: hidden;
    transition: all var(--transition-normal);
}

.function-block.generating {
    border-color: var(--accent-primary);
    animation: pulseGlow 2s ease-in-out infinite;
}

.function-block.success {
    border-color: var(--success);
}

.function-block.error {
    border-color: var(--error);
}

@keyframes pulseGlow {

    0%,
    100% {
        box-shadow: 0 0 5px var(--accent-glow);
    }

    50% {
        box-shadow: 0 0 20px var(--accent-glow);
    }
}

.function-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-hover);
}

.function-icon {
    width: 36px;
    height: 36px;
    background: var(--accent-gradient);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.function-icon svg {
    width: 20px;
    height: 20px;
    color: white;
}

.image-function .function-icon {
    background: linear-gradient(135deg, #8b5cf6 0%, #d946ef 100%);
}

.video-function .function-icon {
    background: linear-gradient(135deg, #ef4444 0%, #f97316 100%);
}

.view-function .function-icon {
    background: linear-gradient(135deg, #06b6d4 0%, #3b82f6 100%);
}

.search-function .function-icon {
    background: linear-gradient(135deg, #10b981 0%, #14b8a6 100%);
}

.function-info {
    flex: 1;
}

.function-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.function-meta {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'Fira Code', monospace;
}

.function-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
}

.function-status .status-text {
    color: var(--text-muted);
}

.function-status .status-text.success {
    color: var(--success);
}

.function-status .status-text.error {
    color: var(--error);
}

.function-prompt {
    border-top: 1px solid var(--border-primary);
    overflow: hidden;
    max-height: 40px;
    transition: max-height var(--transition-normal);
}

.function-prompt.expanded {
    max-height: 200px;
}

.prompt-toggle {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 10px 16px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.prompt-toggle:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.prompt-toggle svg {
    transition: transform var(--transition-fast);
}

.function-prompt.expanded .prompt-toggle svg {
    transform: rotate(180deg);
}

.prompt-content {
    padding: 0 16px 12px;
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.5;
    font-family: 'Fira Code', monospace;
    white-space: pre-wrap;
    word-break: break-word;
}

.function-result {
    padding: 12px 16px 16px;
}

.function-result:empty {
    display: none;
}

.function-result .message-image {
    max-width: 100%;
    margin: 0;
}

.video-result {
    padding: 12px;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
}

.video-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--accent-gradient);
    color: white;
    border-radius: var(--radius-sm);
    font-weight: 500;
    text-decoration: none;
    transition: all var(--transition-fast);
}

.video-link:hover {
    transform: scale(1.02);
    box-shadow: var(--shadow-glow);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    border-radius: var(--radius-full);
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) {
    animation-delay: 0s;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    80%,
    100% {
        transform: scale(0.8);
        opacity: 0.5;
    }

    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Loading Spinner */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid var(--text-muted);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Input Area */
.input-area {
    padding: 16px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-primary);
}

.input-container {
    max-width: var(--input-max-width);
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    flex-direction: column;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-lg);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.input-wrapper:focus-within {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 2px var(--accent-glow);
}

.input-top {
    display: flex;
    align-items: flex-end;
    padding: 12px 16px;
    gap: 12px;
}

.message-input {
    flex: 1;
    min-height: 24px;
    max-height: 200px;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 15px;
    line-height: 1.5;
    resize: none;
    outline: none;
    font-family: inherit;
}

.message-input::placeholder {
    color: var(--text-placeholder);
}

.send-btn {
    width: 36px;
    height: 36px;
    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:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-glow);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.send-btn svg {
    width: 18px;
    height: 18px;
}

.input-bottom {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-top: 1px solid var(--border-primary);
}

.input-action {
    padding: 6px 10px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all var(--transition-fast);
}

.input-action:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.input-action svg {
    width: 16px;
    height: 16px;
}

/* Attachments Preview */
.attachments-preview {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border-primary);
    flex-wrap: wrap;
}

.attachment-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg-hover);
    border-radius: var(--radius-sm);
    font-size: 13px;
}

.attachment-item .remove-btn {
    padding: 2px;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: all var(--transition-fast);
}

.attachment-item .remove-btn:hover {
    color: var(--error);
}

/* ============================================
   Settings Panel
   ============================================ */

.settings-panel {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    max-width: 100%;
    height: 100%;
    background: var(--bg-secondary);
    border-left: 1px solid var(--border-primary);
    z-index: 100;
    transform: translateX(100%);
    transition: transform var(--transition-normal);
    display: flex;
    flex-direction: column;
}

.settings-panel.open {
    transform: translateX(0);
}

.settings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px;
    border-bottom: 1px solid var(--border-primary);
}

.settings-header h2 {
    font-size: 18px;
    font-weight: 600;
}

.settings-close {
    padding: 8px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.settings-close:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.settings-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.settings-section {
    margin-bottom: 24px;
}

.settings-section h3 {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    margin-bottom: 12px;
}

.setting-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-primary);
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-label {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.setting-label .name {
    font-size: 14px;
    font-weight: 500;
}

.setting-label .description {
    font-size: 12px;
    color: var(--text-muted);
}

/* Toggle Switch */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--bg-active);
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.toggle-slider::before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: var(--radius-full);
    transition: all var(--transition-fast);
}

.toggle-switch input:checked+.toggle-slider {
    background: var(--accent-primary);
}

.toggle-switch input:checked+.toggle-slider::before {
    transform: translateX(20px);
}

/* Select Dropdown */
.setting-select {
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    cursor: pointer;
    outline: none;
    transition: border-color var(--transition-fast);
}

.setting-select:focus {
    border-color: var(--border-focus);
}

.setting-select option {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* System Prompt */
.system-prompt-textarea {
    width: 100%;
    min-height: 150px;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 14px;
    font-family: inherit;
    resize: vertical;
    outline: none;
    transition: border-color var(--transition-fast);
}

.system-prompt-textarea:focus {
    border-color: var(--border-focus);
}

.save-prompt-btn {
    width: 100%;
    padding: 10px;
    margin-top: 12px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.save-prompt-btn:hover {
    box-shadow: var(--shadow-glow);
}

/* ============================================
   Documents Panel
   ============================================ */

.documents-section {
    margin-top: 24px;
}

.document-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 12px;
}

.document-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.document-item .icon {
    width: 20px;
    height: 20px;
    color: var(--accent-primary);
}

.document-item .info {
    flex: 1;
}

.document-item .name {
    font-size: 14px;
    font-weight: 500;
}

.document-item .meta {
    font-size: 12px;
    color: var(--text-muted);
}

.document-item .delete-btn {
    padding: 6px;
    background: transparent;
    border: none;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.document-item .delete-btn:hover {
    background: var(--bg-hover);
    color: var(--error);
}

.upload-btn {
    width: 100%;
    padding: 12px;
    background: var(--bg-tertiary);
    border: 2px dashed var(--border-secondary);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition-fast);
}

.upload-btn:hover {
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

/* ============================================
   Login Screen
   ============================================ */

.login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--bg-primary);
    padding: 24px;
}

.login-container {
    width: 100%;
    max-width: 400px;
}

.login-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    padding: 40px 32px;
    text-align: center;
}

.login-logo {
    width: 64px;
    height: 64px;
    margin: 0 auto 24px;
    background: var(--accent-gradient);
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.login-logo svg {
    width: 36px;
    height: 36px;
    color: white;
}

.login-title {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

.login-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    text-align: left;
}

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 6px;
    color: var(--text-secondary);
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 15px;
    outline: none;
    transition: border-color var(--transition-fast);
}

.form-input:focus {
    border-color: var(--border-focus);
}

.form-input::placeholder {
    color: var(--text-placeholder);
}

.login-btn {
    width: 100%;
    padding: 14px;
    margin-top: 8px;
    background: var(--accent-gradient);
    border: none;
    border-radius: var(--radius-md);
    color: white;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.login-btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-glow);
}

.login-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.login-error {
    margin-top: 16px;
    padding: 12px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid var(--error);
    border-radius: var(--radius-md);
    color: var(--error);
    font-size: 14px;
    display: none;
}

.login-error.visible {
    display: block;
}

/* ============================================
   Utilities & Animations
   ============================================ */

.hidden {
    display: none !important;
}

.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.slide-in {
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 90;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.overlay.visible {
    opacity: 1;
    visibility: visible;
}

/* Responsive */
/* Responsive Design */
@media (max-width: 768px) {

    /* Layout */
    .app-container {
        position: relative;
    }

    .main-content {
        width: 100% !important;
        margin-left: 0 !important;
    }

    /* Sidebar Mobile */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        width: 280px;
        box-shadow: 2px 0 12px rgba(0, 0, 0, 0.5);

    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar.collapsed {
        transform: translateX(-100%);
        width: 280px;

    }

    .sidebar.collapsed,
    .sidebar.collapsed * {
        display: none !important;
    }

    /* Overlay backdrop */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.6);
        z-index: 90;
        backdrop-filter: blur(2px);
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .sidebar.open+.main-content .sidebar-overlay,
    body.sidebar-open .sidebar-overlay {
        display: block;
        opacity: 1;
    }

    /* Header adjustments */
    .chat-header {
        padding: 0 12px;
        height: 56px;
    }

    .header-left {
        gap: 8px;
    }

    .model-select {
        max-width: 140px;
        font-size: 13px;
    }

    .quick-toggles {
        display: none;
        /* Hide quick toggles on mobile to save space */
    }

    /* Chat Area */
    .chat-container {
        padding: 0;
    }

    .chat-messages {
        padding: 16px;
        padding-bottom: 20px;
    }

    .message {
        padding: 0;
    }

    .message-avatar {
        width: 28px;
        height: 28px;
    }

    /* Input Area */
    .input-container {
        padding: 12px;
    }

    .input-box {
        padding: 8px 12px;
    }

    .message-input {
        max-height: 120px;
    }

    /* Settings Panel */
    .settings-panel {
        width: 100%;
        max-width: 100%;
        border-left: none;
    }

    /* Login Screen */
    .login-box {
        padding: 24px;
        margin: 16px;
    }

    .login-title {
        font-size: 24px;
    }
}

/* Loading spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border-primary);
    border-top-color: var(--accent-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Status indicator */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-full);
    font-size: 12px;
    color: var(--text-muted);
}

.status-indicator .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--success);
}

.status-indicator.searching .dot {
    background: var(--info);
    animation: pulse 1s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.4;
    }
}

/* ============================================
   Custom HTML Classes for AI Content
   ============================================ */

/* Info Boxes */
.info-box,
.success-box,
.warning-box,
.error-box {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin: 12px 0;
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.info-box {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
    color: #93c5fd;
}

.info-box::before {
    content: "ℹ️";
}

.success-box {
    background: rgba(16, 163, 127, 0.1);
    border: 1px solid rgba(16, 163, 127, 0.3);
    color: #6ee7b7;
}

.success-box::before {
    content: "✅";
}

.warning-box {
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    color: #fcd34d;
}

.warning-box::before {
    content: "⚠️";
}

.error-box {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fca5a5;
}

.error-box::before {
    content: "❌";
}

/* Cards */
.card {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 20px;
    margin: 12px 0;
    box-shadow: var(--shadow-md);
}

.card-header {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-primary);
}

/* Layout Classes */
.flex-row {
    display: flex;
    flex-direction: row;
    gap: 16px;
    flex-wrap: wrap;
}

.flex-col {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.grid-2 {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

@media (max-width: 768px) {

    .grid-2,
    .grid-3 {
        grid-template-columns: 1fr;
    }
}

/* Text Styling */
.text-gradient {
    background: var(--accent-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.text-glow {
    color: var(--accent-primary);
    text-shadow: 0 0 10px var(--accent-glow), 0 0 20px var(--accent-glow);
}

.text-xl {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.3;
}

.text-lg {
    font-size: 18px;
    font-weight: 600;
}

.text-sm {
    font-size: 13px;
}

.text-xs {
    font-size: 11px;
}

.text-muted {
    color: var(--text-muted);
}

.text-accent {
    color: var(--accent-primary);
}

.text-success {
    color: var(--success);
}

.text-warning {
    color: var(--warning);
}

.text-error {
    color: var(--error);
}

.text-info {
    color: var(--info);
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

/* Decorative Elements */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    background: var(--accent-gradient);
    color: white;
    border-radius: var(--radius-full);
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge.secondary {
    background: var(--bg-hover);
    color: var(--text-secondary);
}

.badge.success {
    background: var(--success);
}

.badge.warning {
    background: var(--warning);
    color: #000;
}

.badge.error {
    background: var(--error);
}

.divider {
    height: 1px;
    background: var(--border-primary);
    margin: 16px 0;
}

.divider.thick {
    height: 2px;
    background: var(--accent-gradient);
}

.highlight {
    background: rgba(16, 163, 127, 0.2);
    padding: 2px 6px;
    border-radius: 4px;
}

/* Spacing utilities */
.mt-1 {
    margin-top: 4px;
}

.mt-2 {
    margin-top: 8px;
}

.mt-3 {
    margin-top: 12px;
}

.mt-4 {
    margin-top: 16px;
}

.mb-1 {
    margin-bottom: 4px;
}

.mb-2 {
    margin-bottom: 8px;
}

.mb-3 {
    margin-bottom: 12px;
}

.mb-4 {
    margin-bottom: 16px;
}

.p-2 {
    padding: 8px;
}

.p-3 {
    padding: 12px;
}

.p-4 {
    padding: 16px;
}

/* Stats/Metric boxes */
.stat-box {
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    padding: 16px;
    text-align: center;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent-primary);
    line-height: 1.2;
}

.stat-label {
    font-size: 12px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

/* Quote styling */
.quote {
    border-left: 3px solid var(--accent-primary);
    padding-left: 16px;
    margin: 12px 0;
    font-style: italic;
    color: var(--text-secondary);
}

.quote-author {
    margin-top: 8px;
    font-style: normal;
    font-size: 13px;
    color: var(--text-muted);
}

/* Progress indicator */
.progress-bar {
    height: 8px;
    background: var(--bg-hover);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--accent-gradient);
    border-radius: var(--radius-full);
    transition: width 0.3s ease;
}

/* Timeline */
.timeline {
    border-left: 2px solid var(--border-primary);
    padding-left: 20px;
    margin-left: 8px;
}

.timeline-item {
    position: relative;
    margin-bottom: 20px;
}

.timeline-item::before {
    content: "";
    position: absolute;
    left: -26px;
    top: 4px;
    width: 12px;
    height: 12px;
    background: var(--accent-primary);
    border-radius: 50%;
}

.timeline-date {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 4px;
}

/* Comparison table enhancement */
.comparison-table {
    width: 100%;
    border-collapse: collapse;
}

.comparison-table th {
    background: var(--bg-hover);
    padding: 12px;
    text-align: left;
    font-weight: 600;
}

.comparison-table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-primary);
}

.comparison-table tr:hover td {
    background: var(--bg-hover);
}

/* Feature list */
.feature-list {
    list-style: none;
    padding: 0;
}

.feature-list li {
    padding: 8px 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.feature-list li::before {
    content: "✓";
    color: var(--success);
    font-weight: bold;
}

.feature-list li.negative::before {
    content: "✗";
    color: var(--error);
}

/* ============================================
   Typing Indicator & Streaming
   ============================================ */

.typing-indicator {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--accent-primary);
    border-radius: 50%;
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {

    0%,
    60%,
    100% {
        transform: translateY(0);
        opacity: 0.4;
    }

    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Streaming message fade-in effect */
.message.streaming .message-text {
    animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0.7;
    }

    to {
        opacity: 1;
    }
}

/* Dynamic message font size */
.message-text {
    font-size: var(--message-font-size);
}

/* Message spacing */
.message {
    margin-bottom: var(--message-spacing);
}

/* Custom UI Components for AI */
.custom-html-block {
    margin: 16px 0;
    width: 100%;
}

.custom-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-secondary);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    transition: transform var(--transition-fast);
}

.custom-card:hover {
    border-color: var(--accent-primary);
    transform: translateY(-2px);
}

.metric-box {
    text-align: center;
    padding: 12px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-primary);
}

.metric-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-primary);
    display: block;
}

.metric-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-top: 4px;
}

.alert-box {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: var(--bg-tertiary);
    border-left: 4px solid var(--text-muted);
    margin: 8px 0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-box.info {
    border-left-color: var(--accent-primary);
    background: rgba(var(--accent-primary-rgb), 0.1);
}

.alert-box.success {
    border-left-color: var(--success);
    background: rgba(34, 197, 94, 0.1);
}

.alert-box.warning {
    border-left-color: var(--warning);
    background: rgba(234, 179, 8, 0.1);
}

.alert-box.error {
    border-left-color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 9999px;
    font-size: 11px;
    font-weight: 600;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-secondary);
}

.badge.primary {
    background: var(--accent-primary);
    color: white;
    border: none;
}

.badge.outline {
    background: transparent;
    border-color: var(--accent-primary);
    color: var(--accent-primary);
}

.progress-bar {
    width: 100%;
    height: 8px;
    background: var(--bg-tertiary);
    border-radius: 9999px;
    overflow: hidden;
    margin: 8px 0;
}

.progress-bar>div {
    height: 100%;
    background: var(--accent-primary);
    border-radius: 9999px;
    transition: width 0.5s ease-out;
}


/* Toast Notification */
.toast-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    padding: 12px 20px;
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 12px;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast-notification.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-notification.success {
    border-bottom: 3px solid var(--success);
}

.toast-notification.error {
    border-bottom: 3px solid var(--error);
}

.toast-notification.info {
    border-bottom: 3px solid var(--info);
}


/* Custom Dropdown */
.custom-select-wrapper {
    position: relative;
    user-select: none;
    min-width: 160px;
}

.custom-select {
    position: relative;
    cursor: pointer;
}

.select-trigger {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
    background: transparent;
    border-radius: var(--radius-md);
    transition: all var(--transition-fast);
}

.select-trigger:hover {
    background: var(--bg-hover);
}

.custom-select.open .select-trigger {
    border-color: var(--accent-primary);
}

.select-options {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    margin-top: 4px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    overflow: hidden;
}

.custom-select.open .select-options {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.option {
    padding: 10px 12px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.option:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.option.selected {
    background: rgba(var(--accent-primary-rgb), 0.1);
    color: var(--accent-primary);
    font-weight: 500;
}

/* Code Block Styling */
.code-block-wrapper {
    background: #0d1117;
    border-radius: var(--radius-md);
    margin: 16px 0;
    overflow: hidden;
    border: 1px solid var(--border-primary);
}

.code-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: #161b22;
    border-bottom: 1px solid var(--border-primary);
    font-size: 12px;
    color: var(--text-secondary);
}

.code-lang {
    font-family: var(--font-mono);
    text-transform: uppercase;
}

.copy-btn {
    background: transparent;
    border: 1px solid var(--border-secondary);
    color: var(--text-secondary);
    border-radius: 4px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.copy-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--text-secondary);
}

.code-block-wrapper pre {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
}

.code-block-wrapper code {
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.5;
}

/* Edit Button in Sidebar */
.edit-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: all 0.2s;
    opacity: 0;
    /* Hidden by default until hover */
    margin-right: 4px;
}

.conversation-item:hover .edit-btn {
    opacity: 1;
}

.edit-btn:hover {
    color: var(--text-primary);
    background: var(--bg-hover);
}


/* Hidden Markers */
.hidden-marker {
    opacity: 0;
    width: 0;
    height: 0;
    display: inline-block;
    overflow: hidden;
    position: absolute;
    pointer-events: none;
}

/* HTML Sandbox System */
.html-sandbox-container {
    margin: 16px 0;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-md);
    background: #0d1117;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}

.html-sandbox-container.fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 0;
    border: none;
    z-index: 1000;
    margin: 0;
    height: 100vh;
}

.sandbox-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #161b22;
    border-bottom: 1px solid var(--border-primary);
}

.sandbox-title {
    font-size: 0.75rem;
    color: var(--text-secondary);
    font-family: var(--font-mono);
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.sandbox-controls {
    display: flex;
    gap: 8px;
}

.sandbox-btn {
    background: transparent;
    border: 1px solid var(--border-secondary);
    color: var(--text-secondary);
    border-radius: 4px;
    padding: 2px 8px;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
    font-family: var(--font-sans);
}

.sandbox-btn:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
    border-color: var(--accent-primary);
}

.sandbox-content {
    position: relative;
    width: 100%;
    height: 500px;
    /* Default height */
    background: white;
    /* Canvas background */
}

.html-sandbox-container.fullscreen .sandbox-content {
    height: 100%;
}

.sandbox-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* Loading/Preview State */
.sandbox-preview {
    padding: 16px;
    background: #0d1117;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 13px;
    height: 200px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid var(--border-primary);
}
