:root {
  color-scheme: dark;
  --bg: #111111;
  --chat-bg: #000000;
  --sidebar: #080808;
  --panel: #171717;
  --panel-2: #2f2f2f;
  --panel-3: #262626;
  --line: #303030;
  --line-soft: #242424;
  --text: #f4f4f4;
  --muted: #a3a3a3;
  --green: #10a37f;
  --red: #ff6b6b;
  --blue: #c7c7c7;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--sidebar);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  width: 100%;
  height: 100dvh;
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: var(--sidebar);
  padding: 14px 12px;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 2px 4px 8px;
}

.brand span, .chat-head p, .meta, small, .login-panel p {
  color: var(--muted);
}

.brand-mark {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: #f5f5f5;
  color: #050505;
  font-weight: 900;
}

.nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  padding: 3px;
  background: #111111;
}

button {
  border: 1px solid transparent;
  color: var(--text);
  background: transparent;
  border-radius: 8px;
  min-height: 40px;
  cursor: pointer;
  font: inherit;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.nav button {
  width: 100%;
  min-height: 32px;
  justify-content: center;
  text-align: center;
  padding: 0 5px;
  color: #d8d8d8;
  background: transparent;
  font-size: 12px;
  white-space: nowrap;
}

.nav button.active {
  color: #ffffff;
  background: var(--panel-3);
  border-color: transparent;
}

button.active, button:hover {
  background: var(--panel-3);
  border-color: var(--line-soft);
}

button:focus-visible,
textarea:focus-visible,
input:focus-visible {
  outline: 2px solid rgba(244, 244, 244, 0.28);
  outline-offset: 2px;
}

.status-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel);
}

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

.status-head button {
  width: 34px;
  min-height: 32px;
  background: var(--panel-2);
}

.status-list {
  display: grid;
  gap: 10px;
}

.status-notice {
  border: 1px solid rgba(16, 163, 127, 0.35);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--text);
  background: rgba(16, 163, 127, 0.1);
  font-size: 12px;
}

.agent-summary {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-bottom: 12px;
}

.system-card,
.agent-kpi {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: var(--panel-3);
}

.system-card {
  display: grid;
  gap: 12px;
}

.system-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.system-head strong {
  display: block;
}

.system-head span,
.system-metrics span {
  color: var(--muted);
  font-size: 12px;
}

.pill {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 3px 8px;
  font-size: 11px;
}

.pill.ok {
  border-color: rgba(16, 163, 127, 0.45);
  color: var(--green);
}

.pill.bad {
  border-color: rgba(255, 107, 107, 0.5);
  color: var(--red);
}

.system-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
}

.system-metrics div {
  border-top: 1px solid var(--line);
  padding-top: 8px;
}

.system-metrics strong {
  display: block;
  font-size: 16px;
  line-height: 1.2;
}

.agent-kpi strong {
  display: block;
  font-size: 18px;
}

.agent-kpi span {
  color: var(--muted);
  font-size: 12px;
}

.agent-kpi.small strong {
  font-size: 15px;
}

.jobs-list {
  display: grid;
  gap: 10px;
}

.job-row {
  display: grid;
  gap: 6px;
}

.job-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.job-head span {
  min-width: 28px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 7px;
  color: var(--green);
  text-align: center;
  font-size: 12px;
}

.job-row small {
  display: block;
  overflow-wrap: anywhere;
}

.wiki-graph {
  display: grid;
  gap: 10px;
}

.wiki-root {
  border: 1px solid rgba(16, 163, 127, 0.45);
  border-radius: 8px;
  padding: 9px 10px;
  background: rgba(16, 163, 127, 0.12);
  font-weight: 700;
}

.wiki-lines {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.wiki-lines span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 8px;
  background: #101010;
  color: var(--muted);
  font-size: 12px;
}

.status-row {
  display: grid;
  grid-template-columns: 10px 1fr;
  gap: 10px;
  align-items: center;
}

.status-row.rich {
  grid-template-columns: 10px minmax(0, 1fr) auto;
  align-items: start;
}

