/* Moderna Helper v2 - shell styly. Farby a znacka prevzate z v1, rozlozenie nove (docs/10-ui.md). */

:root {
  color-scheme: light;
  /* Moderna brand: Pantone 294 / RGB 8,49,96 = #083160 */
  --bg: #eaf1f9;
  --bg-grad-1: rgba(46, 108, 223, 0.16);
  --bg-grad-2: rgba(8, 49, 96, 0.12);
  --panel: rgba(255, 255, 255, 0.92);
  --panel-strong: #ffffff;
  --border: rgba(8, 49, 96, 0.16);
  --text: #14273f;
  --muted: #5b6f86;
  --accent: #12508f;
  --accent-strong: #083160;
  --accent-contrast: #ffffff;
  --assistant-bg: #eaf1fa;
  --user-bg: #d7e6fa;
  --shadow: 0 16px 40px rgba(8, 49, 96, 0.14);
  --ok: #1c8a52;
  --warn: #c07a12;
  --danger: #c33a3a;
  --danger-strong: #a12e2e;
  --link: #2d6cdf;
  --code-bg: rgba(8, 49, 96, 0.08);
  --code-border: rgba(8, 49, 96, 0.14);
  --chip-bg: rgba(8, 49, 96, 0.07);
  --chip-border: rgba(8, 49, 96, 0.18);
  --overlay: rgba(8, 20, 36, 0.42);
}

/* Tmavy rezim: automaticky podla systemu (ak nie je explicitny prepinac)... */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0b1522;
    --bg-grad-1: rgba(46, 108, 223, 0.12);
    --bg-grad-2: rgba(8, 49, 96, 0.28);
    --panel: rgba(20, 32, 48, 0.92);
    --panel-strong: #16273a;
    --border: rgba(150, 180, 214, 0.18);
    --text: #e7edf5;
    --muted: #9db0c6;
    --accent: #4d8fd9;
    --accent-strong: #7fb0e8;
    --accent-contrast: #06121f;
    --assistant-bg: #16283e;
    --user-bg: #1c3a5c;
    --shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
    --ok: #3fbf7f;
    --warn: #e0a83e;
    --danger: #ea6363;
    --danger-strong: #ff8a8a;
    --link: #7fb0e8;
    --code-bg: rgba(150, 180, 214, 0.12);
    --code-border: rgba(150, 180, 214, 0.2);
    --chip-bg: rgba(150, 180, 214, 0.1);
    --chip-border: rgba(150, 180, 214, 0.24);
    --overlay: rgba(0, 0, 0, 0.55);
  }
}

/* ...alebo explicitny prepinac cez menu (ulozeny v localStorage) */
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0b1522;
  --bg-grad-1: rgba(46, 108, 223, 0.12);
  --bg-grad-2: rgba(8, 49, 96, 0.28);
  --panel: rgba(20, 32, 48, 0.92);
  --panel-strong: #16273a;
  --border: rgba(150, 180, 214, 0.18);
  --text: #e7edf5;
  --muted: #9db0c6;
  --accent: #4d8fd9;
  --accent-strong: #7fb0e8;
  --accent-contrast: #06121f;
  --assistant-bg: #16283e;
  --user-bg: #1c3a5c;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  --ok: #3fbf7f;
  --warn: #e0a83e;
  --danger: #ea6363;
  --danger-strong: #ff8a8a;
  --link: #7fb0e8;
  --code-bg: rgba(150, 180, 214, 0.12);
  --code-border: rgba(150, 180, 214, 0.2);
  --chip-bg: rgba(150, 180, 214, 0.1);
  --chip-border: rgba(150, 180, 214, 0.24);
  --overlay: rgba(0, 0, 0, 0.55);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

/* Atribut `hidden` skryva prvok cez UA styl, ktory ale prehra s HOCIJAKYM
   autorskym `display`. A `.app-shell`, `.login-screen`, `.popover` aj
   `.dropdown-menu` ho maju, takze bez tohto pravidla sa nic z toho nikdy
   neskryje: appka svietila pod prihlasovacim formularom a popovery boli
   otvorene stale. Plati na cely dokument, preto stoji hned na zaciatku. */
[hidden] {
  display: none !important;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, var(--bg-grad-1), transparent 32%),
    radial-gradient(circle at bottom right, var(--bg-grad-2), transparent 28%),
    var(--bg);
  min-height: 100vh;
}

button {
  font: inherit;
  cursor: pointer;
}

input,
textarea {
  font: inherit;
  color: var(--text);
}

h1,
h2,
h3,
p {
  margin: 0;
}

.hidden {
  display: none !important;
}

/* ================= PRIHLASENIE ================= */

.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: min(420px, 100%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 32px 28px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  backdrop-filter: blur(10px);
}

