/* TaxVector Brand Theme — navy/blue professional palette
   Design reference: docs/2 UX_UI_Design/ChatBox.png
   Bootstrap 5 provides utilities/reset; this file defines visual identity */

/* ── Color palette ── */
:root {
    --black: #1e3a8a;
    --black-soft: #2d4fa0;
    --off-white: #f4f6fb;
    --warm-white: #ffffff;
    --cream: #edf1f8;
    --border: #dde3f0;
    --border2: #c8d2e6;
    --accent: #2563eb;
    --accent-light: #eff4ff;
    --amber: #c8860a;
    --amber-light: #fdf4e0;
    --text: #0d1b2e;
    --text-mid: #374563;
    --muted: #6b7a9a;
}

body {
    background: var(--off-white);
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: var(--text);
}

/* Card-on-background: only when chat is shown */
body:has(.chat-layout) {
    background: #c5cfe8;
    overflow: hidden;
    height: 100vh;
}

/* ── Auth pages (login, register) ── */
.auth-page {
    min-height: 85vh;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 2rem 1rem;
}

.auth-wordmark {
    display: flex; flex-direction: column; align-items: center; gap: 16px;
    margin-bottom: 32px;
}

.auth-logo-img {
    width: 140px;
    height: auto;
    object-fit: contain;
}

.wm-name {
    font-family: 'Playfair Display', serif;
    font-size: 1.55rem; color: var(--black);
    letter-spacing: -0.02em; line-height: 1;
}

.wm-sub {
    font-size: 0.69rem; font-weight: 700;
    letter-spacing: 0.1em; text-transform: uppercase;
    color: var(--muted); margin-top: 3px;
}

.auth-card {
    width: 440px; max-width: 100%;
    background: var(--warm-white); border-radius: 20px;
    border: 1px solid var(--border2);
    box-shadow: 0 1px 2px rgba(0,0,0,0.04), 0 8px 24px rgba(0,0,0,0.08);
    padding: 2rem;
}

.auth-card h1 {
    font-family: 'Playfair Display', serif;
    font-size: 1.3rem; text-align: center; margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
    display: flex; flex-direction: column;
}

.auth-card .form-label {
    font-weight: 600; font-size: 0.85rem; color: var(--text-mid);
    margin-bottom: 0.5rem;
    display: block;
}

.auth-card .form-control {
    background: var(--off-white); border: 1.5px solid var(--border2);
    border-radius: 12px; padding: 0.75rem 1rem;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.9rem;
    width: 100%;
}

.auth-card .form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(37,99,235,0.15);
    background: var(--warm-white);
    outline: none;
}

.btn-taxpal {
    background: var(--accent); border: none; color: #fff;
    font-weight: 700; border-radius: 12px; padding: 0.75rem;
    width: 100%; transition: background 0.15s;
}