.status-title {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.status-title em {
  color: var(--green);
  font-style: normal;
  font-size: 12px;
  white-space: nowrap;
}

.status-row small {
  display: block;
  overflow-wrap: anywhere;
}

.restart-agent {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
  white-space: nowrap;
  background: var(--panel-2);
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.dot.ok { background: var(--green); }
.dot.bad { background: var(--red); }

.logout {
  margin-top: auto;
  width: 100%;
  background: #101010;
  border-color: var(--line-soft);
}

.chat {
  height: 100dvh;
  min-height: 0;
  width: 100%;
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
  background: var(--chat-bg);
}

.chat-head {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 14px max(24px, calc((100vw - 320px - 860px) / 2));
  background: var(--chat-bg);
}

.chat-head h1 {
  margin: 0 0 4px;
  font-size: 20px;
  font-weight: 650;
}

.chat-head p {
  margin: 0;
}

.messages {
  overflow: auto;
  min-height: 0;
  padding: 28px max(24px, calc((100vw - 320px - 860px) / 2)) 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overscroll-behavior: contain;
}

.message {
  display: flex;
}
.message.user { justify-content: flex-end; }
.message.assistant { justify-content: flex-start; }

.bubble {
  width: min(760px, 88%);
  border: 1px solid transparent;
  border-radius: 20px;
  padding: 14px 16px;
  background: transparent;
}
.message.user .bubble {
  width: fit-content;
  max-width: min(760px, 82%);
  background: #2f2f2f;
  border-color: #2f2f2f;
  box-shadow: var(--shadow);
}
.message.assistant .bubble {
  border-color: transparent;
  padding-left: 0;
}

.meta {
  font-size: 12px;
  margin-bottom: 8px;
  color: #8f8f8f;
}
.meta span {
  color: var(--green);
  margin-left: 8px;
}

pre {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  margin: 0;
  font: inherit;
  line-height: 1.5;
}

.message-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.message-actions button {
  padding: 0 14px;
  border-color: var(--green);
  background: rgba(16, 163, 127, 0.12);
}

.composer {
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  padding: 14px max(24px, calc((100vw - 320px - 860px) / 2)) 18px;
  background: var(--chat-bg);
}

.composer-box {
  border: 1px solid #3a3a3a;
  border-radius: 18px;
  background: #2a2a2a;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.02), var(--shadow);
  padding: 8px;
}

.composer-row {
  display: grid;
  grid-template-columns: 38px 1fr 44px;
  gap: 8px;
  align-items: end;
}

textarea, input {
  width: 100%;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
  padding: 12px 8px;
  font: inherit;
  box-shadow: none;
}

textarea {
  resize: none;
  min-height: 48px;
  max-height: 180px;
}

.composer-row button {
  width: 44px;
  min-height: 44px;
  padding: 0;
  overflow: hidden;
  text-indent: -999px;
  position: relative;
  background: #f4f4f4;
  border-color: #f4f4f4;
  color: #111111;
  border-radius: 14px;
}

.composer-row button[type="submit"]::after {
  content: "↑";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  text-indent: 0;
  font-size: 20px;
  font-weight: 800;
}

.attach-button {
  width: 38px;
  min-height: 38px;
  border-radius: 12px;
  background: transparent;
  border-color: transparent;
  color: var(--muted);
  text-indent: 0;
  display: grid;
  place-items: center;
}

.attach-button::after {
  content: none;
}

.attach-button svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.attach-button:hover {
  background: var(--panel-2);
  color: var(--text);
}

.composer button:disabled {
  cursor: default;
  opacity: 0.55;
}

.attachment-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}

.attachment-tray:empty {
  display: none;
}

.pending-attachment {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 240px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 6px 5px 10px;
  background: #202020;
  color: var(--text);
  font-size: 12px;
}

.pending-attachment span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pending-attachment button {
  min-height: 22px;
  width: 22px;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
}

.message-attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.attachment {
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--text);
  text-decoration: none;
  background: #202020;
  overflow: hidden;
}

