/* Shared styles: chat (index.html) and admin (admin.html, login.html).
   Design language follows masterplast.hu: IBM Plex Sans, brand blue #0069B4,
   navy #003263, light-grey panels #F3F5F8, pill controls, uppercase labels,
   flat surfaces, orange tags. */

@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/ibm-plex-sans-latin-ext-400.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 400; font-display: swap;
  src: url(fonts/ibm-plex-sans-latin-400.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap;
  src: url(fonts/ibm-plex-sans-latin-ext-500.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 500; font-display: swap;
  src: url(fonts/ibm-plex-sans-latin-500.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(fonts/ibm-plex-sans-latin-ext-600.woff2) format("woff2");
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }
@font-face { font-family: "IBM Plex Sans"; font-style: normal; font-weight: 600; font-display: swap;
  src: url(fonts/ibm-plex-sans-latin-600.woff2) format("woff2");
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }

:root {
  --bg: #ffffff;
  --surface: #ffffff;
  --panel: #f3f5f8;            /* masterplast.hu grey panels and search pill */
  --panel-2: #e9edf2;
  --text: #302f26;             /* masterplast.hu body text */
  --muted: #6c757d;
  --border: #dee2e6;
  --accent: #0069b4;           /* Masterplast blue */
  --accent-strong: #00548f;
  --accent-soft: #e5f0f8;
  --accent-fill: #0069b4;      /* backgrounds under white text (buttons, active pills, citations) */
  --accent-fill-hover: #00548f;
  --navy: #003263;
  --logo: #0b3b65;             /* logo navy */
  --tag: #f7941d;              /* orange tags */
  --user: #003263;
  --user-text: #ffffff;
  --ok: #009844;               /* masterplast.hu green */
  --warn: #a15c00;
  --danger: #c0392b;
  --radius: 12px;
  --pill: 30px;
  --header-shadow: 0 15px 30px -1px rgba(50, 50, 93, .1), 0 1px 3px -1px rgba(0, 0, 0, .18);
  --font: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1722; --surface: #152131; --panel: #1b2a3d; --panel-2: #22344b; --text: #e7ecf2; --muted: #9aa8b8;
    --border: #2a3b52; --accent: #4aa3e8; --accent-strong: #7bbcf0; --accent-soft: #17324d;
    --accent-fill: #1a75bd; --accent-fill-hover: #2386d4; --navy: #9cc7ee;
    --logo: #ffffff; --user: #0069b4; --ok: #3fbf7a; --warn: #f0b354; --danger: #ff7a6e;
    --header-shadow: 0 1px 0 rgba(255, 255, 255, .06), 0 8px 24px rgba(0, 0, 0, .35);
  }
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }  /* author display rules must not un-hide */
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased; }
button { font: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
a { color: var(--accent); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ── logo: one SVG, coloured by CSS (navy on light, white on dark) ─────── */
.logo { display: block; flex: none; height: 26px; aspect-ratio: 2233 / 472; background: var(--logo);
  -webkit-mask: url(masterchat-logo.svg) no-repeat center / contain; mask: url(masterchat-logo.svg) no-repeat center / contain; }

/* ── layout ─────────────────────────────────────────────────────────────── */
.app { display: flex; flex-direction: column; height: 100%; }
.topbar { position: relative; z-index: 2; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px max(16px, calc((100% - 920px) / 2)); background: var(--surface); box-shadow: var(--header-shadow); }
.brand { display: flex; align-items: center; gap: 14px; min-width: 0; }
.brand h1 { margin: 0; }
.subtitle { margin: 0; color: var(--muted); font-size: 13px; }
.topbar-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.lang-switch { display: inline-flex; padding: 3px; gap: 2px; background: var(--panel); border-radius: var(--pill); }
.lang-switch button { border: 0; background: transparent; color: var(--text); padding: 5px 11px; border-radius: var(--pill);
  font-size: 13px; text-transform: uppercase; }
.lang-switch button[aria-pressed="true"] { background: var(--accent-fill); color: #fff; }
.ghost { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--accent); background: var(--surface);
  color: var(--accent); border-radius: var(--pill); padding: 7px 16px; font-size: 13px; text-transform: uppercase; }
.ghost:hover { background: var(--accent-fill); border-color: var(--accent-fill); color: #fff; }
.ghost.small { padding: 4px 12px; font-size: 12px; }
.new-chat-icon { display: none; font-size: 16px; line-height: 1; }
.primary { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 0; background: var(--accent-fill);
  color: #fff; border-radius: var(--pill); padding: 0 22px; font-size: 14px; text-transform: uppercase; }
.primary:hover:not(:disabled) { background: var(--accent-fill-hover); }
.icon-btn { display: grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: 50%;
  background: var(--panel); color: var(--text); font-size: 15px; line-height: 1; padding: 0; }
.icon-btn:hover { background: var(--accent-fill); color: #fff; }
.embed-controls { display: flex; gap: 6px; }

/* ── messages ───────────────────────────────────────────────────────────── */
.messages { flex: 1; overflow-y: auto; padding: 28px max(16px, calc((100% - 920px) / 2)) 8px; scroll-behavior: smooth; }
.welcome { max-width: 660px; margin: 6vh auto 0; }
.welcome h2 { margin: 0 0 6px; font-size: 30px; font-weight: 500; line-height: 1.2; }
.welcome p { margin: 0 0 22px; color: var(--muted); max-width: 560px; }
.welcome::after { content: ""; display: block; }
.suggestions { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 10px; }
.chip { position: relative; display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 0;
  background: var(--panel); color: var(--text); border-radius: var(--radius); padding: 14px 16px; font-size: 14px; text-align: left; }
.chip::after { content: "→"; color: var(--accent); flex: none; transition: transform .15s; }
.chip:hover { background: var(--accent-soft); }
.chip:hover::after { transform: translateX(3px); }

.msg { display: flex; margin: 0 0 16px; }
.msg.user { justify-content: flex-end; }
.bubble { max-width: min(700px, 92%); border-radius: var(--radius); padding: 12px 16px; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--user); color: var(--user-text); border-radius: 18px 18px 4px 18px; white-space: pre-wrap; }
.msg.assistant .bubble { background: var(--panel); border-bottom-left-radius: 4px; }
.msg.error .bubble { background: var(--surface); border: 1px solid var(--danger); color: var(--danger); }

.answer p { margin: 0 0 10px; }
.answer p:last-child { margin-bottom: 0; }
.answer strong { font-weight: 600; }
.answer h4 { margin: 14px 0 6px; font-size: 15px; font-weight: 600; }
.answer ul, .answer ol { margin: 4px 0 10px; padding-left: 20px; }
.answer li { margin: 3px 0; }
.answer li::marker { color: var(--accent); }
.answer code { background: var(--surface); padding: 1px 5px; border-radius: 5px; font-size: 13px; }
.cite { display: inline-grid; place-items: center; min-width: 18px; height: 18px; margin: 0 1px; padding: 0 5px;
  border: 0; border-radius: 9px; background: var(--accent-fill); color: #fff;
  font-size: 11px; font-weight: 600; vertical-align: 2px; line-height: 1; }
.cite:hover { background: var(--navy); }

.status { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--panel-2); border-top-color: var(--accent);
  animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.steps { margin: 6px 0 0 26px; padding: 0; list-style: none; color: var(--muted); font-size: 13px; }
.steps li::before { content: "✓ "; color: var(--ok); }

.note { margin: 10px 0 0; padding: 8px 12px; border-radius: 8px; background: var(--surface); color: var(--warn); font-size: 13px; }

.sources { margin-top: 14px; border-top: 1px solid var(--border); padding-top: 12px; }
.sources h5 { margin: 0 0 8px; font-size: 12px; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sources ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.sources li { display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border-radius: 10px; background: var(--surface);
  transition: box-shadow .2s, background .2s; }
.sources li.flash { box-shadow: 0 0 0 2px var(--accent); }
.src-num { flex: none; display: grid; place-items: center; width: 20px; height: 20px; border-radius: 50%; background: var(--accent-fill);
  color: #fff; font-size: 11px; font-weight: 600; margin-top: 1px; }
.src-body { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 4px; }
.src-kind { display: inline-block; padding: 1px 7px; border-radius: 5px; background: var(--tag); color: #fff;
  font-size: 10.5px; text-transform: uppercase; letter-spacing: .03em; }
.src-title { font-size: 13px; }
.src-open { flex: none; font-size: 12px; text-transform: uppercase; text-decoration: none; white-space: nowrap; margin-top: 2px; }
.src-open:hover { text-decoration: underline; }

.meta { display: flex; align-items: center; justify-content: space-between; margin-top: 10px; color: var(--muted); font-size: 12px; }
.fb { display: inline-flex; gap: 4px; }
.icon { border: 0; background: transparent; border-radius: 50%; width: 30px; height: 30px; font-size: 15px; }
.icon:hover:not(:disabled) { background: var(--surface); }
.thanks { color: var(--ok); }
.fb-form { display: flex; gap: 6px; margin-top: 8px; }
.fb-form input { flex: 1; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: var(--pill); padding: 6px 14px; font: inherit; font-size: 13px; }

/* ── composer ───────────────────────────────────────────────────────────── */
.composer-wrap { padding: 10px max(16px, calc((100% - 920px) / 2)) 14px; background: var(--bg); }
.composer { display: flex; gap: 8px; align-items: stretch; background: var(--panel); border: 1px solid transparent;
  border-radius: 26px; padding: 6px 6px 6px 8px; }
.composer:focus-within { border-color: var(--accent); background: var(--surface); }
.composer textarea { flex: 1; resize: none; border: 0; outline: 0; background: transparent; color: var(--text);
  font: inherit; padding: 8px 10px; min-height: 24px; max-height: 180px; }
.composer .primary { min-height: 40px; }
.composer .primary::after { content: "→"; font-size: 15px; }
.disclaimer { margin: 8px 4px 0; color: var(--muted); font-size: 12px; text-align: center; }

@media (max-width: 600px) {
  .logo { height: 20px; }
  .new-chat-label { display: none; }
  .new-chat-icon { display: inline; }
  .new-chat { padding: 6px 11px; }
  .topbar { padding: 10px 12px; }
  .messages { padding: 18px 10px 6px; }
  .bubble { max-width: 96%; }
  .welcome h2 { font-size: 24px; }
  .composer-wrap { padding: 8px 10px 10px; }
}

/* ── embed mode (?embed=1, inside the browser-extension panel) ─────────── */
.embed body { font-size: 14px; }
.embed .topbar { padding: 10px 12px; gap: 8px; }
.embed .logo { height: 19px; }
.embed .lang-switch button { padding: 3px 8px; font-size: 11px; }
.embed .new-chat-label { display: none; }
.embed .new-chat-icon { display: inline; }
.embed .new-chat { width: 30px; height: 30px; padding: 0; justify-content: center; }
.embed .icon-btn { width: 30px; height: 30px; }
.embed .messages { padding: 16px 12px 6px; }
.embed .welcome { margin-top: 2vh; }
.embed .welcome h2 { font-size: 21px; }
.embed .welcome p { font-size: 13.5px; margin-bottom: 14px; }
.embed .suggestions { grid-template-columns: 1fr; gap: 6px; }
.embed .chip { padding: 10px 12px; font-size: 13px; }
.embed .composer-wrap { padding: 6px 10px 8px; }
.embed .composer .primary { padding: 0 14px; }
.embed .disclaimer { font-size: 11px; margin-top: 5px; }
@media (max-height: 520px) { .embed .chip:nth-child(n+3) { display: none; } }

/* ── admin ──────────────────────────────────────────────────────────────── */
.admin { max-width: 1180px; margin: 0 auto; padding: 0 16px 40px; }
.admin .topbar { margin: 0 -16px 22px; padding: 14px 16px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 12px; margin-bottom: 22px; }
.card { background: var(--panel); border-radius: var(--radius); padding: 16px; }
.card .label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .04em; }
.card .value { font-size: 26px; font-weight: 500; margin-top: 4px; color: var(--navy); }
.card .sub { color: var(--muted); font-size: 12px; }
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 18px; }
.panel h2 { margin: 0 0 12px; font-size: 16px; font-weight: 500; text-transform: uppercase; letter-spacing: .02em; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-bottom: 12px; }
.panel-head h2 { margin: 0; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: .03em; }
td.num, th.num { text-align: right; white-space: nowrap; }
tr.turn-row { cursor: pointer; }
tr.turn-row:hover td { background: var(--panel); }
tr.detail td { background: var(--panel); }
.detail .answer { max-width: 760px; }
.pill { display: inline-block; padding: 1px 8px; border-radius: 5px; font-size: 11px; font-weight: 500; background: var(--panel); text-transform: uppercase; }
.pill.ok { color: var(--ok); } .pill.bad { color: var(--danger); } .pill.warn { color: var(--warn); }
.upload-form { display: grid; grid-template-columns: 2fr 1.4fr .8fr 1fr auto; gap: 8px; align-items: end; }
.upload-form label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--muted); text-transform: uppercase; }
.upload-form input, .upload-form select { border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 8px; padding: 8px 10px; font: inherit; font-size: 13px; text-transform: none; }
.upload-form .primary { height: 38px; }
.bars { display: flex; align-items: flex-end; gap: 4px; height: 70px; }
.bars div { flex: 1; background: var(--accent); border-radius: 4px 4px 0 0; min-height: 2px; position: relative; }
.bars-labels { display: flex; gap: 4px; font-size: 10px; color: var(--muted); }
.bars-labels span { flex: 1; text-align: center; overflow: hidden; }
.muted { color: var(--muted); }
@media (max-width: 800px) { .upload-form { grid-template-columns: 1fr; } .hide-sm { display: none; } }

/* ── access-code gate ─────────────────────────────────────────────────── */
.locked .messages, .locked .composer-wrap, .locked .new-chat { display: none; }
.gate { flex: 1; display: flex; align-items: flex-start; justify-content: center; padding: 8vh 16px 24px; overflow-y: auto; }
.gate-card { width: 100%; max-width: 420px; display: flex; flex-direction: column; gap: 10px; }
.gate-card h2 { margin: 0; font-size: 26px; font-weight: 500; line-height: 1.2; }
.gate-card p { margin: 0 0 8px; color: var(--muted); }
.gate-card label { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .03em; }
.gate-card input { font: inherit; font-size: 18px; letter-spacing: .06em; padding: 12px 18px; border: 1px solid var(--border);
  border-radius: var(--pill); background: var(--panel); color: var(--text); text-transform: uppercase; }
.gate-card input:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
.gate-card .primary { align-self: flex-start; min-height: 44px; padding: 0 26px; }
.gate-card .gate-error { color: var(--danger); font-size: 14px; margin: 0 !important; }
.gate-card .gate-error.info { color: var(--muted); }
.embed .gate { padding-top: 4vh; }
.embed .gate-card h2 { font-size: 21px; }
.linklike { background: none; border: 0; padding: 0; font: inherit; color: var(--accent); cursor: pointer; text-decoration: underline; }
.msg.error .retry { margin-top: 8px; }
.new-code { margin-top: 12px; padding: 12px 16px; border-radius: var(--radius); background: var(--accent-soft); }
.new-code p { margin: 4px 0; display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.new-code code.big { font-size: 18px; letter-spacing: .05em; }
