/* gibbwiz — gibb Bern branded chat UI */

/* Colors aligned with gibb.ch brand (--color-gibb: #0029ff) */
:root {
    --bg: #ffffff;
    --bg-secondary: #f5fafd;
    --bg-tertiary: #ebf3f8;
    --text: #22242b;
    --text-secondary: #8899a5;
    --accent: #0029ff;
    --accent-hover: #0024e1;
    --accent-light: #ebf3f8;
    --border: #d6e2ea;
    --user-bubble: #0029ff;
    --user-text: #ffffff;
    --assistant-bubble: #f5fafd;
    --assistant-text: #22242b;
    --danger: #eb1f4f;
    --success: #1bce8c;
    --warning: #f2d301;
    --gold: #bd9a52;
    --sidebar-width: 280px;
    --navbar-height: 56px;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);
    --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
}

[data-theme="dark"] {
    --bg: #22242b;
    --bg-secondary: #2a2d36;
    --bg-tertiary: #33363f;
    --text: #f5fafd;
    --text-secondary: #8899a5;
    --accent: #4d6fff;
    --accent-hover: #3b5ef0;
    --accent-light: #2a2d36;
    --border: #3d4050;
    --user-bubble: #4d6fff;
    --user-text: #ffffff;
    --assistant-bubble: #2a2d36;
    --assistant-text: #f5fafd;
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.4);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    overflow: hidden;
}

/* ── Navbar ───────────────────────────────────────────────────────────── */

.navbar {
    height: var(--navbar-height);
    background: var(--accent);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    box-shadow: var(--shadow);
}

.nav-brand a {
    text-decoration: none;
    color: var(--gold);
    font-size: 1.2rem;
}

