/* ---------- Titulos ---------- */

.page-title {
  font-size: 24px;
  font-weight: 600;
  color: var(--slate-100);
}

.page-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.section-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--slate-500);
}

.muted {
  font-size: 14px;
  color: var(--slate-500);
}

.error-text {
  font-size: 14px;
  color: var(--red-400);
}

/* ---------- Inputs ---------- */

.input,
textarea.input {
  width: 100%;
  border-radius: 6px;
  border: 1px solid var(--slate-700);
  background: var(--slate-950);
  padding: 6px 12px;
  font-size: 14px;
  color: var(--slate-100);
  outline: none;
}

.input:focus,
textarea.input:focus {
  border-color: var(--emerald-500);
}

textarea.input {
  resize: none;
  font-family: var(--font-mono);
}

.input-label {
  display: block;
  margin-bottom: 4px;
  font-size: 14px;
  font-weight: 500;
  color: var(--slate-300);
}

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--slate-300);
}

.checkbox-row input[type="checkbox"] {
  height: 16px;
  width: 16px;
  flex-shrink: 0;
  accent-color: var(--emerald-500);
}

.search-field {
  position: relative;
  width: 100%;
  max-width: 320px;
}

.search-field .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--slate-500);
  pointer-events: none;
}

.search-field input {
  padding-left: 36px;
}

/* ---------- Botoes ---------- */

/* PADRAO DE BOTOES DO APP (usar sempre estas classes, nunca estilo solto):
   .btn + tamanho (.btn-sm em listas/cabecalhos de secao, padrao em barras
   de acao) + variante:
     .btn-primary      acao principal da tela (Gerar, Enviar, Entrar)
     .btn-outline      acao secundaria (Copiar, Atualizar)
     .btn-outline.btn-destructive   limpar/excluir - lixeira, vermelho no
                       hover, 2 cliques via G.armConfirm (.armed)
   Texto sempre dentro de <span class="btn-label"> (o JS troca so ele). */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  border-radius: 6px;
  border: 1px solid transparent;
  padding: 7px 12px;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.15s, border-color 0.15s, color 0.15s, opacity 0.15s;
  white-space: nowrap;
}

.btn-sm {
  min-height: 32px;
  padding: 5px 10px;
  font-size: 12px;
}

.btn:focus-visible {
  outline: 2px solid var(--emerald-500);
  outline-offset: 2px;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

.btn-outline {
  border-color: var(--slate-700);
  color: var(--slate-300);
}

.btn-outline:hover:not(:disabled) {
  background: var(--slate-800);
}

.btn-primary {
  background: var(--emerald-500);
  color: var(--emerald-950);
  font-weight: 500;
}

.btn-primary:hover:not(:disabled) {
  background: var(--emerald-400);
}

.btn-destructive:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--red-500) 50%, transparent);
  background: color-mix(in srgb, var(--red-500) 8%, transparent);
  color: var(--red-400);
}

/* 1o clique de um limpar/excluir: pede confirmacao */
.btn-destructive.armed,
.btn-destructive.armed:hover:not(:disabled) {
  border-color: var(--red-500);
  background: var(--red-500);
  color: #fff;
}

/* feedback depois de copiar */
.btn.copied {
  border-color: color-mix(in srgb, var(--emerald-500) 50%, transparent);
  color: var(--emerald-400);
}

@media (pointer: coarse) {
  .btn,
  .btn-sm {
    min-height: 44px;
  }
}

.btn-pill {
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid var(--slate-700);
  color: var(--slate-400);
  transition: background-color 0.15s, color 0.15s;
}

.btn-pill:hover {
  background: var(--slate-800);
}

.btn-pill.active {
  background: var(--emerald-500);
  color: var(--emerald-950);
  border-color: transparent;
}

.btn-pill .count {
  opacity: 0.7;
}

