/* Painel das Listas — tema escuro, azul-marinho suave.
   Mini App do Telegram: largura de celular é o caso principal, então tudo é pensado em coluna
   única e só ganha duas colunas a partir de 560px. */

:root {
  --bg: #0a111e;
  --bg-soft: #0e1728;
  --surface: #121d31;
  --surface-2: #17243c;
  --surface-3: #1d2d49;
  --border: #223454;
  --border-soft: #1a2840;

  --text: #e8eefb;
  --text-dim: #9fb2cf;
  --text-faint: #6d81a3;

  /* Azul escuro fraco: o acento do painel. Dessaturado de propósito — num tema escuro um azul
     vivo vibra e cansa a vista em tela de celular. */
  --accent: #5c89c4;
  --accent-soft: #2a4568;
  --accent-dim: rgba(92, 137, 196, 0.14);

  --ok: #5fab7f;
  --warn: #c9a15e;
  --danger: #c2706e;

  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 8px 28px rgba(3, 8, 18, 0.5);
  --gutter: 16px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior-y: contain;
}

body {
  /* Respeita a área segura do aparelho e a barra do Mini App. */
  padding: 0 var(--gutter) calc(32px + env(safe-area-inset-bottom));
  max-width: 720px;
  margin: 0 auto;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.3rem; }
h2 { font-size: 1.05rem; }
p { margin: 0; }
.hidden { display: none !important; }

/* ---------- Portão de entrada ---------- */
.gate { min-height: 100vh; display: grid; place-items: center; padding: var(--gutter); }
.gate-card { text-align: center; max-width: 320px; }
.gate-card h1 { font-size: 1.1rem; margin: 18px 0 8px; }
.gate-card p { color: var(--text-dim); font-size: 0.92rem; }

.spinner {
  width: 34px; height: 34px; margin: 0 auto;
  border: 2.5px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

/* ---------- Cabeçalho da lista de bots ---------- */
.hero { padding: 28px 0 18px; }
.hero-row { display: flex; align-items: center; gap: 13px; }
.hero-hi { color: var(--text-dim); font-size: 0.88rem; }
.hero-title { font-size: 1.45rem; }
.hero-sub { color: var(--text-faint); font-size: 0.88rem; margin-top: 14px; }

.avatar {
  width: 46px; height: 46px; flex: 0 0 46px;
  border-radius: 50%;
  background: linear-gradient(145deg, var(--accent-soft), var(--surface-3));
  border: 1px solid var(--border);
  background-size: cover; background-position: center;
  display: grid; place-items: center;
  font-weight: 650; color: var(--accent);
}

/* ---------- Cartões ---------- */
.stack { display: flex; flex-direction: column; gap: 10px; }

.card {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 15px;
}

.bot-card {
  display: flex; align-items: center; gap: 13px;
  width: 100%; text-align: left;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius);
  padding: 14px 15px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.bot-card:hover { border-color: var(--accent-soft); background: var(--surface-2); }
.bot-card:active { transform: scale(0.99); }

.bot-mark {
  width: 40px; height: 40px; flex: 0 0 40px;
  border-radius: 11px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-soft);
  display: grid; place-items: center;
  font-weight: 650; color: var(--accent); font-size: 1rem;
}
.bot-card-body { min-width: 0; flex: 1; }
.bot-card-name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bot-card-meta { color: var(--text-faint); font-size: 0.82rem; margin-top: 2px; }
.bot-card-arrow { color: var(--text-faint); font-size: 1.2rem; }

/* ---------- Cabeçalho do bot e abas ---------- */
.bot-head { padding: 20px 0 14px; }
.bot-head-main { display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.bot-head h1 { font-size: 1.25rem; word-break: break-word; }

.btn-ghost {
  background: none; border: none; padding: 0;
  color: var(--text-dim); font: inherit; font-size: 0.92rem; cursor: pointer;
}
.btn-ghost:hover { color: var(--accent); }

.tabs {
  display: flex; gap: 6px;
  overflow-x: auto;
  scrollbar-width: none;
  padding-bottom: 12px;
  margin: 0 calc(var(--gutter) * -1);
  padding-left: var(--gutter); padding-right: var(--gutter);
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  color: var(--text-dim);
  border-radius: 999px;
  padding: 7px 14px;
  font: inherit; font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.15s;
}
.tab:hover { color: var(--text); border-color: var(--accent-soft); }
.tab.is-active { background: var(--accent-dim); border-color: var(--accent-soft); color: var(--accent); font-weight: 600; }

.panel { display: flex; flex-direction: column; gap: 12px; padding-top: 4px; }

/* ---------- Seções ---------- */
.section-title {
  display: flex; align-items: baseline; justify-content: space-between; gap: 10px;
  margin: 10px 2px 2px;
}
.section-title h2 { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-faint); font-weight: 650; }
.section-title span { color: var(--text-faint); font-size: 0.8rem; }

