/* ─── Demo Chat UI ─────────────────────────────────────────────────────────── */

:root {
    --bg: #eef1f7;
    --panel: #ffffff;
    --border: #dde1ea;
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --user-bubble: #2563eb;
    --bot-bubble: #ffffff;
    --text: #1e2030;
    --muted: #6b7280;
    --radius: 12px;
    --shadow: 0 2px 8px rgba(0, 0, 0, .10);
    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    align-items: stretch;
}

/* ── Layout: sidebar + chat ── */
.sidebar {
    width: 280px;
    min-width: 220px;
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    padding: 20px 16px;
    gap: 14px;
}

.sidebar h2 {
    font-size: 15px;
    font-weight: 700;
    color: var(--primary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.sidebar label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    display: block;
    margin-bottom: 4px;
}

.sidebar input {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 6px;
    font-size: 13px;
    color: var(--text);
    background: #f9fafb;
}

.sidebar input:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 8px 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: background .15s, opacity .15s;
    text-decoration: none;
    width: 100%;
}

.btn:disabled {
    opacity: .5;
    cursor: default;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

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

.btn-secondary {
    background: #e5e7eb;
    color: var(--text);
}

.btn-secondary:hover:not(:disabled) {
    background: #d1d5db;
}

.btn-danger {
    background: #fee2e2;
    color: #dc2626;
}

.btn-danger:hover:not(:disabled) {
    background: #fecaca;
}

.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    width: auto;
}

/* ── State card ── */
.state-card {
    background: #f0f4ff;
    border: 1px solid #c7d2fe;
    border-radius: 8px;
    padding: 12px;
    font-size: 12px;
}

.state-card .state-title {
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 6px;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.state-card .field {
    margin-bottom: 3px;
}

.state-card .field span {
    color: var(--muted);
}

.sidebar-links {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* ── Chat area ── */
.chat-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    background: var(--panel);
    border-bottom: 1px solid var(--border);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.chat-header h1 {
    font-size: 16px;
    font-weight: 700;
}

.chat-header .subtitle {
    font-size: 12px;
    color: var(--muted);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

/* ── Bubbles ── */
.msg {
    display: flex;
    flex-direction: column;
    max-width: 72%;
}

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

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

.bubble {
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    box-shadow: var(--shadow);
}

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

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

.msg-meta {
    font-size: 10px;
    color: var(--muted);
    margin-top: 3px;
    padding: 0 4px;
}

/* ── Input bar ── */
.chat-input-bar {
    background: var(--panel);
    border-top: 1px solid var(--border);
    padding: 12px 20px;
    display: flex;
    gap: 10px;
    align-items: center;
}

#msg-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 24px;
    font-size: 14px;
    color: var(--text);
    background: #f9fafb;
    outline: none;
    transition: border .15s, background .15s;
    resize: none;
    font-family: var(--font);
    line-height: 1.4;
    max-height: 120px;
    min-height: 42px;
}

#msg-input:focus {
    border-color: var(--primary);
    background: #fff;
}

#send-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: none;
    background: var(--primary);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background .15s, transform .1s;
}

#send-btn:hover {
    background: var(--primary-hover);
}

#send-btn:active {
    transform: scale(.95);
}

#send-btn:disabled {
    opacity: .5;
    cursor: default;
}

/* ── Empty state ── */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--muted);
    gap: 8px;
    font-size: 14px;
}

.empty-state .icon {
    font-size: 40px;
}

/* ── Loading spinner ── */
.typing {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
}

.typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--muted);
    animation: bounce .9s infinite ease-in-out;
}

.typing span:nth-child(2) {
    animation-delay: .15s;
}

.typing span:nth-child(3) {
    animation-delay: .3s;
}

@keyframes bounce {

    0%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-6px);
    }
}

/* ── Responsive ── */
@media (max-width: 600px) {
    .sidebar {
        display: none;
    }
}

/* ── RTL support (Hebrew & Arabic) ── */
[lang="he"] .bubble,
[lang="ar"] .bubble {
    direction: rtl;
    text-align: right;
}

/* Bot bubble text auto-detects RTL via Unicode bidi */
.bubble {
    unicode-bidi: plaintext;
}

/* ── Language detect chips in sidebar ── */
.lang-row {
    display: flex;
    align-items: center;
    gap: 5px;
    flex-wrap: wrap;
}

.lang-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
}

.lang-chip {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 99px;
    font-size: 10px;
    font-weight: 700;
    background: #e5e7eb;
    color: var(--muted);
    border: 1px solid var(--border);
    cursor: default;
    user-select: none;
}