.nav-subtitle {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.7);
    margin-left: 0.5rem;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-link {
    color: rgba(255,255,255,0.9);
    text-decoration: none;
    font-size: 0.875rem;
    padding: 0.3rem 0.6rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.nav-link:hover { background: rgba(255,255,255,0.15); }

.btn-nav {
    background: rgba(255,255,255,0.1);
    border: 1px solid rgba(255,255,255,0.2);
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.btn-nav:hover { background: rgba(255,255,255,0.2); }
.lang-label { font-weight: 600; font-size: 0.8rem; }

/* Profile dropdown */
.nav-profile {
    display: flex; align-items: center; gap: 0.4rem;
    cursor: pointer; position: relative;
    padding: 0.2rem 0.5rem; border-radius: var(--radius-sm);
    transition: background 0.15s;
}
.nav-profile:hover { background: rgba(255,255,255,0.15); }

.nav-avatar {
    width: 28px; height: 28px; border-radius: 50%; object-fit: cover;
    border: 2px solid rgba(255,255,255,0.4);
}
.nav-avatar-placeholder {
    width: 28px; height: 28px; border-radius: 50%;
    background: rgba(255,255,255,0.25); color: white;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.85rem;
}
.nav-username {
    font-size: 0.85rem; color: rgba(255,255,255,0.9);
    max-width: 100px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.profile-menu {
    display: none; position: absolute; top: 100%; right: 0;
    background: var(--bg); border: 1px solid var(--border);
    border-radius: var(--radius-sm); box-shadow: var(--shadow-lg);
    min-width: 140px; overflow: hidden; margin-top: 0.3rem; z-index: 200;
}
.profile-menu.show { display: block; }
.profile-menu a {
    display: block; padding: 0.6rem 1rem; color: var(--text);
    text-decoration: none; font-size: 0.85rem; transition: background 0.15s;
}
.profile-menu a:hover { background: var(--bg-secondary); }

/* ── Modal ────────────────────────────────────────────────────────── */
.modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); display: flex; align-items: center;
    justify-content: center; z-index: 1000;
}
.modal-content {
    background: var(--bg); border-radius: var(--radius); padding: 1.5rem;
    max-width: 420px; width: 90%; max-height: 85vh; overflow-y: auto;
}
.modal-content h3 { margin: 0 0 1rem; }
.form-group { margin-bottom: 1rem; }
.form-group label { display: block; font-size: 0.85rem; font-weight: 600; margin-bottom: 0.3rem; color: var(--text-secondary); }
.form-group input[type="text"],
.form-group input[type="password"] {
    width: 100%; padding: 0.5rem; border: 1px solid var(--border);
    border-radius: 6px; font-size: 0.9rem; background: var(--bg); color: var(--text);
}
.form-group textarea {
    width: 100%; padding: 0.5rem; border: 1px solid var(--border);
    border-radius: 6px; font-size: 0.85rem; resize: vertical;
    background: var(--bg); color: var(--text); font-family: var(--font);
}
.project-tips {
    background: var(--bg-secondary); border-radius: var(--radius-sm);
    padding: 0.75rem; margin-bottom: 1rem; font-size: 0.82rem;
}
.project-tips p { margin-bottom: 0.4rem; }
.project-tips ul { padding-left: 1.2rem; }
.project-tips li { margin-bottom: 0.3rem; }
.project-tips code {
    background: var(--bg-tertiary); padding: 0.1rem 0.3rem;
    border-radius: 3px; font-family: var(--font-mono); font-size: 0.8rem;
}
.form-actions { display: flex; gap: 0.5rem; justify-content: flex-end; margin-top: 1rem; }
.form-actions button { padding: 0.5rem 1rem; border-radius: 6px; cursor: pointer; font-size: 0.9rem; }
.btn-primary { background: var(--accent); color: white; border: none; }
.btn-secondary { background: var(--bg-secondary); color: var(--text); border: 1px solid var(--border); }

.avatar-upload { display: flex; align-items: center; gap: 1rem; }
.avatar-preview {
    width: 60px; height: 60px; border-radius: 50%; background: var(--bg-secondary);
    display: flex; align-items: center; justify-content: center; overflow: hidden;
    border: 2px solid var(--border); font-size: 1.5rem; font-weight: 700; color: var(--text-secondary);
}
.avatar-preview img { width: 100%; height: 100%; object-fit: cover; }
.avatar-upload input[type="file"] { font-size: 0.85rem; }

/* ── Main content ────────────────────────────────────────────────────── */

.main-content {
    margin-top: var(--navbar-height);
    height: calc(100vh - var(--navbar-height));
}

/* ── Chat layout ─────────────────────────────────────────────────────── */

.chat-layout {
    display: flex;
    height: 100%;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    overflow-y: auto;
    flex-shrink: 0;
    transition: margin-left 0.2s ease, opacity 0.2s ease;
}

.sidebar.collapsed {
    margin-left: calc(-1 * var(--sidebar-width));
    opacity: 0;
    pointer-events: none;
}

.sidebar-header {
    display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem;
}
.sidebar-action-btn {
    background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; padding: 6px 10px; font-size: 1rem; color: var(--text-secondary);
    transition: background 0.15s; position: relative;
}
.sidebar-action-btn:hover { background: var(--bg-tertiary); }
.sidebar-action-btn:hover::after {
    content: attr(title);
    position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    background: var(--text); color: var(--bg); padding: 0.3rem 0.6rem;
    border-radius: 4px; font-size: 0.75rem; white-space: nowrap;
    margin-top: 4px; z-index: 100; pointer-events: none;
}

.sidebar-sections { flex: 1; overflow-y: auto; }

.sidebar-divider {
    padding: 0.5rem 0.6rem 0.2rem; font-size: 0.7rem;
    text-transform: uppercase; letter-spacing: 0.05em;
    color: var(--text-secondary); border-top: 1px solid var(--border);
    margin-top: 0.5rem;
}

/* Projects */
.project-item { margin-bottom: 2px; }
.project-header {
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.4rem 0.6rem; border-radius: var(--radius-sm);
    cursor: pointer; font-size: 0.825rem; transition: background 0.15s;
}
.project-header:hover { background: var(--bg-tertiary); }
.project-icon { font-size: 0.9rem; }
.project-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; }
.project-badge {
    font-size: 0.7rem; background: var(--bg-tertiary); padding: 0.1rem 0.4rem;
    border-radius: 10px; color: var(--text-secondary);
}
.project-actions { display: flex; gap: 2px; opacity: 0; transition: opacity 0.15s; }
.project-header:hover .project-actions { opacity: 1; }
.project-actions button {
    background: none; border: none; cursor: pointer; font-size: 0.75rem;
    padding: 0 3px; color: var(--text-secondary);
}

