/* NARAD full-screen chat page (/chat) — ChatGPT/Claude-style layout on
   the dark NARAD theme. Reuses :root tokens + buttons from style.css;
   this file only adds the chat-page layout. (26 Nov 2026) */

html, body { height: 100%; }

body.chat-page { overflow: hidden; }

/* style.css sets `main { max-width: 1240px; ... }` for the dashboard;
   the chat page needs the full width. */
.chat-page main.chat-main { max-width: none; margin: 0; padding: 0; }

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

/* ---------- Sidebar ---------- */
.chat-sidebar {
    width: 280px;
    flex-shrink: 0;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.chat-sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--border);
}

.chat-new-btn { margin: 14px 14px 4px; }

.conv-list-label {
    padding: 12px 18px 4px;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted);
}

.conv-list {
    flex: 1;
    overflow-y: auto;
    padding: 4px 10px 12px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.conv-item {
    padding: 9px 10px;
    border-radius: 8px;
    cursor: pointer;
    border: 1px solid transparent;
}

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

.conv-item.active {
    background: var(--accent-violet-soft);
    border-color: rgba(139, 92, 246, 0.35);
}

.conv-title {
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.conv-time { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.conv-empty { padding: 12px; font-size: 13px; color: var(--text-muted); }

.chat-sidebar-footer {
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.sidebar-link { font-size: 13px; }

.sidebar-model { font-size: 11.5px; color: var(--text-muted); }

.sidebar-backdrop { display: none; }

/* ---------- Main column ---------- */
.chat-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background: var(--bg);
}

.chat-topbar {
    height: 56px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 16px;
    border-bottom: 1px solid var(--border);
}

.chat-topbar-title { font-size: 15px; font-weight: 700; }

.chat-model-badge {
    font-size: 11px;
    font-weight: 600;
    color: var(--accent-cyan);
    background: var(--accent-cyan-soft);
    border: 1px solid rgba(34, 211, 238, 0.35);
    padding: 2px 8px;
    border-radius: 999px;
    margin-left: 6px;
    vertical-align: 1px;
}

.chat-model-select {
    font-size: 12px;
    font-weight: 600;
    color: var(--accent-cyan);
    background: var(--accent-cyan-soft);
    border: 1px solid rgba(34, 211, 238, 0.35);
    padding: 3px 6px;
    border-radius: 999px;
    margin-left: 6px;
    vertical-align: 1px;
    cursor: pointer;
    max-width: 170px;
}

.chat-topbar-link { margin-left: auto; font-size: 13px; }

.icon-btn {
    display: none;
    background: none;
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    width: 36px;
    height: 36px;
    font-size: 17px;
    cursor: pointer;
}

.sidebar-close {
    display: none;
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 16px;
    cursor: pointer;
    padding: 4px;
}

/* ---------- Thread ---------- */
.chat-thread { flex: 1; overflow-y: auto; }

.chat-messages-col {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 26px;
}

.chat-msg { line-height: 1.65; font-size: 14.5px; }

.chat-msg-user {
    align-self: flex-end;
    max-width: 78%;
    background: var(--accent-violet-soft);
    border: 1px solid rgba(139, 92, 246, 0.4);
    border-radius: 18px 18px 4px 18px;
    padding: 10px 14px;
    white-space: pre-wrap;
    word-break: break-word;
}

.chat-msg-assistant { display: flex; gap: 12px; align-items: flex-start; }

.chat-avatar {
    width: 30px;
    height: 30px;
    flex-shrink: 0;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.chat-msg-actions { display: flex; gap: 6px; margin-top: 8px; }

.chat-action-btn {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-muted);
    font-size: 11.5px;
    padding: 3px 9px;
    border-radius: 6px;
    cursor: pointer;
}

.chat-action-btn:hover { color: var(--text); border-color: var(--border-strong); }

.chat-stopped-note {
    margin-top: 8px;
    font-size: 12px;
    color: var(--accent-amber);
}

/* ---------- Markdown (assistant replies) ---------- */
.chat-md h1 { font-size: 20px; margin: 2px 0 10px; }
.chat-md h2 { font-size: 17px; margin: 2px 0 10px; }
.chat-md h3 { font-size: 15px; margin: 2px 0 8px; }
.chat-md p { margin: 0 0 10px; }
.chat-md p:last-child { margin-bottom: 0; }
.chat-md ul, .chat-md ol { margin: 0 0 10px; padding-left: 22px; }
.chat-md li { margin: 3px 0; }
.chat-md code {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: 5px;
    padding: 1px 5px;
}
.chat-md pre {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px 14px;
    overflow-x: auto;
    position: relative;
    margin: 0 0 10px;
}
.chat-md pre code { background: none; border: none; padding: 0; font-size: 12.5px; }
.chat-md .code-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.chat-md .code-lang { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.chat-md .copy-code-btn {
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    color: var(--text-secondary);
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 6px;
    cursor: pointer;
}
.chat-md .copy-code-btn:hover { color: var(--text); }
.chat-md blockquote {
    border-left: 3px solid var(--accent-violet);
    padding-left: 12px;
    color: var(--text-secondary);
    margin: 0 0 10px;
}
.chat-md a { color: var(--accent-cyan); }
.chat-md table { border-collapse: collapse; margin: 0 0 10px; }
.chat-md th, .chat-md td { border: 1px solid var(--border); padding: 6px 10px; font-size: 13px; text-align: left; }
.chat-md hr { border: none; border-top: 1px solid var(--border); margin: 14px 0; }
.chat-md .stream-text { white-space: pre-wrap; word-break: break-word; }

/* ---------- Welcome / empty state ---------- */
.chat-welcome {
    max-width: 800px;
    margin: 0 auto;
    padding: 72px 20px 20px;
    text-align: center;
}

.welcome-logo { width: 64px; height: 64px; border-radius: 16px; margin-bottom: 16px; }

.chat-welcome h2 { font-size: 24px; margin-bottom: 6px; }

.chat-welcome p { color: var(--text-secondary); }

.welcome-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 22px;
}

.welcome-chip {
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 8px 14px;
    border-radius: 999px;
    cursor: pointer;
    font-size: 13px;
}

.welcome-chip:hover { border-color: var(--accent-violet); color: var(--text); }

/* ---------- Composer ---------- */
.chat-composer-wrap { padding: 10px 16px 14px; flex-shrink: 0; }

.chat-composer {
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg-elevated);
    border: 1px solid var(--border-strong);
    border-radius: 18px;
    padding: 10px 12px;
}

.chat-composer:focus-within { border-color: var(--accent-violet); }

.chat-composer textarea {
    flex: 1;
    background: none;
    border: none;
    outline: none;
    resize: none;
    color: var(--text);
    font-family: var(--font-sans);
    font-size: 14.5px;
    line-height: 1.55;
    max-height: 200px;
    padding: 4px 2px;
}

.chat-composer textarea::placeholder { color: var(--text-muted); }

.chat-send-btn {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #4385ff, #8b5cf6);
    color: #fff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(67, 133, 255, 0.45);
    transition: filter 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.chat-send-btn:hover:not(:disabled) {
    filter: brightness(1.1);
    transform: translateY(-1px);
    box-shadow: 0 6px 18px rgba(67, 133, 255, 0.55);
}

.chat-send-btn:active:not(:disabled) {
    transform: translateY(0) scale(0.94);
    box-shadow: 0 2px 8px rgba(67, 133, 255, 0.4);
}

.chat-send-btn:disabled {
    background: linear-gradient(135deg, #3a4356, #4a4458);
    opacity: 0.55;
    box-shadow: none;
    cursor: default;
    transform: none;
}

.chat-stop-btn {
    flex-shrink: 0;
    background: none;
    border: 1px solid var(--accent-rose);
    color: var(--accent-rose);
    font-size: 12.5px;
    padding: 8px 12px;
    border-radius: 999px;
    cursor: pointer;
}

.chat-composer-hint {
    max-width: 800px;
    margin: 8px auto 0;
    text-align: center;
    font-size: 11.5px;
    color: var(--text-muted);
}

/* ---------- Mobile: sidebar becomes a drawer ---------- */
@media (max-width: 900px) {
    .chat-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-102%);
        transition: transform 0.2s ease;
        box-shadow: var(--shadow);
    }
    .chat-sidebar.open { transform: none; }
    .sidebar-backdrop.show {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.55);
        z-index: 90;
    }
    .icon-btn { display: block; }
    .sidebar-close { display: block; }
    .chat-msg-user { max-width: 88%; }
    .chat-messages-col { padding: 18px 14px 12px; }
    .chat-welcome { padding-top: 48px; }
}

/* Fallback badge + private-history notice (Nov 2026 secfix) */
.chat-fallback-badge { display: inline-block; margin-top: 8px; font-size: 11px; font-weight: 600; color: #fbbf24; background: rgba(251, 191, 36, 0.13); border: 1px solid rgba(251, 191, 36, 0.35); padding: 2px 8px; border-radius: 999px; }
.chat-notice { margin: 12px auto; max-width: 720px; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px; color: var(--text-muted); font-size: 13px; text-align: center; }