.login-logo {
  height: 46px;
  width: auto;
  align-self: center;
  margin-bottom: 12px;
}

.login-card h1 {
  text-align: center;
  color: var(--accent-strong);
  font-size: 1.5rem;
}

.login-sub {
  text-align: center;
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 18px;
}

.field-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  margin-top: 10px;
}

.login-card input[type="text"],
.login-card input[type="password"] {
  margin-top: 4px;
  padding: 12px 14px;
  min-height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--text);
}

.login-card input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.login-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 0.88rem;
  color: var(--muted);
}

.login-remember input {
  width: 18px;
  height: 18px;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-contrast);
  border: 0;
  border-radius: 12px;
  padding: 12px 16px;
  min-height: 44px;
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-strong);
}

.btn-block {
  width: 100%;
  margin-top: 18px;
}

.login-error {
  color: var(--danger-strong);
  font-size: 0.86rem;
  margin-top: 10px;
  text-align: center;
}

.login-hint {
  margin-top: 14px;
  text-align: center;
  font-size: 0.78rem;
  color: var(--muted);
  opacity: 0.8;
}

/* ================= APP SHELL ================= */

.app-shell {
  height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  flex-wrap: wrap;
  /* `backdrop-filter` zaklada NOVY kontext vrstvenia. Bez vlastneho z-index
     sa cela lista - aj s otvorenym menu - kresli POD oblastou chatu, ktora je
     v dokumente za nou. Menu je potom vidiet, ale klik dopadne na spravu pod
     nim, takze polozky vyzeraju mrtve. Zistene z pouzivatelskej snimky
     2026-09-03: bublina spravy prekryvala polozky menu.
     Musi zostat POD popovermi (z-index 60), inak by ich lista prekryla. */
  position: relative;
  z-index: 50;
}

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  flex-shrink: 0;
}

.icon-btn:hover {
  background: var(--chip-bg);
}

.hamburger,
.hamburger::before,
.hamburger::after {
  content: "";
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
}

.hamburger {
  position: relative;
}

.hamburger::before {
  position: absolute;
  top: -6px;
}

.hamburger::after {
  position: absolute;
  top: 6px;
}

.brand-mini {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-right: 4px;
}

.brand-mini-logo {
  height: 26px;
  width: auto;
}

.brand-mini-name {
  font-weight: 700;
  color: var(--accent-strong);
  white-space: nowrap;
}

.mode-switch {
  display: flex;
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  padding: 3px;
  gap: 2px;
}

.mode-btn {
  background: transparent;
  border: 0;
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 38px;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.86rem;
}

.mode-btn.active {
  background: var(--accent);
  color: var(--accent-contrast);
}

.status-lights {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.status-dot {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 6px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 40px;
}

.status-dot:hover {
  background: var(--chip-bg);
}

.status-dot .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 0 3px rgba(28, 138, 82, 0.16);
  flex-shrink: 0;
}

.status-dot[data-tone="warn"] .dot {
  background: var(--warn);
  box-shadow: 0 0 0 3px rgba(192, 122, 18, 0.18);
}

.status-dot[data-tone="error"] .dot {
  background: var(--danger);
  box-shadow: 0 0 0 3px rgba(195, 58, 58, 0.18);
}

.status-dot .dot-label {
  font-size: 0.76rem;
  color: var(--muted);
  display: none;
}

@media (min-width: 860px) {
  .status-dot .dot-label {
    display: inline;
  }
}

.user-menu-wrap {
  position: relative;
  margin-left: 4px;
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  padding: 8px 12px;
  min-height: 44px;
  color: var(--text);
}

.user-chip-role {
  color: var(--muted);
  font-size: 0.82rem;
}

.caret {
  color: var(--muted);
  font-size: 0.7rem;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 240px;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 8px;
  z-index: 40;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dropdown-menu button {
  background: transparent;
  border: 0;
  text-align: left;
  padding: 10px 12px;
  border-radius: 10px;
  color: var(--text);
  min-height: 40px;
}

.dropdown-menu button:hover {
  background: var(--chip-bg);
}

.dropdown-menu .menu-danger {
  color: var(--danger-strong);
}

.menu-sep {
  height: 1px;
  background: var(--border);
  margin: 6px 4px;
}

/* ================= BODY LAYOUT ================= */

.body-layout {
  flex: 1;
  display: flex;
  min-height: 0;
  position: relative;
}

.drawer-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 30;
}

.conversations-panel {
  width: 260px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  background: var(--panel);
  display: flex;
  flex-direction: column;
  padding: 12px;
  gap: 10px;
  overflow-y: auto;
}

.btn-new-chat {
  background: var(--accent);
  color: var(--accent-contrast);
  border: 0;
  border-radius: 12px;
  padding: 12px;
  min-height: 44px;
  font-weight: 600;
}