.new-project-inline {
    display: flex; align-items: center; gap: 0.4rem;
    padding: 0.4rem 0.6rem; margin-bottom: 2px;
}
.new-project-inline input {
    flex: 1; padding: 0.3rem 0.5rem; border: 1px solid var(--accent);
    border-radius: var(--radius-sm); font-size: 0.825rem;
    background: var(--bg); color: var(--text); outline: none;
}

.project-contents { padding-left: 1.2rem; }
.project-file-item {
    display: flex; align-items: center; gap: 0.3rem;
    padding: 0.2rem 0.4rem; font-size: 0.78rem; border-radius: 4px;
}
.project-file-item:hover { background: var(--bg-tertiary); }
.file-icon { font-size: 0.75rem; }
.file-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    color: var(--accent); text-decoration: none; font-size: 0.78rem; }
.file-size { font-size: 0.7rem; color: var(--text-secondary); }
.file-delete { background: none; border: none; cursor: pointer; font-size: 0.8rem;
    color: var(--text-secondary); opacity: 0; transition: opacity 0.15s; }
.project-file-item:hover .file-delete { opacity: 1; }

.project-convos .conversation-item { padding-left: 0.3rem; }

/* File viewer modal */
.file-viewer { max-width: 700px; width: 95%; }
.file-viewer-header {
    display: flex; align-items: baseline; gap: 0.75rem; margin-bottom: 0.75rem;
}
.file-viewer-header h3 { margin: 0; }
.file-viewer-meta { font-size: 0.75rem; color: var(--text-secondary); }
.file-editor {
    width: 100%; min-height: 300px; max-height: 60vh;
    padding: 0.75rem; border: 1px solid var(--border); border-radius: var(--radius-sm);
    font-family: var(--font-mono); font-size: 0.85rem; line-height: 1.5;
    background: var(--bg-secondary); color: var(--text); resize: vertical;
    tab-size: 4; white-space: pre; overflow-wrap: normal; overflow-x: auto;
}

.sidebar-collapse {
    background: none; border: 1px solid var(--border); border-radius: var(--radius-sm);
    cursor: pointer; padding: 4px 8px; font-size: 0.9rem; color: var(--text-secondary);
    transition: background 0.15s;
}
.sidebar-collapse:hover { background: var(--bg-tertiary); }

.sidebar-expand {
    display: none;
    position: fixed;
    top: calc(var(--navbar-height) + 8px);
    left: 8px;
    z-index: 50;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 6px 10px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    box-shadow: var(--shadow);
    transition: opacity 0.2s;
}
.sidebar-expand:hover { background: var(--bg-tertiary); }

.sidebar.collapsed ~ .sidebar-expand {
    display: block;
}

.btn-new-chat {
    width: 100%;
    padding: 0.6rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    transition: background 0.15s;
}

.btn-new-chat:hover { background: var(--accent-hover); }

.conversation-list { flex: 1; overflow-y: auto; }

.conversation-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.6rem;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.825rem;
    color: var(--text);
    transition: background 0.15s;
    margin-bottom: 2px;
}

.conversation-item:hover, .conversation-item.active {
    background: var(--bg-tertiary);
}

.conv-title {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
}

.conv-actions {
    display: flex; align-items: center; gap: 2px;
    opacity: 0; transition: opacity 0.15s;
}
.conversation-item:hover .conv-actions { opacity: 1; }

.conv-rate, .conv-delete {
    background: none; border: none; color: var(--text-secondary);
    cursor: pointer; font-size: 0.75rem; padding: 0 3px;
}
.conv-rate:hover { transform: scale(1.2); }
.conv-delete { font-size: 1rem; }
.conv-rated { font-size: 0.75rem; font-weight: 600; }