.btn-taxpal:hover { background: var(--black); color: #fff; }

.auth-link { text-align: center; margin-top: 1rem; font-size: 0.875rem; color: var(--muted); }
.auth-link a { color: var(--accent); font-weight: 600; text-decoration: none; }

.auth-error {
    background: #fde8e8; border: 1px solid #f0b0b0;
    border-radius: 12px; padding: 10px 14px;
    margin-bottom: 1rem; font-size: 0.85rem; font-weight: 600; color: #8b1a1a;
}

/* ── Chat layout (sidebar + shell) ── */
.chat-layout {
    display: flex;
    height: calc(100vh - 40px);
    margin: 20px;
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 8px 40px rgba(15, 45, 130, 0.18);
}

.chat-sidebar {
    width: 240px;
    flex-shrink: 0;
    background: var(--black);
    border-right: 1px solid rgba(255,255,255,0.08);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
}

.sidebar-section-label {
    padding: 12px 16px 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: rgba(255,255,255,0.35);
}

.session-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.session-item {
    padding: 10px 16px;
    cursor: pointer;
    border-radius: 6px;
    margin: 2px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    transition: background 0.15s;
}

.session-item:hover,
.session-item.active {
    background: rgba(255,255,255,0.08);
}

.session-title {
    font-size: 0.85rem;
    color: rgba(255,255,255,0.85);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-date {
    font-size: 0.72rem;
    color: rgba(255,255,255,0.35);
}

.session-empty {
    padding: 16px;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.3);
    font-style: italic;
}

/* ── Chat shell ── */
.chat-shell {
    flex: 1;
    min-width: 0;
    background: var(--warm-white);
    display: flex; flex-direction: column;
    overflow: hidden;
}

/* ── Chat header ── */
.chat-header {
    background: var(--warm-white);
    border-bottom: 1px solid var(--border);
    padding: 14px 22px;
    display: flex; align-items: center; gap: 14px; flex-shrink: 0;
}

.hdr-owl {
    width: 44px; height: 44px; background: var(--accent-light);
    border-radius: 13px;
    display: flex; align-items: center; justify-content: center;
}

.hdr-owl img { width: 30px; height: 30px; object-fit: contain; }
.hdr-info { flex: 1; }

.hdr-name {
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 1.05rem; font-weight: 700; color: var(--text);
}

.hdr-sub {
    font-size: 0.72rem; font-weight: 600;
    color: rgba(255,255,255,0.5); margin-top: 2px;
    display: flex; align-items: center; gap: 6px;
}

.online-pip {
    width: 7px; height: 7px; border-radius: 50%;
    background: #5de8a0;
    animation: pip 2.5s ease-in-out infinite;
}

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

.hdr-actions { display: flex; align-items: center; gap: 8px; }

.rate-badge {
    font-size: 0.72rem; font-weight: 700;
    padding: 5px 12px; border-radius: 20px;
}

.rate-badge.normal { background: var(--off-white); color: var(--muted); border: 1px solid var(--border2); }
.rate-badge.warning { background: var(--amber-light); color: var(--amber); border: 1px solid #f0d898; }
.rate-badge.danger { background: #fde8e8; color: #c0392b; border: 1px solid #f0b0b0; }

.hdr-btn {
    background: var(--off-white); border: 1px solid var(--border2);
    color: var(--text-mid); font-size: 0.78rem; font-weight: 600;
    padding: 6px 14px; border-radius: 9px; cursor: pointer;
}

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

/* ── Chat messages area ── */
.chat-messages {
    flex: 1; overflow-y: auto; padding: 24px 20px;
    display: flex; flex-direction: column; gap: 20px;
    background: var(--off-white);
    scrollbar-width: thin; scrollbar-color: var(--border2) transparent;
}

.msg-row { display: flex; align-items: flex-end; gap: 10px; }
.msg-row.user { flex-direction: row-reverse; }

.msg-av {
    width: 36px; height: 36px; border-radius: 10px; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
}

.msg-av.bot { background: var(--accent-light); border: 1px solid var(--border2); }
.msg-av.bot img { width: 24px; height: 24px; object-fit: contain; }
.msg-av.user { background: var(--black); color: #fff; font-size: 14px; }

.bub-col { display: flex; flex-direction: column; gap: 5px; max-width: 80%; }
.msg-row.user .bub-col { align-items: flex-end; }

.bubble { padding: 12px 16px; font-size: 0.875rem; line-height: 1.68; font-weight: 500; }

.bubble.bot {
    background: var(--warm-white); border: 1px solid var(--border);
    border-radius: 16px 16px 16px 4px; color: var(--text);
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.bubble.user { background: var(--black); border-radius: 16px 16px 4px 16px; color: #fff; }
.bubble.error { background: #fde8e8; border: 1px solid #f0b0b0; border-radius: 16px 16px 16px 4px; color: #8b1a1a; }
.bubble.warning { background: var(--amber-light); border: 1px solid #f0d898; border-radius: 16px 16px 16px 4px; color: #7a5200; }

.source-pill {
    display: inline-flex; align-items: center; gap: 5px;
    font-size: 0.69rem; font-weight: 700;
    color: var(--accent); background: var(--accent-light);
    border: 1px solid #c0ddd0; border-radius: 20px;
    padding: 3px 10px; margin-top: 4px;
}

.sources-block {
    margin-top: 8px;
}

.sources-list {
    list-style: none; padding: 0; margin: 6px 0 0 0;
}

.sources-list li {
    font-size: 0.78rem; padding: 2px 0;
}

.sources-list a {
    color: var(--accent); text-decoration: underline;
    text-underline-offset: 2px;
}

.sources-list a:hover { color: var(--text); }

.src-pages {
    color: var(--muted); font-size: 0.72rem;
}

/* ── Typing indicator ── */
.typing-bub {
    background: var(--warm-white); border: 1px solid var(--border);
    border-radius: 16px 16px 16px 4px; padding: 14px 18px;
    display: inline-flex; gap: 6px; align-items: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.05);
}

.tdot { width: 7px; height: 7px; border-radius: 50%; background: var(--border2); animation: td 1.2s ease-in-out infinite; }
.tdot:nth-child(2) { animation-delay: 0.18s; }
.tdot:nth-child(3) { animation-delay: 0.36s; }

@keyframes td {
    0%, 80%, 100% { transform: scale(1); background: var(--border2); }
    40% { transform: scale(1.35); background: var(--black); }
}

/* ── Chat input area ── */
.chat-input-area {
    padding: 14px 20px 18px; background: var(--warm-white);
    border-top: 1px solid var(--border); flex-shrink: 0;
}

.input-box {
    display: flex; align-items: center; gap: 8px;
    background: var(--off-white); border: 1.5px solid var(--border2);
    border-radius: 16px; padding: 10px 10px 10px 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37,99,235,0.15); }

.input-box input {
    flex: 1; background: none; border: none; outline: none;
    color: var(--text); font-family: 'Plus Jakarta Sans', sans-serif;
    font-size: 0.875rem; font-weight: 500;
}

.input-box input::placeholder { color: var(--muted); }

.send-btn {
    background: var(--accent); border: none; color: #fff;
    width: 40px; height: 40px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; font-size: 16px; transition: all 0.15s; flex-shrink: 0;
}

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

/* ── HTMX indicators ── */
.htmx-indicator { opacity: 0; transition: opacity 200ms ease-in; }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* Reset form control styles that crispy-forms adds */
.auth-card .form-control-lg {
    padding: 0.75rem 1rem;
    border-radius: 12px;
}

.form-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
}

/* ── Sidebar brand logo ── */
.sidebar-brand {
    padding: 16px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    display: flex; align-items: center;
}

.sidebar-logo-img {
    width: 80px; height: auto;
    object-fit: contain;
    background: #fff;
    border-radius: 10px;
    padding: 6px;
}

/* ── Sidebar nav items ── */
.sidebar-nav { padding: 8px 0; border-bottom: 1px solid rgba(255,255,255,0.08); }

.nav-list { list-style: none; margin: 0; padding: 0; }

.nav-item {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 16px; margin: 2px 8px;
    border-radius: 8px;
    font-size: 0.83rem; font-weight: 600;
    color: rgba(255,255,255,0.55);
    cursor: pointer; transition: background 0.15s;
}

.nav-active {
    background: rgba(255,255,255,0.12);
    color: rgba(255,255,255,0.95);
}

.nav-disabled { opacity: 0.4; cursor: not-allowed; }

/* ── Header title (replaces owl/name) ── */
.hdr-title {
    flex: 1;
    font-size: 1.05rem; font-weight: 700; color: var(--text);
}

/* ── Empty state / suggested questions ── */
.empty-state {
    flex: 1;
    display: flex; flex-direction: column;
    align-items: center; justify-content: center;
    padding: 40px 24px; text-align: center;
}

.empty-title {
    font-size: 1.15rem; font-weight: 700;
    color: var(--text); margin-bottom: 24px;
}

.suggested-label {
    font-size: 0.72rem; font-weight: 700;
    letter-spacing: 0.07em; text-transform: uppercase;
    color: var(--muted); margin-bottom: 12px;
}

.suggested-btns {
    display: flex; flex-direction: column; gap: 8px;
    max-width: 420px; width: 100%;
}

.suggested-btn {
    background: var(--warm-white); border: 1px solid var(--border);
    border-radius: 12px; padding: 10px 16px;
    font-size: 0.85rem; font-weight: 500;
    color: var(--text-mid); cursor: pointer; text-align: left;
    font-family: 'Plus Jakarta Sans', sans-serif;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
}

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

/* ── CPA trust badge ── */
.cpa-badge {
    text-align: center; margin-top: 8px;
    font-size: 0.72rem; font-weight: 600;
    color: var(--muted); letter-spacing: 0.02em;
}

.cpa-badge i { color: var(--accent); margin-right: 3px; }

/* ── Paperclip attach button ── */
.attach-btn {
    background: none; border: none;
    color: var(--muted); font-size: 16px;
    cursor: not-allowed; padding: 4px 6px;
    border-radius: 8px; flex-shrink: 0; opacity: 0.5;
}