.conversations-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.conv-group-label {
  font-size: 0.76rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 10px 8px 4px;
}

.conv-item {
  background: transparent;
  border: 0;
  border-radius: 10px;
  padding: 10px 10px;
  min-height: 44px;
  text-align: left;
  color: var(--text);
  display: block;
  width: 100%;
}

.conv-item:hover {
  background: var(--chip-bg);
}

.conv-item.active {
  background: var(--chip-bg);
  font-weight: 600;
  border: 1px solid var(--chip-border);
}

/* ================= CHAT ================= */

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.msg {
  display: flex;
  max-width: min(760px, 92%);
}

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

.msg.role-assistant,
.msg.role-system {
  align-self: flex-start;
}

.msg-bubble {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--assistant-bg);
  width: 100%;
}

.msg.role-user .msg-bubble {
  background: var(--user-bg);
}

.msg.role-system .msg-bubble {
  background: transparent;
  border-style: dashed;
  color: var(--muted);
  font-size: 0.88rem;
}

.msg-body {
  white-space: pre-wrap;
  line-height: 1.55;
  word-break: break-word;
}

.msg-body a {
  color: var(--link);
  text-decoration: underline;
  word-break: break-word;
}

.msg-body strong {
  font-weight: 700;
  color: var(--accent-strong);
}

.msg-body code {
  font-family: "Consolas", "Menlo", monospace;
  font-size: 0.88em;
  padding: 1px 5px;
  border-radius: 6px;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
}

.msg-body .md-heading {
  font-weight: 700;
  font-size: 1.05em;
  color: var(--accent-strong);
  margin: 8px 0 4px;
}

.msg-body .md-heading:first-child {
  margin-top: 0;
}

.msg-body .md-bullet {
  padding-left: 14px;
  margin: 2px 0;
}

/* Kurzor sa ukazuje az vtedy, ked sa naozaj pise. Kym appka pracuje, je na
   jeho mieste nazov fazy - blikajuca ciarka sama o sebe nehovori, ci sa nieco
   deje alebo sa to zaseklo. */
.msg-body.typing::after {
  content: "▍";
  animation: blink 1s step-start infinite;
  color: var(--muted);
}

.msg-stage {
  display: flex;
  flex-direction: column;
  gap: 2px;
  color: var(--muted);
  font-size: 0.85em;
  font-style: italic;
}

.msg-stage .msg-stage-line {
  display: flex;
  align-items: center;
  gap: 7px;
}

/* Hotova faza: zosedivie, namiesto bodiek dostane fajku. */
.msg-stage .msg-stage-line.done {
  opacity: 0.55;
}

.msg-stage .msg-stage-line.done .msg-stage-dots::after {
  content: "\2713";
  animation: none;
}

.msg-stage .msg-stage-dots {
  display: inline-block;
  width: 1.2em;
  text-align: left;
  font-style: normal;
}

.msg-stage .msg-stage-dots::after {
  content: "";
  animation: stage-dots 1.2s steps(4, end) infinite;
}

@keyframes stage-dots {
  0%   { content: ""; }
  25%  { content: "."; }
  50%  { content: ".."; }
  75%  { content: "..."; }
}

/* -- tabulka v odpovedi -- */

.msg-body .md-table-wrap {
  overflow-x: auto;
  margin: 8px 0;
}

.msg-body .md-table {
  border-collapse: collapse;
  font-size: 0.95em;
}

.msg-body .md-table th,
.msg-body .md-table td {
  border: 1px solid var(--border, rgba(127, 127, 127, 0.35));
  padding: 4px 9px;
  text-align: left;
  vertical-align: top;
  /* Bunky sa NELAMU. Predtym sa lamal prvy stlpec a z datumu bol "2019-04-"
     a "01" pod nim, z hlavicky "zakazn" a "ik" - necitatelne. Tabulka sa
     namiesto toho posuva do strany, na to je `md-table-wrap`. */
  white-space: nowrap;
}

/* Vynimka: bunka s celou vetou by inak roztiahla tabulku donekonecna. */
.msg-body .md-table td.md-cell-long {
  white-space: normal;
  min-width: 14em;
}

.msg-body .md-table th {
  font-weight: 600;
  background: var(--surface-2, rgba(127, 127, 127, 0.12));
}

@keyframes blink {
  50% {
    opacity: 0;
  }
}

/* -- kandidati -- */

.msg-candidates {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.candidate-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  background: var(--panel-strong);
  border: 1px solid var(--chip-border);
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 44px;
  color: var(--text);
}

.candidate-row:hover {
  border-color: var(--accent);
  background: var(--chip-bg);
}

.candidate-row.selected {
  border-color: var(--accent);
  background: var(--chip-bg);
  font-weight: 600;
}

