/* Panel styling, extracted from the inline <style> blocks that were
   copy-pasted into all five pages of all five bots. There was no CSS file
   anywhere under static/ before this one.

   Keeps the original dark neon look so the panel stays recognisable, and uses
   --accent (set per bot in base.html) so each brand is visually distinct -
   the cheapest guard against firing the right action at the wrong brand. */

:root {
  --accent: #64748b;
  --bg: #0b1020;
  --bg-soft: #141a2e;
  --line: rgba(148, 163, 184, 0.18);
  --text: #e5e7eb;
  --muted: #94a3b8;
  --ok: #10b981;
  --warn: #f59e0b;
  --bad: #ef4444;
}

body {
  background:
    radial-gradient(1100px 500px at 12% -10%, rgba(99, 102, 241, 0.16), transparent 60%),
    radial-gradient(900px 420px at 88% 0%, color-mix(in srgb, var(--accent) 22%, transparent), transparent 60%),
    var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.wrap { max-width: 1180px; margin: 0 auto; padding: 1.5rem 1rem 4rem; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* -- local-mode warning strip ------------------------------------------ */

.env-strip {
  background: repeating-linear-gradient(45deg, #78350f, #78350f 12px, #92400e 12px, #92400e 24px);
  color: #fff7ed;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  text-align: center;
  padding: 0.35rem 1rem;
}

/* -- brand bar and nav ------------------------------------------------- */

.brandbar {
  border-bottom: 1px solid var(--line);
  background: rgba(10, 14, 28, 0.85);
  backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 30;
}
.brandbar::before {
  content: ""; display: block; height: 3px; background: var(--accent);
}
.brandbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 0.7rem 1rem;
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.brand-dot {
  width: 0.9rem; height: 0.9rem; border-radius: 999px; flex: none;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}
.brand-name { font-weight: 700; font-size: 1.05rem; line-height: 1.2; }
.brand-key { font-size: 0.72rem; color: var(--muted); font-family: ui-monospace, monospace; }

.bot-switch {
  background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); border-radius: 0.5rem;
  padding: 0.4rem 0.6rem; font-size: 0.85rem; max-width: 15rem;
}
.bot-switch:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.navbar {
  max-width: 1180px; margin: 0 auto; padding: 0 1rem;
  display: flex; gap: 0.25rem; overflow-x: auto;
}
.nav-link {
  padding: 0.55rem 0.85rem; font-size: 0.9rem; color: var(--muted);
  border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none;
}
.nav-link:hover { color: var(--text); }
.nav-link.is-active { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

/* -- cards and stats --------------------------------------------------- */

.card {
  background: linear-gradient(180deg, rgba(20, 26, 46, 0.95), rgba(13, 18, 34, 0.95));
  border: 1px solid var(--line); border-radius: 0.9rem; padding: 1.1rem;
}
.card-title {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin-bottom: 0.75rem;
}
.neon-border { border: 1px solid var(--accent); box-shadow: 0 0 18px -6px var(--accent); }

.stat-grid {
  display: grid; gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(10rem, 1fr));
}
.stat { background: var(--bg-soft); border: 1px solid var(--line); border-radius: 0.75rem; padding: 0.85rem 1rem; }
.stat-value { font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat-label { font-size: 0.75rem; color: var(--muted); margin-top: 0.15rem; }

/* -- buttons ----------------------------------------------------------- */

.btn, .neon-button {
  display: inline-flex; align-items: center; gap: 0.4rem;
  background: var(--accent); color: #0b1020; font-weight: 650;
  border: none; border-radius: 0.55rem; padding: 0.5rem 0.95rem;
  font-size: 0.88rem; cursor: pointer; text-decoration: none;
}
.btn:hover, .neon-button:hover { filter: brightness(1.1); }
.btn[disabled] { opacity: 0.5; cursor: not-allowed; filter: none; }

.btn-ghost {
  background: transparent; color: var(--muted);
  border: 1px solid var(--line); border-radius: 0.5rem;
  padding: 0.4rem 0.8rem; font-size: 0.85rem; cursor: pointer; text-decoration: none;
}
.btn-ghost:hover { color: var(--text); border-color: var(--accent); }

/* -- tables ------------------------------------------------------------ */

.table-scroll { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 0.88rem; }
table.data th {
  text-align: left; font-size: 0.73rem; text-transform: uppercase;
  letter-spacing: 0.05em; color: var(--muted);
  padding: 0.5rem 0.7rem; border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 0.55rem 0.7rem; border-bottom: 1px solid rgba(148,163,184,0.08); vertical-align: top; }
table.data tbody tr:hover { background: rgba(148, 163, 184, 0.05); }
.num { font-variant-numeric: tabular-nums; text-align: right; }
.clip { max-width: 28rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* -- badges ------------------------------------------------------------ */

.badge {
  display: inline-block; font-size: 0.7rem; padding: 0.12rem 0.45rem;
  border-radius: 999px; border: 1px solid var(--line); color: var(--muted);
  white-space: nowrap;
}
.badge-ok { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 45%, transparent); }
.badge-warn { color: var(--warn); border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.badge-bad { color: var(--bad); border-color: color-mix(in srgb, var(--bad) 45%, transparent); }

/* -- forms ------------------------------------------------------------- */

label.field { display: block; font-size: 0.8rem; color: var(--muted); margin-bottom: 0.3rem; }
input[type="text"], input[type="password"], input[type="url"], input[type="search"],
input[type="number"], textarea, select.field {
  width: 100%; background: var(--bg-soft); color: var(--text);
  border: 1px solid var(--line); border-radius: 0.55rem;
  padding: 0.55rem 0.7rem; font-size: 0.9rem;
}
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

/* -- flash ------------------------------------------------------------- */

.flash {
  border-radius: 0.6rem; padding: 0.7rem 0.95rem; margin-bottom: 0.85rem;
  font-size: 0.9rem; border: 1px solid var(--line); background: var(--bg-soft);
}
.flash-error { border-color: color-mix(in srgb, var(--bad) 50%, transparent); color: #fecaca; }
.flash-success { border-color: color-mix(in srgb, var(--ok) 50%, transparent); color: #bbf7d0; }
.flash-warning { border-color: color-mix(in srgb, var(--warn) 50%, transparent); color: #fde68a; }

/* -- misc -------------------------------------------------------------- */

.muted { color: var(--muted); }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.grid-2 { display: grid; gap: 1rem; grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr)); }
.empty { text-align: center; color: var(--muted); padding: 2rem 1rem; font-size: 0.9rem; }

@media (max-width: 640px) {
  .brandbar-inner { flex-wrap: wrap; }
  .bot-switch { max-width: 100%; }
}

/* -- Telegram preview -------------------------------------------------- */

.tg-preview {
  background: #17212b;                 /* Telegram dark chat background */
  border: 1px solid var(--line);
  border-radius: 0.9rem;
  padding: 1rem;
}
.tg-preview-head {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--muted); margin-bottom: 0.75rem;
  display: flex; align-items: center; gap: 0.4rem;
}
.tg-dot { width: 0.5rem; height: 0.5rem; border-radius: 999px; background: #2aabee; }

.tg-bubble {
  background: #2b5278;                 /* outgoing bubble */
  border-radius: 0.9rem; padding: 0.6rem;
  max-width: 24rem; color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}
.tg-media img, .tg-media video {
  display: block; width: 100%; border-radius: 0.55rem; margin-bottom: 0.45rem;
  max-height: 16rem; object-fit: cover; background: #0e1621;
}
.tg-media-note { font-size: 0.68rem; color: #c9d6e3; margin-bottom: 0.4rem; }
.tg-text { font-size: 0.9rem; line-height: 1.45; white-space: pre-wrap; word-break: break-word; }
.tg-empty { font-size: 0.85rem; color: #9fb3c8; font-style: italic; }

.tg-buttons { margin-top: 0.5rem; display: flex; flex-direction: column; gap: 0.25rem; }
.tg-btn {
  background: rgba(255,255,255,0.12); border-radius: 0.45rem;
  padding: 0.5rem; text-align: center; font-size: 0.85rem; color: #e9f0f7;
}

.tg-warn {
  margin-top: 0.75rem; font-size: 0.78rem; color: #fde68a;
  border: 1px solid color-mix(in srgb, var(--warn) 45%, transparent);
  border-radius: 0.5rem; padding: 0.5rem 0.65rem;
}

/* -- button editor ----------------------------------------------------- */

/* Button editor rows adapt to the CARD width, not the viewport: these sit
   inside a two-column settings grid, so a card is ~480px even on a wide
   screen and a three-across row truncated the button text. Container
   queries measure the right box. */
.card { container-type: inline-size; }

.button-row {
  display: grid; gap: 0.4rem; margin-bottom: 0.5rem;
  grid-template-columns: 1fr 1.4fr auto;
  align-items: center;
}
@container (max-width: 34rem) {
  /* Name + remove on one line, URL on its own - the URL is the long value
     and deserves the full width. Placement is explicit because the DOM
     order is name, url, button: left to auto-placement the button landed
     on a third row and its column collapsed to 0px. */
  .button-row {
    grid-template-columns: 1fr auto;
    padding-bottom: 0.55rem;
    margin-bottom: 0.55rem;
    border-bottom: 1px solid rgba(148, 163, 184, 0.08);
  }
  .button-row > input[name$='name[]'] { grid-area: 1 / 1 / 2 / 2; }
  .button-row > button { grid-area: 1 / 2 / 2 / 3; }
  .button-row > input[name$='url[]'] { grid-area: 2 / 1 / 3 / -1; }
  /* The last row's separator would sit directly above the form's own
     divider, drawing two lines a few pixels apart. */
  .button-row:last-child { border-bottom: none; margin-bottom: 0; }
}
@media (max-width: 560px) {
  .button-row { grid-template-columns: 1fr; }
}

.tpl-thumb {
  width: 100%; max-height: 9rem; object-fit: cover;
  border-radius: 0.55rem; border: 1px solid var(--line); background: #0e1621;
}

/* -- progress ---------------------------------------------------------- */

.progress {
  height: 0.5rem; background: var(--bg-soft); border-radius: 999px;
  overflow: hidden; border: 1px solid var(--line);
}
.progress-bar { height: 100%; background: var(--accent); transition: width 0.4s ease; }

/* -- slot chips -------------------------------------------------------- */

.slot-chip {
  display: inline-block; font-family: ui-monospace, monospace;
  font-size: 0.8rem; padding: 0.2rem 0.5rem; border-radius: 0.4rem;
  background: var(--bg-soft); border: 1px solid var(--line); margin: 0.1rem;
}

/* -- settings layout --------------------------------------------------- */

/* align-items:start is the fix for the dead space: a CSS grid stretches
   every item in a row to the tallest one, so a short card sat on top of
   150px of nothing. */
.settings-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(22rem, 1fr));
  align-items: start;
  margin-bottom: 1rem;
}
.settings-grid.wide { grid-template-columns: repeat(auto-fit, minmax(30rem, 1fr)); }

.section-head {
  font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted); margin: 1.75rem 0 0.6rem;
  padding-bottom: 0.4rem; border-bottom: 1px solid var(--line);
}
.section-head:first-of-type { margin-top: 0; }

/* Uniform vertical rhythm inside forms - fields were 2px apart in one card
   and 20px in the next. */
.field-group { margin-bottom: 0.9rem; }
.field-group:last-child { margin-bottom: 0; }
.field-hint { font-size: 0.75rem; color: var(--muted); margin-top: 0.35rem; line-height: 1.5; }
.form-actions {
  display: flex; gap: 0.5rem; flex-wrap: wrap;
  margin-top: 1.1rem; padding-top: 0.9rem; border-top: 1px solid var(--line);
}

/* -- file picker ------------------------------------------------------- */

/* The native control renders an OS-styled button plus untranslatable
   "No file chosen" text - a white box in a dark panel. The input is kept
   (so the form still works and the label still opens the dialog) but moved
   out of sight, and the label becomes the control. */
.file-field {
  display: flex; align-items: center; gap: 0.6rem;
  background: var(--bg-soft); border: 1px solid var(--line);
  border-radius: 0.55rem; padding: 0.4rem 0.5rem 0.4rem 0.4rem;
  cursor: pointer; width: 100%;
}
.file-field:hover { border-color: var(--accent); }
.file-field:focus-within { outline: 2px solid var(--accent); outline-offset: 1px; }
.file-field input[type="file"] {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.file-btn {
  flex: none; background: rgba(148, 163, 184, 0.14); color: var(--text);
  border: 1px solid var(--line); border-radius: 0.4rem;
  padding: 0.3rem 0.7rem; font-size: 0.82rem; font-weight: 600;
}
.file-field:hover .file-btn { background: rgba(148, 163, 184, 0.22); }
.file-name {
  font-size: 0.82rem; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0;
}
.file-name.has-file { color: var(--text); }

/* -- compact list rows (brands, test recipients) ----------------------- */

.list-row {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.55rem 0.1rem;
  border-bottom: 1px solid rgba(148, 163, 184, 0.08);
}
.list-row:last-of-type { border-bottom: none; }
.list-row .grow { flex: 1 1 auto; min-width: 0; }
.list-row .sub { font-size: 0.75rem; color: var(--muted); }
.list-row form { flex: none; }

/* Checkbox + label pairs were colliding with the text beside them. */
.check-line {
  display: inline-flex; align-items: center; gap: 0.45rem;
  font-size: 0.82rem; cursor: pointer;
}
.check-line input[type="checkbox"] { width: 0.95rem; height: 0.95rem; flex: none; }

.saved-media {
  display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap;
  margin-top: 0.5rem; padding: 0.45rem 0.6rem;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: 0.5rem;
  font-size: 0.78rem;
}