.attachment.file {
  padding: 8px 10px;
  font-size: 13px;
}

.attachment.image {
  display: grid;
  width: min(220px, 100%);
}

.attachment.image img {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  display: block;
}

.attachment.image span {
  padding: 7px 9px;
  font-size: 12px;
  color: var(--muted);
}

.login-body {
  display: grid;
  place-items: center;
  background: #0b0b0b;
}

.login-panel {
  width: min(420px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 28px;
  box-shadow: var(--shadow);
}

.login-panel h1 {
  margin: 16px 0 4px;
}

.login-panel form {
  display: grid;
  gap: 10px;
  margin-top: 20px;
}

.login-panel button {
  margin-top: 8px;
}

@media (max-width: 760px) {
  body {
    overflow: auto;
  }
  .shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }
  .sidebar {
    height: auto;
    max-height: 40dvh;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }
  .chat {
    height: 58dvh;
    min-height: 70vh;
  }
  .messages {
    min-height: 50vh;
    padding: 14px;
  }
  .message.user .bubble {
    max-width: 90%;
  }
  .composer {
    padding: 12px;
  }
  .composer-row {
    grid-template-columns: 38px 1fr 44px;
  }
}

/* Prehlednejsi prihlasovaci stranka: svetla karta, viditelna pole (plati i pro verify.html) */
.login-body {
  background: linear-gradient(160deg, #2b2b30, #131315);
}
.login-panel {
  background: #f7f7f8;
  border: 1px solid #d9d9de;
  color: #17171a;
}
.login-panel h1 { color: #17171a; }
.login-panel p { color: #5c5c66; }
.login-panel .brand-mark { background: #10a37f; color: #ffffff; }
.login-panel label { color: #3c3c44; font-size: 14px; font-weight: 600; }
.login-panel input {
  background: #ffffff;
  border: 1px solid #c9c9d1;
  border-radius: 8px;
  color: #17171a;
  padding: 12px;
}
.login-panel input:focus-visible { outline: 2px solid rgba(16, 163, 127, 0.45); outline-offset: 1px; }
.login-panel button {
  background: #10a37f;
  border-color: #10a37f;
  color: #ffffff;
  font-weight: 600;
}
.login-panel button:hover { background: #0d8a6c; border-color: #0d8a6c; }

/* ===== Redesign leveho menu ===== */
.sidebar {
  background: linear-gradient(180deg, #0e0e10, #060607);
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: #26262a transparent;
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: #26262a; border-radius: 4px; }
.brand {
  padding: 6px 4px 12px;
  border-bottom: 1px solid var(--line-soft);
}
.brand-mark {
  width: 38px;
  height: 38px;
  border-radius: 11px;
  background: linear-gradient(135deg, #13bf95, #0a6c54);
  color: #ffffff;
  box-shadow: 0 4px 16px rgba(16, 163, 127, 0.3);
}
.brand strong { font-size: 15px; letter-spacing: 0.01em; }
.nav {
  background: #0f0f11;
  border-radius: 10px;
  padding: 4px;
}
.nav button { border-radius: 7px; }
.nav button.active {
  background: rgba(16, 163, 127, 0.16);
  color: #35d6ad;
}
.status-card {
  background: #101013;
  border-color: #232327;
  border-radius: 12px;
  padding: 12px;
}
.status-head { margin-bottom: 10px; }
.status-head strong {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}
.status-head strong::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  margin-right: 8px;
  vertical-align: 2px;
}
.status-head button {
  width: 30px;
  min-height: 28px;
  border-radius: 7px;
  border: 1px solid var(--line-soft);
  background: transparent;
  color: var(--muted);
}
.status-head button:hover { color: var(--text); background: var(--panel-3); }
.system-card, .agent-kpi { background: #141417; border-color: #232327; }
.logout {
  background: transparent;
  border: 1px solid #3a2626;
  border-radius: 10px;
  color: #e08b8b;
}
.logout:hover { background: rgba(255, 107, 107, 0.08); border-color: #5a3030; color: #ff9d9d; }

/* ===== Hlavicka chatu: hledani a mobilni menu ===== */
.chat-head {
  display: flex;
  align-items: center;
  gap: 14px;
}
.chat-head-info { flex: 1; min-width: 0; }
.chat-head-info p { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-search input {
  width: min(240px, 34vw);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #0d0d0f;
  padding: 9px 14px;
  font-size: 13px;
}
.chat-search input:focus-visible { outline: 2px solid rgba(16, 163, 127, 0.4); outline-offset: 1px; }
.menu-toggle {
  display: none;
  width: 40px;
  min-height: 38px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  place-items: center;
  flex: none;
}
.menu-toggle svg { width: 20px; height: 20px; stroke: var(--text); stroke-width: 2; fill: none; stroke-linecap: round; }
.sidebar-backdrop { display: none; }

/* ===== Barevne route stitky ===== */
.route-badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 11px;
  color: var(--muted);
}
.route-badge.route-direct { color: #35d6ad; border-color: rgba(16, 163, 127, 0.45); }
.route-badge.route-wiki { color: #7ab8ff; border-color: rgba(122, 184, 255, 0.45); }
.route-badge.route-n8n { color: #ffb86b; border-color: rgba(255, 184, 107, 0.45); }
.route-badge.route-langgraph { color: #d19bff; border-color: rgba(209, 155, 255, 0.45); }

/* ===== Markdown v odpovedich ===== */
.bubble .md { font-size: 14.5px; line-height: 1.55; overflow-wrap: anywhere; }
.bubble .md p { margin: 0 0 8px; }
.bubble .md p:last-child, .bubble .md ul:last-child { margin-bottom: 0; }
.bubble .md h4 { margin: 12px 0 6px; font-size: 15px; }
.bubble .md h4:first-child { margin-top: 0; }
.bubble .md ul { margin: 4px 0 10px; padding-left: 20px; }
.bubble .md li { margin: 2px 0; }
.bubble .md code {
  background: #1c1c20;
  border: 1px solid #2c2c31;
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.bubble .md pre.code {
  background: #131316;
  border: 1px solid #2a2a2e;
  border-radius: 10px;
  padding: 10px 12px;
  margin: 6px 0 10px;
  overflow-x: auto;
  font-size: 13px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  white-space: pre;
}

/* ===== Kopirovat, indikator psani, oddelovace dnu ===== */
.copy-btn {
  min-height: 22px;
  padding: 0 8px;
  margin-left: auto;
  border: 1px solid var(--line-soft);
  border-radius: 6px;
  font-size: 11px;
  color: var(--muted);
  opacity: 0;
  transition: opacity 0.15s ease;
}
.message:hover .copy-btn { opacity: 1; }
.copy-btn:hover { color: var(--text); }
.bubble .meta { display: flex; align-items: center; gap: 8px; }
.typing-bubble { display: flex; align-items: center; gap: 10px; }
.typing-bubble small { color: var(--muted); }
.typing-dots { display: inline-flex; gap: 4px; }
.typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  animation: typing-blink 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.typing-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes typing-blink {
  0%, 70%, 100% { opacity: 0.25; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-3px); }
}
.date-sep {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  margin: 4px 0;
}
.date-sep::before, .date-sep::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line-soft);
}

/* ===== Mobil: vysouvaci sidebar ===== */
@media (max-width: 760px) {
  .menu-toggle { display: grid; }
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    width: min(320px, 85vw);
    transform: translateX(-105%);
    transition: transform 0.2s ease;
    z-index: 40;
    box-shadow: var(--shadow);
  }
  .sidebar.open { transform: none; }
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 30;
  }
  .sidebar-backdrop.show { display: block; }
  .chat-head { flex-wrap: wrap; }
  .chat-search { order: 3; width: 100%; }
  .chat-search input { width: 100%; }
  .chat-head-info p { white-space: normal; }
}