.candidate-row:disabled {
  opacity: 0.55;
  cursor: default;
}

.candidate-num {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-contrast);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.78rem;
  font-weight: 700;
}

.candidate-label {
  flex: 1;
  min-width: 0;
}

.candidate-code {
  font-weight: 700;
}

.candidate-desc {
  color: var(--muted);
  font-size: 0.86rem;
}

.candidate-reason {
  flex-shrink: 0;
  font-size: 0.8rem;
  color: var(--muted);
  white-space: nowrap;
}

/* -- tabulka -- */

.msg-table-wrap {
  margin-top: 10px;
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: 12px;
}

.msg-table {
  border-collapse: collapse;
  width: 100%;
  min-width: 420px;
  font-size: 0.88rem;
}

.msg-table th,
.msg-table td {
  padding: 8px 10px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.msg-table th {
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--chip-bg);
}

.msg-table tr:last-child td {
  border-bottom: 0;
}

/* -- subory (files) -- */
.msg-file {
  margin-top: 10px;
}

.file-download {
  display: inline-flex;
  align-items: center;
  background-color: var(--chip-bg);
  border: 1px solid var(--chip-border);
  border-radius: 8px;
  padding: 8px 12px;
  cursor: pointer;
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  transition: background-color 0.2s, border-color 0.2s;
  text-align: left;
}

.file-download:hover {
  background-color: var(--panel-strong);
  border-color: var(--border);
}

.file-icon {
  color: var(--accent);
  margin-right: 8px;
  font-size: 16px;
}

.file-name {
  font-weight: 500;
  margin-right: 8px;
}

.file-size {
  color: var(--muted);
  font-size: 13px;
  margin-left: auto;
}

/* -- upozornenia (notices) -- */

.msg-notices {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.notice {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  background: var(--chip-bg);
  border-left: 3px solid var(--border);
  font-size: 0.85rem;
  color: var(--text);
  border-radius: 0 4px 4px 0;
}

.notice-icon {
  font-size: 1rem;
  line-height: 1.2;
}

.notice-text {
  line-height: 1.4;
}

.notice-archive {
  border-left-color: var(--muted);
}
.notice-archive .notice-icon {
  color: var(--muted);
}

.notice-info {
  border-left-color: var(--accent);
}
.notice-info .notice-icon {
  color: var(--accent);
}

.notice-blocked {
  border-left-color: var(--warn);
}
.notice-blocked .notice-icon {
  color: var(--warn);
}

/* -- footer / zdroj / flow -- */

.msg-footer {
  margin-top: 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.msg-source {
  font-size: 0.78rem;
  color: var(--muted);
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  padding: 4px 10px;
}

.msg-flow-btn {
  background: transparent;
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.78rem;
  color: var(--accent);
}

.msg-flow-btn:hover {
  background: var(--chip-bg);
}

/* -- followupy -- */

.msg-followups {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.followup-chip {
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  padding: 8px 12px;
  min-height: 36px;
  font-size: 0.82rem;
  color: var(--text);
}

.followup-chip:hover {
  background: var(--accent);
  color: var(--accent-contrast);
  border-color: var(--accent);
}

/* -- akcie -- */

.msg-actions {
  margin-top: 10px;
  display: flex;
  gap: 6px;
}

.msg-actions button {
  background: transparent;
  border: 1px solid var(--chip-border);
  border-radius: 10px;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  font-size: 0.9rem;
}

.msg-actions button:hover {
  background: var(--chip-bg);
}

.msg-actions button.active[data-vote="up"] {
  border-color: var(--ok);
  color: var(--ok);
}

.msg-actions button.active[data-vote="down"] {
  border-color: var(--danger);
  color: var(--danger-strong);
}

.msg-actions button.speaking {
  border-color: var(--accent);
  color: var(--accent-strong);
}

.msg-actions .msg-copy {
  width: auto;
  padding: 0 12px;
  font-size: 0.8rem;
}

/* denied / error styl */

.msg.denied .msg-bubble {
  border-color: var(--warn);
  background: color-mix(in srgb, var(--warn) 12%, var(--assistant-bg));
}

.msg.error .msg-bubble {
  border-color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, var(--assistant-bg));
}

.msg.role-system.is-error .msg-bubble {
  border-color: var(--danger-strong);
  background: color-mix(in srgb, var(--danger) 15%, var(--assistant-bg));
  color: var(--danger-strong);
}

.denied-help {
  margin-top: 6px;
  font-size: 0.84rem;
}

.denied-help a {
  color: var(--link);
}

/* ================= STAVOVY RIADOK SLOTOV ================= */

.slot-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--panel);
  overflow: hidden;
}

.slot-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: thin;
  flex: 1;
  padding-bottom: 2px;
}