.spin {
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* ---------- Cards / stat tiles ---------- */

.card {
  border-radius: 12px;
  border: 1px solid var(--slate-800);
  padding: 20px;
}

.stat-tile {
  border-radius: 12px;
  border: 1px solid var(--slate-800);
  background: rgba(15, 23, 42, 0.4);
  padding: 20px;
}

.stat-tile .stat-label {
  font-size: 14px;
  color: var(--slate-500);
}

.stat-tile .stat-value {
  margin-top: 4px;
  font-size: 30px;
  font-weight: 600;
  color: var(--slate-100);
}

.stat-tile .stat-value.accent {
  color: var(--emerald-400);
}

.pill-stat {
  border-radius: 6px;
  border: 1px solid var(--slate-800);
  background: rgba(15, 23, 42, 0.5);
  padding: 6px 12px;
  font-size: 12px;
  color: var(--slate-400);
}

.pill-stat strong {
  color: var(--slate-100);
  font-weight: 600;
}

.pill-stat .accent {
  color: var(--emerald-400);
  font-weight: 600;
}

.pill-stat .danger {
  color: var(--red-400);
  font-weight: 600;
}

/* ---------- Tabela ---------- */

.table-wrap {
  overflow-x: auto;
  border-radius: 12px;
  border: 1px solid var(--slate-800);
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 14px;
}

thead tr {
  border-bottom: 1px solid var(--slate-800);
  color: var(--slate-500);
}

th {
  padding: 12px 16px;
  font-weight: 500;
}

tbody tr {
  border-bottom: 1px solid rgba(30, 41, 59, 0.6);
}

tbody tr:last-child {
  border-bottom: none;
}

td {
  padding: 12px 16px;
  vertical-align: middle;
}

td.link-cell a {
  color: var(--emerald-400);
}

td.link-cell a:hover {
  text-decoration: underline;
}

td.title-cell {
  max-width: 28rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--slate-100);
}

/* ---------- Toast ---------- */

#toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 200;
  max-width: 24rem;
  border-radius: 8px;
  border: 1px solid;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.45;
  overflow-wrap: anywhere;
  cursor: pointer;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.35);
}

/* celular: largura toda com respiro dos dois lados (antes ficava grudado
   na borda esquerda, porque a largura maxima era maior que a tela) e
   acima da barra de gestos do iPhone */
@media (max-width: 640px) {
  #toast {
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    max-width: none;
  }
}

/* ---------- Estado de erro (falha ao carregar uma tela) ---------- */

/* grid: icone | texto | botao. Em tela estreita o botao desce pra baixo
   do texto - com flex ele disputava a linha e espremia o texto a uma
   palavra por linha */
.error-state {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: start;
  gap: 4px 12px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--red-500) 35%, transparent);
  background: color-mix(in srgb, var(--red-500) 8%, transparent);
  padding: 16px;
}

.error-state-icon {
  margin-top: 2px;
  color: var(--red-400);
}

.error-state-text {
  min-width: 0;
}

.error-state-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--slate-100);
}

.error-state-msg {
  margin-top: 2px;
  font-size: 13px;
  color: var(--slate-400);
  overflow-wrap: anywhere;
}

@media (max-width: 640px) {
  .error-state {
    grid-template-columns: auto 1fr;
  }

  .error-state .error-retry {
    grid-column: 2;
    justify-self: start;
    margin-top: 8px;
  }
}

#toast.toast-success {
  border-color: rgba(16, 185, 129, 0.3);
  background: var(--emerald-950);
  color: #6ee7b7;
}

#toast.toast-warning {
  border-color: rgba(251, 191, 36, 0.35);
  background: #2a1d05;
  color: var(--amber-400);
}

#toast.toast-error {
  border-color: rgba(239, 68, 68, 0.3);
  background: var(--red-950);
  color: #fca5a5;
}

/* ---------- Badges ---------- */

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 500;
}

.badge-slate {
  background: var(--slate-800);
  color: var(--slate-400);
}

.badge-red {
  background: rgba(239, 68, 68, 0.15);
  color: var(--red-400);
}
