/* Realtime AI Support - chat window */
:root {
    --side-bg: #0f172a;
    --side-item: #1e293b;
    --side-text: #94a3b8;
    --side-strong: #f8fafc;
    --blue: #2563eb;
    --blue-dark: #1d4ed8;
    --blue-soft: #eff6ff;
    --green: #22c55e;
    --green-text: #16a34a;
    --amber: #d97706;
    --bg: #f3f4f6;
    --card: #ffffff;
    --line: #e5e7eb;
    --text: #111827;
    --muted: #6b7280;
    --radius: 12px;
    --font: "Segoe UI", system-ui, -apple-system, "Noto Sans", "Noto Sans Devanagari", "Nirmala UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body { font-family: var(--font); color: var(--text); background: var(--bg); font-size: 15px; line-height: 1.5; }
button, select, textarea { font-family: inherit; }
.icon { flex: none; vertical-align: middle; }

.app { display: flex; height: 100vh; height: 100dvh; overflow: hidden; }

/* ---------- Sidebar ---------- */
.sidebar {
    width: 260px; flex: none; background: var(--side-bg); color: var(--side-text);
    display: flex; flex-direction: column; padding: 18px 12px; overflow-y: auto;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 6px 18px; color: var(--side-strong); }
.brand-icon { display: inline-flex; color: var(--side-strong); }
.brand-name { font-weight: 700; font-size: 17px; flex: 1; }
.sidebar-close { display: none; background: none; border: 0; color: var(--side-text); cursor: pointer; }

.btn-new {
    display: flex; align-items: center; gap: 8px; width: 100%; padding: 11px 14px; border: 0; border-radius: 8px;
    background: var(--blue); color: #fff; font-size: 15px; font-weight: 500; cursor: pointer; margin-bottom: 22px;
}
.btn-new:hover { background: var(--blue-dark); }

.side-label { font-size: 11.5px; letter-spacing: .06em; text-transform: uppercase; color: #8b98ad; padding: 0 6px 8px; }
.product-list { display: flex; flex-direction: column; gap: 2px; }
.product {
    display: block; padding: 9px 10px; border-radius: 8px; color: var(--side-text); text-decoration: none; font-size: 14.5px;
}
.product:hover { background: rgba(255,255,255,.05); color: #e2e8f0; }
.product.current { background: var(--side-item); color: var(--side-strong); padding: 10px; }
.product-name { display: block; }
.product-status { display: block; font-size: 12.5px; margin-top: 1px; }
.product-status.ok { color: var(--green); }
.product-status.soon { color: #fbbf24; }

.side-divider { height: 1px; background: #273449; margin: 18px 4px; }
.resource {
    display: flex; flex-direction: column; gap: 3px; padding: 6px; color: var(--side-strong); text-decoration: none; font-size: 14.5px;
    border-radius: 8px;
}
.resource:hover { background: rgba(255,255,255,.05); }
.resource.disabled { color: #64748b; cursor: not-allowed; }
.sidebar-backdrop { display: none; }

/* ---------- Main ---------- */
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; background: var(--bg); }
.topbar {
    display: flex; align-items: center; gap: 10px; height: 52px; padding: 0 16px; background: #fff;
    border-bottom: 1px solid var(--line); flex: none;
}
.topbar-title { flex: 1; margin: 0; font-size: 16px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.menu-btn { display: none; background: none; border: 0; padding: 4px; cursor: pointer; color: var(--text); }
.ai-badge { font-size: 12.5px; white-space: nowrap; }
.ai-badge.on { color: var(--green-text); }
.ai-badge.off { color: var(--muted); }
.ai-badge.offline { color: var(--amber); }

.chat-scroll { flex: 1; overflow-y: auto; padding: 32px 16px 16px; }
.welcome { max-width: 760px; margin: 0 auto; text-align: center; padding-top: 12px; }
.welcome h2 { margin: 0 0 14px; font-size: 21px; font-weight: 600; }
.welcome-sub { margin: 0 0 22px; color: var(--muted); font-size: 13.5px; }
.cards { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; text-align: left; }
.card {
    display: flex; flex-direction: column; align-items: flex-start; gap: 3px; padding: 14px 12px; background: var(--card);
    border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; text-align: left; color: var(--text);
    transition: border-color .15s, box-shadow .15s, transform .15s;
}
.card:hover { border-color: #bfdbfe; box-shadow: 0 2px 10px rgba(37,99,235,.08); transform: translateY(-1px); }
.card-icon { color: var(--blue); display: inline-flex; margin-bottom: 4px; }
.card-title { font-weight: 600; font-size: 14.5px; }
.card-sub { font-size: 12.5px; color: var(--muted); }
.empty-guide {
    display: flex; gap: 12px; align-items: flex-start; text-align: left; background: #fffbeb; border: 1px solid #fde68a;
    color: #92400e; border-radius: var(--radius); padding: 14px 16px;
}
.empty-guide p { margin: 0; }
.welcome.compact { display: none; }

/* ---------- Messages ---------- */
.messages { max-width: 780px; margin: 0 auto; display: flex; flex-direction: column; gap: 16px; }
.msg { display: flex; gap: 10px; align-items: flex-start; }
.msg.user { justify-content: flex-end; }
.msg.user .bubble {
    background: var(--blue); color: #fff; border-radius: 16px 16px 4px 16px; padding: 9px 14px; max-width: 80%;
    white-space: pre-wrap; word-wrap: break-word;
}
.avatar {
    width: 30px; height: 30px; border-radius: 50%; background: var(--side-bg); color: #fff; flex: none;
    display: inline-flex; align-items: center; justify-content: center;
}
.msg.bot .bubble {
    background: #fff; border: 1px solid var(--line); border-radius: 4px 16px 16px 16px; padding: 14px 16px;
    max-width: calc(100% - 40px); min-width: 0; overflow-wrap: anywhere;
}
.msg.bot.notfound .bubble { background: #fffbeb; border-color: #fde68a; }
.intro { color: var(--muted); font-size: 13.5px; margin: 0 0 8px; }
.answer-title { font-size: 16px; font-weight: 600; margin: 0 0 6px; }
.menu-path {
    display: inline-flex; align-items: center; gap: 5px; background: var(--blue-soft); color: var(--blue-dark);
    border-radius: 999px; padding: 3px 10px; font-size: 12.5px; margin-bottom: 10px;
}
.md p { margin: 0 0 10px; }
.md p:last-child { margin-bottom: 0; }
.md ol, .md ul { margin: 0 0 10px; padding-left: 22px; }
.md li { margin: 3px 0; }
.md h3, .md h4 { margin: 12px 0 6px; font-size: 15px; }
.md code { background: #f1f5f9; padding: 1px 5px; border-radius: 4px; font-size: 13px; }
.md .table-wrap { overflow-x: auto; margin: 0 0 10px; }
.md table { border-collapse: collapse; width: 100%; font-size: 13.5px; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 9px; text-align: left; vertical-align: top; }
.md th { background: #f8fafc; font-weight: 600; }

.shot { margin-top: 12px; }
.shot-label { display: flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--muted); margin-bottom: 6px; }
.shot img {
    display: block; max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: 8px; cursor: zoom-in;
}

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.chips-label { width: 100%; font-size: 12.5px; color: var(--muted); }
.chip {
    border: 1px solid #bfdbfe; background: #fff; color: var(--blue-dark); border-radius: 999px; padding: 6px 12px;
    font-size: 13px; cursor: pointer; text-align: left;
}
.chip:hover { background: var(--blue-soft); }
.topic-list { display: flex; flex-direction: column; gap: 6px; margin-top: 4px; }
.topic-item {
    display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 12px; background: #fff; border: 1px solid var(--line);
    border-radius: 8px; cursor: pointer; text-align: left; font-size: 14px; color: var(--text);
}
.topic-item:hover { border-color: #bfdbfe; background: #f8fbff; }
.topic-item .num {
    flex: none; width: 24px; height: 24px; border-radius: 50%; background: var(--blue-soft); color: var(--blue-dark);
    font-size: 12px; font-weight: 600; display: inline-flex; align-items: center; justify-content: center;
}
.topic-item .arrow { margin-left: auto; color: #94a3b8; display: inline-flex; }

.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--line); }
.lang-tag { font-size: 12px; color: var(--muted); }
.feedback { margin-left: auto; display: flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--muted); }
.fb-btn {
    border: 1px solid var(--line); background: #fff; border-radius: 6px; padding: 4px 8px; cursor: pointer; color: var(--muted);
    display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px;
}
.fb-btn:hover { color: var(--text); border-color: #cbd5e1; }
.fb-btn.chosen { color: var(--blue-dark); border-color: #93c5fd; background: var(--blue-soft); }
.fb-thanks { font-size: 12.5px; color: var(--green-text); }

.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: #94a3b8; animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ---------- Composer ---------- */
.composer-wrap { flex: none; padding: 8px 16px 10px; }
.composer {
    max-width: 780px; margin: 0 auto; background: #fff; border: 1px solid var(--line); border-radius: 14px;
    padding: 12px 12px 10px; box-shadow: 0 1px 3px rgba(15,23,42,.04);
}
.composer:focus-within { border-color: #93c5fd; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
.composer textarea {
    width: 100%; border: 0; outline: 0; resize: none; font-size: 15px; line-height: 1.45; max-height: 160px;
    padding: 2px 2px 8px; color: var(--text); background: transparent;
}
.composer textarea::placeholder { color: #6b7280; }
.composer-bar { display: flex; align-items: center; gap: 8px; }
.lang-select { display: inline-flex; align-items: center; gap: 6px; color: #4b5563; font-size: 14px; }
.lang-select select { border: 0; background: transparent; color: #4b5563; font-size: 14px; cursor: pointer; outline: 0; padding: 2px 0; max-width: 200px; }
.composer-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }
.icon-btn {
    width: 34px; height: 34px; border-radius: 8px; border: 0; background: transparent; color: #6b7280; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: #f3f4f6; color: var(--text); }
.icon-btn.listening { background: #fee2e2; color: #dc2626; }
.send-btn {
    width: 34px; height: 34px; border-radius: 8px; border: 0; background: var(--blue); color: #fff; cursor: pointer;
    display: inline-flex; align-items: center; justify-content: center;
}
.send-btn:hover { background: var(--blue-dark); }
.send-btn:disabled { opacity: .5; cursor: default; }
.footer-note { text-align: center; color: #4b5563; font-size: 13px; padding-top: 8px; }

/* ---------- Picture viewer ---------- */
.lightbox {
    position: fixed; inset: 0; background: rgba(15,23,42,.85); display: flex; align-items: center; justify-content: center;
    z-index: 100; padding: 24px;
}
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 8px; background: #fff; }
.lightbox-close { position: absolute; top: 14px; right: 14px; background: none; border: 0; color: #fff; cursor: pointer; }

/* ---------- Mobile ---------- */
@media (max-width: 820px) {
    .sidebar { position: fixed; left: 0; top: 0; bottom: 0; z-index: 50; transform: translateX(-100%); transition: transform .2s; }
    .app.menu-open .sidebar { transform: none; }
    .app.menu-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.4); z-index: 40; }
    .sidebar-close, .menu-btn { display: inline-flex; }
    .cards { grid-template-columns: 1fr; }
    .chat-scroll { padding-top: 20px; }
    .msg.user .bubble { max-width: 90%; }
}