.slot-chip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  padding: 8px 8px 8px 12px;
  min-height: 40px;
  font-size: 0.86rem;
  color: var(--text);
  white-space: nowrap;
}

.slot-chip-label {
  background: transparent;
  border: 0;
  color: inherit;
  font: inherit;
  padding: 0;
  min-height: auto;
}

.slot-chip-remove {
  background: transparent;
  border: 0;
  color: var(--muted);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.slot-chip-remove:hover {
  background: rgba(0, 0, 0, 0.08);
  color: var(--danger-strong);
}

.slot-chip-empty {
  color: var(--muted);
  font-size: 0.84rem;
  padding: 8px 4px;
}

.slot-clear {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid var(--chip-border);
  border-radius: 999px;
  padding: 8px 14px;
  min-height: 40px;
  font-size: 0.84rem;
  color: var(--muted);
}

.slot-clear:hover {
  color: var(--danger-strong);
  border-color: var(--danger);
}

/* ================= VSTUP ================= */

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: var(--panel);
}

.mic-btn {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid var(--chip-border);
  background: var(--chip-bg);
  font-size: 1.2rem;
  color: var(--text);
  opacity: 0.55;
}

.mic-btn:not(:disabled) {
  opacity: 1;
}

.mic-btn:not(:disabled):hover {
  background: var(--accent);
  color: var(--accent-contrast);
}

.composer-input {
  flex: 1;
  resize: none;
  max-height: 140px;
  min-height: 44px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--text);
  line-height: 1.4;
}

.composer-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.btn-send {
  flex-shrink: 0;
  background: var(--accent);
  color: var(--accent-contrast);
  border: 0;
  border-radius: 16px;
  padding: 0 18px;
  min-height: 48px;
  font-weight: 600;
}

.btn-send:hover {
  background: var(--accent-strong);
}

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

/* ================= POPOVERY ================= */

.popover {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 16px;
}

.popover-card {
  width: min(520px, 100%);
  max-height: 84vh;
  overflow-y: auto;
  background: var(--panel-strong);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.popover-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.popover-content {
  font-size: 0.9rem;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.flow-stage {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
}

.flow-stage-title {
  font-weight: 700;
  color: var(--accent-strong);
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}

.flow-kv {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 10px;
  font-size: 0.86rem;
}

.flow-kv dt {
  color: var(--muted);
}

.flow-kv dd {
  margin: 0;
}

.flow-sql {
  font-family: "Consolas", "Menlo", monospace;
  font-size: 0.78rem;
  background: var(--code-bg);
  border: 1px solid var(--code-border);
  border-radius: 8px;
  padding: 8px;
  white-space: pre-wrap;
  word-break: break-word;
}

.flow-locked {
  color: var(--muted);
  font-style: italic;
  font-size: 0.84rem;
}

.device-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.device-row:last-child {
  border-bottom: 0;
}

.device-name {
  font-weight: 600;
}

.device-meta {
  color: var(--muted);
  font-size: 0.82rem;
}

.device-row button {
  background: transparent;
  border: 1px solid var(--chip-border);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--danger-strong);
  font-size: 0.82rem;
}

.admin-btn {
  background: transparent;
  border: 1px solid var(--chip-border);
  border-radius: 10px;
  padding: 8px 10px;
  color: var(--accent-strong);
  font-size: 0.82rem;
  cursor: pointer;
  margin-right: 4px;
}

.admin-btn-danger {
  color: var(--danger-strong);
}

.admin-btn-neutral {
  color: var(--text);
}

/* ================= RESPONZIVITA ================= */

@media (min-width: 861px) {
  #btn-drawer {
    display: none;
  }

  .drawer-backdrop {
    display: none !important;
  }
}

@media (max-width: 860px) {
  .brand-mini-name {
    display: none;
  }

  .conversations-panel {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 35;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow);
  }

  .conversations-panel.open {
    transform: translateX(0);
  }

  .mode-btn {
    padding: 8px 10px;
    font-size: 0.8rem;
  }

  .msg {
    max-width: 96%;
  }
}

/* -- nahravanie hlasu -- */

