/* Emma Admin — světlé + tmavé téma, mobil-first. Žádné externí zdroje. */
:root {
  --bg: #f4f5f7;
  --panel: #ffffff;
  --panel-2: #eef0f3;
  --text: #1c2126;
  --muted: #667085;
  --border: #d9dde3;
  --accent: #2563eb;
  --accent-2: #0ea5a4;
  --danger: #dc2626;
  --ok: #16a34a;
  --bubble-client: #e7edf6;
  --bubble-bot: #d9f2ee;
  --add: #16a34a;
  --add-bg: #e7f6ec;
  --del: #dc2626;
  --del-bg: #fbeaea;
  --warn-bg: #fff4e0;
  --warn-border: #f0b429;
}
:root[data-theme="dark"], :root:not([data-theme]) {
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1319;
    --panel: #171c24;
    --panel-2: #1f2632;
    --text: #e6e9ee;
    --muted: #93a0b0;
    --border: #2a323e;
    --accent: #5b8cff;
    --accent-2: #2dd4bf;
    --bubble-client: #232c3a;
    --bubble-bot: #1d3a37;
    --add: #4ade80;
    --add-bg: #12301d;
    --del: #f87171;
    --del-bg: #341717;
    --warn-bg: #3a2f14;
    --warn-border: #b8860b;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1319;
  --panel: #171c24;
  --panel-2: #1f2632;
  --text: #e6e9ee;
  --muted: #93a0b0;
  --border: #2a323e;
  --accent: #5b8cff;
  --accent-2: #2dd4bf;
  --bubble-client: #232c3a;
  --bubble-bot: #1d3a37;
  --add: #4ade80;
  --add-bg: #12301d;
  --del: #f87171;
  --del-bg: #341717;
  --warn-bg: #3a2f14;
  --warn-border: #b8860b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
  line-height: 1.45;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }

/* ── Topbar ── */
.topbar {
  display: flex; align-items: center; gap: .5rem;
  flex-wrap: wrap;
  padding: .5rem .75rem;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { font-weight: 700; margin-right: .5rem; }
.mainnav { display: flex; gap: .25rem; flex-wrap: wrap; flex: 1; }
.mainnav a {
  padding: .35rem .6rem; border-radius: 6px; color: var(--text);
}
.mainnav a.active { background: var(--accent); color: #fff; }
.topbar-actions { display: flex; gap: .35rem; }
button {
  font: inherit; cursor: pointer;
  background: var(--accent); color: #fff; border: none;
  padding: .4rem .7rem; border-radius: 6px;
}
button:hover { filter: brightness(1.05); }
button.ghost { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
button.secondary { background: var(--panel-2); color: var(--text); border: 1px solid var(--border); }
button:disabled { opacity: .5; cursor: default; }

.view { padding: 1rem; max-width: 1100px; margin: 0 auto; }
h1, h2, h3 { margin: .2rem 0 .6rem; }
h1 { font-size: 1.35rem; }
h2 { font-size: 1.1rem; }

/* ── Karty ── */
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: .75rem; margin-bottom: 1rem; }
.card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: .8rem;
}
.card .big { font-size: 1.6rem; font-weight: 700; }
.card .lbl { color: var(--muted); font-size: .8rem; text-transform: uppercase; letter-spacing: .03em; }
.card .sub { color: var(--muted); font-size: .85rem; }

.panel {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 1rem; margin-bottom: 1rem;
}

/* ── Tabulky ── */
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: .9rem; }
th, td { text-align: left; padding: .45rem .5rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
tr.clickable { cursor: pointer; }
tr.clickable:hover { background: var(--panel-2); }

.badge {
  display: inline-block; padding: .1rem .45rem; border-radius: 999px;
  font-size: .78rem; background: var(--panel-2); border: 1px solid var(--border);
}
.badge.in { background: var(--bubble-client); }
.badge.out { background: var(--bubble-bot); }
.tag { display:inline-block; padding:.05rem .4rem; border-radius:4px; background:var(--panel-2); font-size:.8rem; }
.path-arrow { color: var(--muted); }

/* ── Chat bubliny ── */
.chat { display: flex; flex-direction: column; gap: .4rem; }
.bubble { max-width: 80%; padding: .5rem .7rem; border-radius: 12px; white-space: pre-wrap; word-break: break-word; }
.bubble.client { align-self: flex-start; background: var(--bubble-client); border-bottom-left-radius: 3px; }
.bubble.bot { align-self: flex-end; background: var(--bubble-bot); border-bottom-right-radius: 3px; }
.bubble .who { font-size: .72rem; color: var(--muted); margin-bottom: .15rem; }

/* ── Filtry / ovládání ── */
.controls { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; margin-bottom: .75rem; }
select, input[type="text"], input[type="password"], textarea {
  font: inherit; padding: .35rem .5rem; border-radius: 6px;
  border: 1px solid var(--border); background: var(--panel); color: var(--text);
}
.pager { display: flex; gap: .5rem; align-items: center; margin-top: .75rem; }

/* ── Detail (klíč→hodnota) ── */
.kv { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .75rem; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; word-break: break-word; }

/* ── Server sparkliny ── */
.spark-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: .75rem; }
.spark { background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: .6rem .8rem; }
.spark .val { font-size: 1.3rem; font-weight: 700; }
.spark svg { width: 100%; height: 40px; display: block; margin-top: .3rem; }

/* ── Ladění / editor ── */
.editor { width: 100%; min-height: 55vh; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .85rem; }
.warn { background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: 8px; padding: .6rem .8rem; margin: .5rem 0; }
.info { background: var(--panel-2); border: 1px solid var(--border); border-radius: 8px; padding: .5rem .8rem; margin: .5rem 0; }
.diff { font-family: ui-monospace, monospace; font-size: .82rem; white-space: pre-wrap; border: 1px solid var(--border); border-radius: 8px; overflow: auto; max-height: 40vh; }
.diff .l { padding: 0 .5rem; }
.diff .add { background: var(--add-bg); color: var(--add); }
.diff .del { background: var(--del-bg); color: var(--del); }
.prompt-list { list-style: none; padding: 0; margin: 0; }
.prompt-list li { display: flex; justify-content: space-between; gap: .5rem; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.legend { display: flex; gap: 1rem; font-size: .82rem; margin-top: .3rem; }
.legend span::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: .3rem; vertical-align: middle; }
.legend .l-hovory::before { background: var(--accent); }
.legend .l-wa::before { background: var(--accent-2); }

.err-box { background: var(--del-bg); border: 1px solid var(--del); color: var(--del); padding: .6rem .8rem; border-radius: 8px; }

/* ── Login ── */
.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.login-card { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 1.5rem; width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: .5rem; }
.login-card h1 { margin: 0; }
.login-card input { width: 100%; }
.login-card button { margin-top: .5rem; }
.login-error { color: var(--danger); font-size: .9rem; }

/* ── Modal detail ── */
.modal-back { position: fixed; inset: 0; background: rgba(0,0,0,.5); display: flex; align-items: flex-start; justify-content: center; padding: 1rem; overflow-y: auto; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 1rem; max-width: 720px; width: 100%; margin: 2vh auto; }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: .5rem; margin-bottom: .5rem; }

@media (max-width: 640px) {
  .brand { width: 100%; }
  .mainnav { order: 3; width: 100%; }
}
