/* ============================================================
   styles.css — Phase 6
   Pure CSS. No frameworks. Mobile-first responsive design.
   ============================================================ */

/* ---------- Design system (CSS custom properties) ---------- */
:root {
    --bg:        #0d0d0f;
    --surface:   #161618;
    --surface-2: #1c1c20;
    --border:    #222228;
    --text:      #e0e0e8;
    --muted:     #555566;
    --accent:    #3b82f6;    /* overridden by JS from /config */
    --user-bg:   #1d4ed8;
    --radius:    12px;
    --radius-sm: 8px;
    --font:      -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Helvetica Neue", Arial, sans-serif;
    --transition: 0.2s ease;
}

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

html, body {
    height: 100dvh;
    overflow: hidden;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: var(--font);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* ---------- Layout ---------- */
.container {
    max-width: 680px;
    width: 100%;
    height: 100dvh;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    padding: 20px 16px 12px;
}

/* ---------- Header ---------- */
#site-header {
    text-align: center;
    padding-bottom: 16px;
    flex-shrink: 0;
}

#avatar-wrap {
    margin-bottom: 10px;
}

#avatar-img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--border);
}

#bot-title {
    font-size: 22px;
    font-weight: 600;
    color: #fff;
    line-height: 1.3;
}

#bot-subtitle {
    font-size: 13px;
    color: var(--muted);
    margin-top: 4px;
}

/* ---------- Suggestion chips ---------- */
.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    padding-bottom: 12px;
    flex-shrink: 0;
}

.chip {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    font-family: var(--font);
    cursor: pointer;
    transition: background var(--transition), border-color var(--transition);
    white-space: nowrap;
}

.chip:hover {
    background: var(--surface-2);
    border-color: var(--accent);
}

/* ---------- Chat area ---------- */
.chat {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 8px 0;
    scroll-behavior: smooth;
}

/* Custom scrollbar */
.chat::-webkit-scrollbar { width: 4px; }
.chat::-webkit-scrollbar-track { background: transparent; }
.chat-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ---------- Message bubbles ---------- */
.msg {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeIn 0.25s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.msg.user {
    align-self: flex-end;
    align-items: flex-end;
}

.msg.bot {
    align-self: flex-start;
    align-items: flex-start;
}

.msg-body {
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 14px;
    line-height: 1.5;
    word-wrap: break-word;
}

.msg.user .msg-body {
    background: var(--user-bg);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.msg.bot .msg-body {
    background: var(--surface);
    border: 1px solid var(--border);
    border-bottom-left-radius: 4px;
}

/* Sources under bot messages */
.msg-sources {
    font-size: 11px;
    color: var(--muted);
    margin-top: 4px;
    padding: 0 4px;
}

.msg-sources span {
    display: inline-block;
    background: var(--surface-2);
    border-radius: 4px;
    padding: 1px 6px;
    margin: 2px 2px 0 0;
}

/* Listen button */
.listen-btn {
    background: none;
    border: none;
    color: var(--muted);
    font-size: 12px;
    cursor: pointer;
    padding: 2px 4px;
    margin-top: 2px;
    font-family: var(--font);
    transition: color var(--transition);
}

.listen-btn:hover { color: var(--accent); }

/* Hide voice controls when disabled via config */
.voice-disabled .listen-btn { display: none; }

/* Error message */
.msg.error .msg-body {
    background: #2a1515;
    border-color: #5c2020;
    color: #fca5a5;
}

/* ---------- Typing indicator ---------- */
.typing {
    display: flex;
    gap: 5px;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    margin: 4px 0;
}

.typing-dot {
    width: 7px;
    height: 7px;
    background: var(--muted);
    border-radius: 50%;
    animation: bounce 1.2s infinite;
}

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%            { transform: translateY(-6px); }
}

/* ---------- Input row ---------- */
.input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

textarea {
    flex: 1;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    font-family: var(--font);
    font-size: 14px;
    line-height: 1.4;
    resize: none;
    outline: none;
    max-height: 80px;
    transition: border-color var(--transition);
    overflow-y: auto;
}

textarea:focus { border-color: var(--accent); }
textarea::placeholder { color: var(--muted); }

.icon-btn {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    flex-shrink: 0;
    transition: background var(--transition), border-color var(--transition);
    padding: 0;
}

.icon-btn:hover {
    background: var(--surface-2);
    border-color: var(--accent);
}

.icon-btn.on {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.send-btn {
    background: var(--accent);
    border-color: var(--accent);
    color: #fff;
}

.send-btn:hover {
    filter: brightness(1.1);
}

/* ---------- Responsive ---------- */
@media (max-width: 480px) {
    .container { padding: 12px 10px 8px; }
    #bot-title { font-size: 18px; }
    .msg { max-width: 90%; }
    .chip { font-size: 12px; padding: 5px 10px; }
}