.mic-btn.recording {
  background: var(--danger);
  color: var(--accent-contrast);
  border-color: var(--danger);
  /* Pulz je jediny znak, ze appka naozaj pocuva - bez neho pouzivatel drzi
     tlacidlo a hada. */
  animation: mic-pulse 1.1s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

/* ================= MOBILNE DOLADENIE (jedna ruka, auto) ================= */
@media (max-width: 640px) {
  /* Tlacidlo mikrofonu vacsie na stlacenie jednou rukou */
  .mic-btn {
    width: 56px;
    height: 56px;
    font-size: 1.4rem;
  }

  /* Priestor pod composerom kvoli safe area (gesta na iOS) */
  .composer {
    padding-bottom: calc(10px + env(safe-area-inset-bottom));
  }

  /* Vyraznejsi pulz a vysoky kontrast na mobile */
  .mic-btn.recording {
    animation: mic-pulse-mobile 1s ease-in-out infinite;
    box-shadow: 0 0 16px var(--danger);
  }

  /* Zvacsenie font-size v inpute zabranuje nechcenemu zoomu na iOS */
  .composer-input {
    font-size: 16px;
  }

  /* Lavy panel pre rozhovory nech nerusi sirku obrazovky pri zatvoreni */
  .conversations-panel:not(.open) {
    display: none;
  }

  /* Vyssia citatelnost na rychly pohlad */
  .msg-body {
    font-size: 1.05rem;
    line-height: 1.6;
  }

  /* Obmedzenie sirky spravy na 100%, aby tabulky nepokazili scroll */
  .msg {
    max-width: 100%;
    min-width: 0;
  }

  /* Na zarucenie ze flex potomkovia (bublina) spravne prevezmu min-width */
  .msg-bubble {
    min-width: 0;
  }
}

@keyframes mic-pulse-mobile {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* ================= ADMIN USERS (nova obrazovka) ================= */

/* Sprava pouzivatelov: sirka je PERCENTUALNA, ziadne hadane pixely.
   Skutocnym dovodom vodorovneho posuvania nebola sirka karty, ale
   `white-space: nowrap` zdedeny z `.msg-table` - pri nom sa nesmie zalomit
   nic, takze osem stlpcov s celym menom, casovou peciatkou a tlacidlami
   pretlaci lubovolnu sirku. Preto sa tu zalamovanie povoluje. */
#users-popover .popover-card {
  width: 96vw;
  max-height: 90vh;
}

#users-popover .msg-table th,
#users-popover .msg-table td {
  white-space: normal;
  word-break: break-word;
}

/* Tlacidla akcii a stavovy stitok sa lamat nesmu - rozpadli by sa na
   jednotlive pismena. */
#users-popover .msg-table td:last-child,
#users-popover .msg-table th:last-child,
#users-popover .admin-users-badge {
  white-space: nowrap;
}

.admin-users-cell-actions {
  display: flex;
  gap: 4px;
}

.admin-users-actions {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
  align-items: center;
}

.admin-users-hidden-row {
  opacity: 0.5;
}

.admin-users-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  border: 1px solid var(--chip-border);
}
.admin-users-badge-active {
  background: var(--ok);
  color: var(--panel-strong);
}
.admin-users-badge-blocked {
  background: var(--danger-strong);
  color: var(--panel-strong);
}
.admin-users-badge-hidden {
  background: var(--muted);
  color: var(--panel-strong);
}

.admin-users-form {
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  border-radius: 12px;
  padding: 16px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.admin-users-form-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.admin-users-form-row label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.admin-users-form-row input,
.admin-users-form-row select {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--text);
}

.admin-users-form-row input:focus,
.admin-users-form-row select:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.admin-users-form-buttons {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.admin-users-error {
  color: var(--danger-strong);
  font-size: 0.86rem;
  margin-top: 4px;
}

.admin-users-perm-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}
.admin-users-perm-row:last-child {
  border-bottom: none;
}
.admin-users-perm-label {
  font-weight: 600;
  font-size: 0.88rem;
}
.admin-users-perm-desc {
  font-size: 0.8rem;
  color: var(--muted);
}
.admin-users-perm-select {
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--text);
}

/* -- Mobil: z riadkov tabulky sa robia karty --

   Na sirku telefonu (~360 px) sa osem stlpcov nezmesti ani so zalamovanim:
   na kazdy vyjde ~40 px, co je menej nez jedno slovo, takze prehliadac lame
   nadpisy po JEDNOM PISMENE pod sebou - presne to bolo vidiet na Chrome pre
   Android. Ziadna sirka karty to nespravi, pretoze problem je pocet stlpcov,
   nie sirka. Preto sa tu tabulka rozpadne na karty: hlavicka sa skryje a nazov
   stlpca sa vypise pred hodnotu z `data-label` (nastavuje ho admin-users.js). */