/* ---------- Grade de números ---------- */
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 560px) { .stats { grid-template-columns: repeat(4, 1fr); } }

.stat {
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 13px 14px;
}
.stat-value { font-size: 1.4rem; font-weight: 650; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--text-faint); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.05em; margin-top: 3px; }
.stat.is-accent .stat-value { color: var(--accent); }
.stat.is-warn .stat-value { color: var(--warn); }

/* ---------- Linhas de formulário ---------- */
.row {
  display: flex; align-items: center; justify-content: space-between; gap: 14px;
  padding: 13px 15px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
.row-stack { flex-direction: column; align-items: stretch; }
.row-label { font-weight: 550; }
.row-hint { color: var(--text-faint); font-size: 0.8rem; margin-top: 3px; }
.row-main { min-width: 0; }

input[type="text"], input[type="number"], select, textarea {
  background: var(--bg-soft);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font: inherit; font-size: 0.92rem;
  width: 100%;
  /* 16px no foco evita o zoom automático do iOS em campo de formulário. */
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
input[type="number"] { max-width: 120px; }
textarea { min-height: 96px; resize: vertical; line-height: 1.5; }
.row > input[type="number"], .row > select { flex: 0 0 auto; width: auto; min-width: 110px; }

/* Interruptor */
.switch { position: relative; flex: 0 0 46px; width: 46px; height: 27px; }
.switch input { position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.switch span {
  position: absolute; inset: 0;
  background: var(--surface-3); border: 1px solid var(--border);
  border-radius: 999px; transition: background 0.18s, border-color 0.18s;
  pointer-events: none;
}
.switch span::after {
  content: ""; position: absolute; top: 3px; left: 3px;
  width: 19px; height: 19px; border-radius: 50%;
  background: var(--text-dim); transition: transform 0.18s, background 0.18s;
}
.switch input:checked + span { background: var(--accent-soft); border-color: var(--accent); }
.switch input:checked + span::after { transform: translateX(19px); background: var(--accent); }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px var(--accent-dim); }

/* ---------- Botões ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px 16px;
  font: inherit; font-size: 0.92rem; font-weight: 550;
  cursor: pointer;
  transition: all 0.15s;
}
.btn:hover { border-color: var(--accent-soft); background: var(--surface-3); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn-primary { background: var(--accent-soft); border-color: var(--accent); color: #eaf2ff; }
.btn-primary:hover { background: #31507a; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { border-color: var(--danger); background: rgba(194, 112, 110, 0.1); }
.btn-sm { padding: 6px 11px; font-size: 0.84rem; }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; }

/* Barra de salvar, fixa no rodapé enquanto houver mudança pendente */
.savebar {
  position: sticky; bottom: 0;
  margin: 6px calc(var(--gutter) * -1) 0;
  padding: 12px var(--gutter) calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 62%, rgba(10, 17, 30, 0));
  display: flex; gap: 10px; align-items: center;
}
.savebar p { color: var(--text-dim); font-size: 0.85rem; flex: 1; }

/* ---------- Itens de lista (chats, links, admins) ---------- */
.item {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
}
.item-body { flex: 1; min-width: 0; }
.item-title { font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-meta { color: var(--text-faint); font-size: 0.8rem; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-actions { display: flex; gap: 6px; flex: 0 0 auto; }

.pill {
  display: inline-flex; align-items: center; gap: 5px;
  background: var(--surface-3); border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 999px; padding: 2px 10px;
  font-size: 0.76rem; font-weight: 550; white-space: nowrap;
}
.pill.is-ok { color: var(--ok); border-color: rgba(95, 171, 127, 0.4); background: rgba(95, 171, 127, 0.1); }
.pill.is-warn { color: var(--warn); border-color: rgba(201, 161, 94, 0.4); background: rgba(201, 161, 94, 0.1); }
.pill.is-danger { color: var(--danger); border-color: rgba(194, 112, 110, 0.4); background: rgba(194, 112, 110, 0.1); }
.pill.is-dim { color: var(--text-faint); }

.filters { display: flex; gap: 6px; overflow-x: auto; flex-wrap: wrap; }
.filters .tab { font-size: 0.82rem; padding: 5px 11px; }

/* ---------- Vazio, carregando, erro ---------- */
.empty { text-align: center; padding: 44px 20px; color: var(--text-dim); }
.empty-icon { font-size: 2rem; margin-bottom: 10px; opacity: 0.7; }
.empty h2 { color: var(--text); margin-bottom: 6px; }
.empty p { font-size: 0.88rem; }

.skeleton {
  height: 62px; border-radius: var(--radius-sm);
  background: linear-gradient(100deg, var(--surface) 30%, var(--surface-2) 50%, var(--surface) 70%);
  background-size: 300% 100%;
  animation: shimmer 1.3s ease-in-out infinite;
}
@keyframes shimmer { from { background-position: 150% 0; } to { background-position: -50% 0; } }
@media (prefers-reduced-motion: reduce) { .skeleton { animation: none; } }

/* ---------- Aviso flutuante ---------- */
.toast {
  position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom));
  transform: translate(-50%, 140%);
  /* Só o transform não basta: o elemento continua pintado, e como tem fundo e borda ele aparece
     como uma pílula cinza vazia (numa captura de página inteira, ou num salto de rolagem). */
  visibility: hidden; opacity: 0; pointer-events: none;
  background: var(--surface-3); border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px; padding: 10px 18px;
  font-size: 0.88rem; font-weight: 550;
  box-shadow: var(--shadow);
  max-width: calc(100% - 32px); text-align: center;
  transition: transform 0.25s cubic-bezier(0.2, 0.9, 0.3, 1), opacity 0.2s, visibility 0.25s;
  z-index: 50;
}
.toast.is-up { transform: translate(-50%, 0); visibility: visible; opacity: 1; }
.toast.is-ok { border-color: rgba(95, 171, 127, 0.5); }
.toast.is-err { border-color: rgba(194, 112, 110, 0.55); }

/* ---------- Menu de seções do bot ----------
   Substitui a faixa de abas: com 7 seções, a rolagem lateral no topo esconde metade dos itens e
   obriga a adivinhar o que existe. Em lista, tudo aparece de uma vez e o alvo de toque é grande. */

.menu { display: flex; flex-direction: column; gap: 8px; }

.menu-row {
  display: flex; align-items: center; gap: 13px;
  width: 100%; text-align: left;
  background: var(--surface);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.menu-row:hover { border-color: var(--accent-soft); background: var(--surface-2); }
.menu-row:active { transform: scale(0.99); }
.menu-row:focus-visible { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

.menu-icon {
  width: 36px; height: 36px; flex: 0 0 36px;
  border-radius: 10px;
  background: var(--accent-dim);
  border: 1px solid var(--accent-soft);
  display: grid; place-items: center;
  font-size: 1rem;
}
.menu-body { flex: 1; min-width: 0; }
.menu-title { font-weight: 550; }
.menu-hint { color: var(--text-faint); font-size: 0.8rem; margin-top: 1px; }
.menu-side { display: flex; align-items: center; gap: 9px; flex: 0 0 auto; }
.menu-arrow { color: var(--text-faint); font-size: 1.15rem; }

/* Cabeçalho da página aberta */
.page-head { display: flex; align-items: center; gap: 10px; padding: 2px 2px 6px; }
.page-head h2 { font-size: 1.1rem; font-weight: 650; letter-spacing: -0.01em; }

/* Linha de resumo: ao contrário de .item-meta (que corta com reticências para manter a altura das
   linhas de lista), aqui o texto precisa quebrar — é uma frase, não um rótulo de uma linha só. */
.card-line {
  color: var(--text-dim);
  font-size: 0.84rem;
  white-space: normal;
  overflow-wrap: anywhere;
}
.card-line + .card-line { margin-top: 4px; }