/* ── Chat area ───────────────────────────────────────────────────────── */

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    scroll-behavior: smooth;
}

.welcome-message {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-secondary);
}

.welcome-message h2 {
    color: var(--text);
    margin-bottom: 0.75rem;
}

.welcome-message p { margin-bottom: 0.5rem; }

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1.5rem;
}

.suggestion-chips button {
    padding: 0.5rem 1rem;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.825rem;
    color: var(--text);
    transition: all 0.15s;
}

.suggestion-chips button:hover {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

/* ── Messages ────────────────────────────────────────────────────────── */

.message {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    max-width: 800px;
    margin-left: auto;
    margin-right: auto;
}

.message-avatar {
    width: 32px;
    height: 32px;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.chat-avatar-img {
    width: 32px; height: 32px; border-radius: 50%; object-fit: cover;
}

.message-body {
    flex: 1; min-width: 0;
}

.message-bubble {
    padding: 0.75rem 1rem;
    border-radius: var(--radius);
    line-height: 1.6;
    font-size: 0.925rem;
    max-width: 100%;
    overflow-wrap: break-word;
}

.message-user .message-bubble {
    background: var(--user-bubble);
    color: var(--user-text);
    border-bottom-left-radius: 4px;
}

.message-assistant .message-bubble {
    background: var(--assistant-bubble);
    color: var(--assistant-text);
    border-bottom-left-radius: 4px;
}

/* Markdown in assistant messages */
.message-assistant .message-bubble h1,
.message-assistant .message-bubble h2,
.message-assistant .message-bubble h3 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
}

.message-assistant .message-bubble p { margin-bottom: 0.5rem; }
.message-assistant .message-bubble p:last-child { margin-bottom: 0; }

.message-assistant .message-bubble ul,
.message-assistant .message-bubble ol {
    padding-left: 1.5rem;
    margin-bottom: 0.5rem;
}

.message-assistant .message-bubble pre {
    background: #1e1e2e;
    color: #cdd6f4;
    padding: 0.75rem 1rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 0.5rem 0;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.message-assistant .message-bubble code {
    font-family: var(--font-mono);
    font-size: 0.85em;
}

.message-assistant .message-bubble :not(pre) > code {
    background: var(--bg-tertiary);
    padding: 0.15rem 0.35rem;
    border-radius: 4px;
}

.message-assistant .message-bubble a {
    color: var(--accent);
    text-decoration: underline;
}

.message-assistant .message-bubble blockquote {
    border-left: 3px solid var(--accent);
    padding-left: 0.75rem;
    color: var(--text-secondary);
    margin: 0.5rem 0;
}

/* Streaming cursor */
.streaming .cursor {
    animation: blink 0.8s infinite;
    color: var(--accent);
}

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* ── Input area ──────────────────────────────────────────────────────── */

.input-area {
    padding: 0.75rem 1.5rem 1.25rem;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
}

#chat-form {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.5rem;
    transition: border-color 0.15s;
}

#chat-form:focus-within { border-color: var(--accent); }

#message-input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    color: var(--text);
    font-family: var(--font);
    font-size: 0.925rem;
    padding: 0.4rem 0.5rem;
    resize: none;
    line-height: 1.5;
    max-height: 200px;
}

#message-input::placeholder { color: var(--text-secondary); }

.btn-send {
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    width: 36px;
    height: 36px;
    cursor: pointer;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s;
}

.btn-send:hover { background: var(--accent-hover); }
.btn-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* ── Auth pages ──────────────────────────────────────────────────────── */

.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 1rem;
}

.auth-card {
    width: 100%;
    max-width: 400px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    padding: 2rem;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.auth-header h1 { font-size: 2rem; margin-bottom: 0.25rem; }
.auth-header p { color: var(--text-secondary); font-size: 0.9rem; }

.auth-tabs {
    display: flex;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border);
}