@media (max-width: 720px) {
  #users-popover .popover-card {
    width: 100%;
    max-height: 92vh;
    padding: 12px;
  }

  /* `.msg-table` ma min-width 420px kvoli tabulkam v chate; tu by na uzkom
     displeji vynutila vodorovne posuvanie. */
  #users-popover .msg-table {
    min-width: 0;
  }

  #users-popover .msg-table-wrap {
    overflow-x: visible;
  }

  #users-popover .msg-table thead {
    display: none;
  }

  #users-popover .msg-table,
  #users-popover .msg-table tbody,
  #users-popover .msg-table tr {
    display: block;
  }

  #users-popover .msg-table tr {
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
  }

  #users-popover .msg-table tr:last-child {
    border-bottom: 0;
  }

  #users-popover .msg-table td {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    padding: 4px 10px;
    border-bottom: 0;
    text-align: right;
    /* `anywhere` lame az ked sa slovo naozaj nezmesti, nie zbytocne. */
    word-break: normal;
    overflow-wrap: anywhere;
  }

  #users-popover .msg-table td::before {
    content: attr(data-label);
    flex: 0 0 auto;
    text-align: left;
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
  }

  /* Pri akciach je nazov stlpca zbytocny - tlacidla hovoria samy za seba -
     a musia sa smiet zalomit do viacerych riadkov. */
  #users-popover .msg-table td.admin-users-cell-actions::before {
    content: none;
  }

  #users-popover .msg-table td.admin-users-cell-actions {
    flex-wrap: wrap;
    justify-content: flex-start;
    white-space: normal;
    padding-top: 8px;
  }

  /* Formulare v tej istej obrazovke: na uzkom displeji pod seba. */
  #users-popover .admin-users-actions,
  #users-popover .admin-users-form-buttons {
    flex-wrap: wrap;
  }

  #users-popover .admin-users-perm-row {
    flex-direction: column;
    align-items: stretch;
    gap: 6px;
  }

  #users-popover .admin-users-perm-select {
    width: 100%;
  }
}

/* -- priloha (importny subor) -- */
.attachment-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  padding: 6px 10px;
  border: 1px solid var(--chip-border);
  border-radius: 10px;
  background: var(--chip-bg);
  font-size: 0.85rem;
}

.attachment-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.attachment-clear {
  flex: 0 0 auto;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
}

.attachment-clear:hover {
  color: var(--text);
}