.tab {
    flex: 1;
    padding: 0.6rem;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.925rem;
    color: var(--text-secondary);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.15s;
}

.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.auth-form { display: flex; flex-direction: column; gap: 0.75rem; }
.auth-form.hidden { display: none; }

.auth-form input {
    padding: 0.7rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 0.925rem;
    background: var(--bg);
    color: var(--text);
    outline: none;
    transition: border-color 0.15s;
}

.auth-form input:focus { border-color: var(--accent); }

.btn-primary {
    padding: 0.7rem;
    background: var(--accent);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.925rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
}

.btn-primary:hover { background: var(--accent-hover); }

.error-msg {
    padding: 0.6rem;
    background: #fef2f2;
    color: var(--danger);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    text-align: center;
    margin-top: 0.75rem;
}

[data-theme="dark"] .error-msg { background: #2a1515; }
.hidden { display: none !important; }

/* ── Admin pages ─────────────────────────────────────────────────────── */

.admin-container {
    max-width: 900px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
    overflow-y: auto;
    height: 100%;
}

.admin-container h1 { margin-bottom: 1.5rem; }
.admin-container h2 { margin-top: 2rem; margin-bottom: 1rem; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1.25rem;
    text-align: center;
}

.stat-number {
    font-size: 2rem;
    font-weight: 700;
    color: var(--accent);
}

.stat-label {
    font-size: 0.825rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.admin-table th, .admin-table td {
    padding: 0.6rem 0.75rem;
    border-bottom: 1px solid var(--border);
    text-align: left;
}

.admin-table th {
    font-weight: 600;
    background: var(--bg-secondary);
}

.badge {
    padding: 0.2rem 0.5rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.badge-admin { background: #fef3c7; color: #92400e; }
.badge-teacher { background: #dbeafe; color: #1e40af; }
.badge-student { background: #d1fae5; color: #065f46; }

[data-theme="dark"] .badge-admin { background: #422006; color: #fbbf24; }
[data-theme="dark"] .badge-teacher { background: #172554; color: #60a5fa; }
[data-theme="dark"] .badge-student { background: #052e16; color: #34d399; }

.btn-small {
    padding: 0.3rem 0.6rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--text);
    transition: all 0.15s;
}

.btn-small:hover { background: var(--accent-light); border-color: var(--accent); }

.btn-secondary {
    display: inline-block;
    padding: 0.6rem 1rem;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.15s;
}

.btn-secondary:hover { background: var(--accent-light); border-color: var(--accent); }

.btn-back {
    display: inline-block;
    color: var(--accent);
    text-decoration: none;
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.admin-nav { margin-top: 2rem; }

/* ── Responsive ──────────────────────────────────────────────────────── */

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: -100%;
        top: var(--navbar-height);
        height: calc(100vh - var(--navbar-height));
        z-index: 50;
        transition: left 0.2s;
        box-shadow: var(--shadow-lg);
    }

    .sidebar.open { left: 0; }
    .sidebar-toggle { display: block; }

    .messages { padding: 1rem; }
    .input-area { padding: 0.5rem; }

    .stats-grid { grid-template-columns: repeat(2, 1fr); }

    .nav-subtitle { display: none; }
}

/* ── Preset selector ─────────────────────────────────────────────── */
.preset-bar {
    display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border);
}
.preset-btn {
    display: flex; align-items: center; gap: 0.3rem; cursor: pointer;
    padding: 0.3rem 0.8rem; border: 1px solid var(--border); border-radius: 16px;
    background: var(--bg); color: var(--text); font-size: 0.85rem;
    transition: background 0.2s, border-color 0.2s;
    user-select: none;
}
.preset-btn:hover { background: var(--bg-secondary); }
.preset-btn.active {
    background: var(--accent); color: white; border-color: var(--accent);
}
.custom-prompt-input {
    flex: 1; min-width: 150px; padding: 0.3rem 0.6rem;
    border: 1px solid var(--border); border-radius: 16px;
    font-size: 0.85rem; background: var(--bg); color: var(--text);
}

/* ── Feedback + Copy buttons ──────────────────────────────────────── */
.feedback-bar {
    display: flex; gap: 0.3rem; padding: 0.2rem 0 0 0;
    opacity: 0.4; transition: opacity 0.2s;
}
.message:hover .feedback-bar { opacity: 1; }
.feedback-bar button {
    background: none; border: none; border-radius: 4px;
    padding: 0.15rem 0.35rem; cursor: pointer; font-size: 0.75rem;
    color: var(--text-secondary); transition: background 0.15s;
}
.feedback-bar button:hover { background: var(--bg-tertiary); }

.feedback-modal {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5); display: flex; align-items: center;
    justify-content: center; z-index: 1000;
}
.feedback-modal-content {
    background: var(--bg); border-radius: 12px; padding: 1.5rem;
    max-width: 400px; width: 90%;
}
.feedback-modal-content h3 { margin: 0 0 1rem; }
.feedback-categories {
    display: flex; flex-wrap: wrap; gap: 0.5rem; margin-bottom: 1rem;
}
.feedback-categories button {
    padding: 0.4rem 0.8rem; border: 1px solid var(--border);
    border-radius: 6px; background: var(--bg-secondary); cursor: pointer;
    font-size: 0.85rem; transition: background 0.2s;
}
.feedback-categories button:hover { background: var(--accent); color: white; }
.feedback-modal-content textarea {
    width: 100%; padding: 0.5rem; border: 1px solid var(--border);
    border-radius: 6px; margin-bottom: 1rem; font-size: 0.85rem;
    background: var(--bg); color: var(--text);
}
.feedback-actions { display: flex; gap: 0.5rem; justify-content: flex-end; }
.feedback-actions button { padding: 0.4rem 1rem; border-radius: 6px; cursor: pointer; }
.btn-primary { background: var(--accent); color: white; border: none; }

/* ── Image paste previews ────────────────────────────────────────── */
.image-previews {
    display: flex; gap: 0.5rem; padding: 0.5rem 1rem; overflow-x: auto;
}
.image-preview {
    position: relative; flex-shrink: 0;
}
.image-preview img {
    height: 60px; border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.image-preview button {
    position: absolute; top: -6px; right: -6px;
    background: var(--danger); color: white; border: none; border-radius: 50%;
    width: 18px; height: 18px; font-size: 0.7rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}

/* ── Tool status indicator ────────────────────────────────────────── */
.tool-status {
    color: var(--text-secondary); font-size: 0.9rem; font-style: italic;
    padding: 0.3rem 0; animation: pulse 1.5s ease-in-out infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* ── Bug Screenshot Zone ─────────────────────────────────────────── */
.bug-screenshot-zone {
    border: 2px dashed var(--border); border-radius: var(--radius-sm);
    padding: 0.75rem 1rem; cursor: pointer; transition: border-color 0.15s, background 0.15s;
    min-height: 60px; display: flex; align-items: center; flex-wrap: wrap; gap: 0.5rem;
}
.bug-screenshot-zone:hover { border-color: var(--accent); background: var(--accent-light); }
.bug-screenshot-zone.drag-over { border-color: var(--accent); background: var(--accent-light); }

.bug-zone-hint {
    font-size: 0.82rem; color: var(--text-secondary); pointer-events: none; user-select: none;
}

.bug-thumbs { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.bug-thumb {
    position: relative; flex-shrink: 0;
}
.bug-thumb img {
    height: 64px; width: 64px; object-fit: cover;
    border-radius: var(--radius-sm); border: 1px solid var(--border); display: block;
}
.bug-thumb button {
    position: absolute; top: -6px; right: -6px;
    background: var(--danger); color: white; border: none; border-radius: 50%;
    width: 18px; height: 18px; font-size: 0.75rem; cursor: pointer;
    display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.bug-thumb-num {
    position: absolute; bottom: 2px; left: 4px;
    font-size: 0.65rem; font-weight: 700; color: white;
    text-shadow: 0 1px 2px rgba(0,0,0,0.7);
}