/* -- ponuka dalsich krokov -- */
.msg-followups {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.followup {
  border: 1px solid var(--chip-border);
  background: var(--chip-bg);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.84rem;
  cursor: pointer;
}

.followup:hover {
  border-color: var(--accent);
}


/* -- rozhovory v lavom paneli -- */

.conv-row {
  display: flex;
  align-items: center;
  gap: 2px;
  border-radius: 8px;
}

.conv-row.active {
  background: var(--surface-2, rgba(127, 127, 127, 0.14));
}

.conv-row .conv-item {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Krizik sa ukaze az pri najazde - inak lava lista vyzera ako zoznam na
   mazanie, nie ako zoznam rozhovorov. Na dotyku nie je co najst, preto je
   tam vzdy. */
.conv-delete {
  opacity: 0;
  border: 0;
  background: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px 7px;
  border-radius: 6px;
  font-size: 0.85em;
}

.conv-row:hover .conv-delete,
.conv-delete:focus-visible {
  opacity: 1;
}

.conv-delete:hover {
  color: var(--danger, #c0392b);
}

@media (hover: none) {
  .conv-delete { opacity: 0.6; }
}

.conv-empty {
  color: var(--muted);
  font-size: 0.9em;
  padding: 10px 8px;
  line-height: 1.45;
}

/* -- tlacidlo odoslat / stop -- */

.btn-send .btn-send-icon {
  font-size: 1.05em;
  line-height: 1;
  display: inline-block;
}

.btn-send[data-mode="stop"] {
  background: var(--danger, #c0392b);
}

.btn-send[data-mode="stop"] .btn-send-icon {
  font-size: 0.8em;
}


/* ================= MOBIL: sirka a vyska sa ratajú ================= */
/* Na 400 px obrazovke bola polovica sirky na okrajoch a tlacidlach: tri
   kruhy po 56 px plus siroke tlacidlo nechali na text menej nez tretinu
   riadku. Tu sa to stlaca tak, aby zostal citatelny obsah. */

@media (max-width: 640px) {
  .composer {
    gap: 6px;
    padding: 8px 8px calc(8px + env(safe-area-inset-bottom));
  }

  /* Kruhy boli zvacsene "na jednu ruku", lenze su tri vedla vstupu.
     44 px je stale nad hranicou pohodlneho dotyku (Apple HIG aj Material). */
  .composer .mic-btn {
    width: 44px;
    height: 44px;
    font-size: 1.15rem;
  }

  .btn-send {
    padding: 0;
    width: 44px;
    min-height: 44px;
    border-radius: 14px;
  }

  .messages {
    padding-left: 10px;
    padding-right: 10px;
  }

  .msg {
    max-width: 100%;
  }

  .msg-body {
    /* 1,05 rem s riadkovanim 1,6 robilo z kazdej odpovede dlhy zvitok. */
    font-size: 1rem;
    line-height: 1.5;
  }

  /* Tabulka sa na uzkej obrazovke nezmesti nikdy - musi sa dat posunut
     a nesmie roztiahnut celu stranku. */
  .msg-body .md-table-wrap {
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
  }

  .msg-body .md-table {
    font-size: 0.88rem;
  }

  .msg-body .md-table th,
  .msg-body .md-table td {
    padding: 3px 6px;
  }

  .md-heading {
    font-size: 1.05rem;
  }

  /* Prazdna lista s kontextom zaberala cely riadok textom, ktory nic
     nehovori. Nezmizne - je to jedine miesto, kde clovek vidi, co si appka
     pamata - ale zmensi sa na jeden tenky riadok. */
  .slot-bar.is-empty {
    padding-top: 2px;
    padding-bottom: 2px;
  }

  .slot-bar.is-empty .slot-chip-empty {
    font-size: 0.78rem;
    opacity: 0.65;
  }
}

/* Uzke telefony (360 px): hlavicka sa musi zmestit na jeden riadok. */
@media (max-width: 420px) {
  .composer .mic-btn {
    width: 40px;
    height: 40px;
    font-size: 1.05rem;
  }

  .btn-send {
    width: 40px;
    min-height: 40px;
  }

  .composer-input {
    padding: 9px 10px;
  }

  .user-chip-role {
    display: none;
  }

  .msg-body .md-table {
    font-size: 0.82rem;
  }
}

/* ================= NAVRHY NA ZMENU ================= */
#suggestion-popover .popover-card { width: min(760px, 100%); }
.suggestion-info { color: var(--muted); font-size: 0.85rem; margin: 0; }
.suggestion-form textarea,
.admin-users-form textarea {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--panel-strong);
  color: var(--text);
  font: inherit;
  resize: vertical;
}
.suggestion-error { color: var(--danger, #c0392b); margin: 0; }
.suggestion-row { cursor: pointer; }
.suggestion-row:hover td { background: var(--chip-bg); }
.suggestion-meta { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 0; }
.suggestion-meta dt { color: var(--muted); font-weight: 600; }
.suggestion-meta dd { margin: 0; }
.suggestion-desc { white-space: pre-wrap; margin: 0; }
.suggestion-conv summary { cursor: pointer; font-weight: 600; margin: 6px 0; }
.suggestion-msg { border-left: 3px solid var(--border); padding: 4px 10px; margin: 6px 0; }
.suggestion-msg-user { border-left-color: var(--accent); }
.suggestion-msg-who { font-size: 0.75rem; color: var(--muted); }
.suggestion-context { font-size: 0.75rem; overflow-x: auto; white-space: pre-wrap; }
.suggestion-filter { align-self: flex-start; padding: 6px 10px; border-radius: 8px; }
.suggestion-saved { margin-left: 8px; color: var(--muted); }
.msg-report {
  background: none; border: 1px solid var(--border); border-radius: 8px;
  padding: 2px 8px; font-size: 0.8rem; color: var(--muted); cursor: pointer;
}

/* ================= FORMULAR NAREZU ================= */

/* Tlacidlo s kotucom pily nalavo od kontextu. Rovnaka vyska ako stitky
   kontextu, aby lista neposkakovala. */
.slot-tool {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--chip-border);
  background: var(--chip-bg);
  color: var(--accent);
  cursor: pointer;
}
.slot-tool:hover { border-color: var(--accent); }
.slot-tool:hover svg { transform: rotate(40deg); }
.slot-tool svg { transition: transform 0.3s ease; }

#narez-popover .popover-card { width: min(720px, 100%); }
.narez-form { gap: 14px; }
.narez-form textarea { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.85rem; }
.narez-help { color: var(--muted); font-size: 0.78rem; }
.narez-info { margin: -6px 0 0; font-size: 0.8rem; color: var(--muted); }
.narez-info-chyba { color: var(--danger-strong); }
.narez-fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 12px;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.narez-fieldset legend { font-size: 0.82rem; font-weight: 600; color: var(--muted); padding: 0 4px; }
.narez-radio {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 8px;
  align-items: center;
  cursor: pointer;
}
.narez-radio small { grid-column: 2; color: var(--muted); font-size: 0.78rem; }
.narez-checks { display: flex; flex-direction: column; gap: 6px; font-size: 0.9rem; }
.narez-checks label { cursor: pointer; }
.narez-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
}
.narez-grid input { width: 100%; box-sizing: border-box; }
.narez-nahlad {
  border-left: 3px solid var(--accent);
  padding: 6px 10px;
  font-size: 0.85rem;
}
.narez-nahlad pre {
  margin: 6px 0 0;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  font-size: 0.78rem;
}
@media (max-width: 420px) {
  .narez-grid { grid-template-columns: 1fr 1fr; }
}
