/* ARQUIVO: public/css/admin.css */

/* ==========================================================
   Tokens de design
   Paleta: modo escuro completo, preto como base (não navy) -
   estilo Vercel/Linear/Stripe. Verde-esmeralda como único acento
   de cor, reservado para ações primárias e estado positivo;
   âmbar (atenção/pendente) e vermelho (erro) completam a semântica.
   Tipografia: fonte do sistema para texto; monoespaçada para
   qualquer dado sensível/copiável (tokens, ids, hashes) - é o
   elemento de assinatura visual deste painel.
   ========================================================== */
:root {
  --bg-canvas: #000000;
  --bg-surface: #0a0a0a;
  --bg-surface-elevated: #141414;
  --bg-surface-hover: #1f1f1f;

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  --text-primary: #f4f4f5;
  --text-secondary: #a1a1aa;
  --text-muted: #71717a;

  --accent: #10b981;
  --accent-strong: #34d399;
  --accent-soft: rgba(16, 185, 129, 0.14);
  --accent-contrast: #001b12;

  --warning: #f59e0b;
  --warning-soft: rgba(245, 158, 11, 0.14);

  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.14);

  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;

  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.45);
  --shadow-lg: 0 20px 60px rgba(0, 0, 0, 0.65);

  --ease-fluid: cubic-bezier(0.16, 1, 0.3, 1);

  /* Faz os controles nativos do navegador (checkbox, select, scrollbar)
     renderizarem na variante escura automaticamente, sem precisar
     reimplementar cada um do zero. */
  color-scheme: dark;
}

* { box-sizing: border-box; }

/* Garante que o atributo "hidden" sempre vence, mesmo em elementos que
   têm display:flex/grid definido por classe (ex: .login-screen, .app) -
   sem isso, [hidden] e a classe têm a mesma especificidade e o CSS de
   classe pode "ganhar" dependendo da ordem, deixando os dois visíveis
   ao mesmo tempo sobrepostos. */
[hidden] {
  display: none !important;
}

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-canvas);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

button, input, select {
  font-family: inherit;
  font-size: inherit;
}

button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.01em; }

/* ==========================================================
   Tela de login
   ========================================================== */
.login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 20% 20%, rgba(16, 185, 129, 0.10), transparent 40%),
    var(--bg-canvas);
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  animation: fade-up 0.4s var(--ease-fluid);
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.login-brand__mark {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-md);
  background: var(--bg-surface-hover);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 18px;
  flex-shrink: 0;
}

.login-brand h1 { font-size: 17px; }
.login-brand__subtitle { margin: 2px 0 0; font-size: 12.5px; color: var(--text-secondary); }

/* ==========================================================
   Campos de formulário
   ========================================================== */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field--inline {
  min-width: 240px;
}

.field__label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
}

.field__input {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  width: 100%;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field__input::placeholder { color: var(--text-muted); }

.field__input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.field__hint { font-size: 12px; color: var(--text-muted); margin-top: 2px; }

.form-error {
  background: var(--danger-soft);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  margin: 0;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-grid > .field--full { grid-column: 1 / -1; }

/* ==========================================================
   Botões
   ========================================================== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: none;
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-weight: 600;
  font-size: 13.5px;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
  white-space: nowrap;
}

.btn:active { transform: scale(0.97); }

.btn--block { width: 100%; }

.btn--primary { background: var(--accent); color: #051b12; }
.btn--primary:hover { background: var(--accent-strong); }
.btn--primary:disabled { background: var(--bg-surface-hover); color: var(--text-muted); cursor: not-allowed; }

.btn--secondary {
  background: var(--bg-surface-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
}
.btn--secondary:hover { border-color: var(--accent); color: var(--accent-strong); background: var(--bg-surface-hover); }

.btn--ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-strong);
}
.btn--ghost:hover { color: var(--text-primary); border-color: var(--text-secondary); }

.btn--danger { background: var(--danger); color: #2a0a0a; }
.btn--danger:hover { background: #fca5a5; }

.btn--danger-ghost {
  background: transparent;
  color: var(--danger);
  border: 1px solid var(--danger-soft);
}
.btn--danger-ghost:hover { background: var(--danger-soft); }

.btn--sm { padding: 6px 10px; font-size: 12.5px; }

/* ==========================================================
   Layout do app
   ========================================================== */
.app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  padding: 20px 16px;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 15px;
  padding: 0 8px 20px;
}

.sidebar__mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-weight: 700;
}

.sidebar__nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  background: transparent;
  border: none;
  border-left: 2px solid transparent;
  color: var(--text-secondary);
  text-align: left;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.nav-item:hover { background: var(--bg-surface-hover); color: var(--text-primary); }
.nav-item.is-active { background: var(--bg-surface-hover); color: #fff; border-left-color: var(--accent); }

.sidebar__footer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.admin-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 13px;
  padding: 0 4px;
}

.admin-chip__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.content {
  padding: 32px 40px;
  overflow-y: auto;
}

.view { display: none; }
.view.is-active { display: block; animation: fade-up 0.25s var(--ease-fluid); }

@keyframes fade-up {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 20px;
}

.view-subtitle { margin: 4px 0 0; color: var(--text-secondary); font-size: 13px; }
.section-subtitle { font-size: 14px; margin: 28px 0 12px; color: var(--text-secondary); }

.toolbar {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin-bottom: 16px;
}

.toolbar .field__input { max-width: 320px; }

/* ==========================================================
   Tabela
   ========================================================== */
.table-wrap {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.table { width: 100%; border-collapse: collapse; }

.table th {
  text-align: left;
  font-size: 11.5px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  font-weight: 600;
  padding: 12px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
}

.table td {
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.table tr:last-child td { border-bottom: none; }
.table tr { transition: background-color 0.1s ease; }
.table tr:hover td { background: var(--bg-surface-hover); }

.table-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 16px !important;
}

.cell-muted { color: var(--text-muted); }

/* Chip monoespaçado - elemento de assinatura para dados sensíveis/copiáveis */
.mono-chip {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-surface);
  border: 1px dashed var(--border-strong);
  border-radius: 6px;
  padding: 3px 8px;
  color: var(--text-primary);
  display: inline-block;
}

/* ==========================================================
   Badges
   ========================================================== */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
}

.badge--success { background: var(--accent-soft); color: var(--accent-strong); }
.badge--warning { background: var(--warning-soft); color: var(--warning); }
.badge--danger { background: var(--danger-soft); color: var(--danger); }
.badge--neutral { background: var(--bg-surface-hover); color: var(--text-secondary); }

/* ==========================================================
   Paginação
   ========================================================== */
.pagination {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--text-secondary);
}

/* ==========================================================
   Card de split ativo
   ========================================================== */
.split-active-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  margin-bottom: 8px;
  transition: border-color 0.15s ease;
}

.split-active-card__label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 4px;
}

.split-active-card__value {
  font-family: var(--font-mono);
  font-size: 28px;
  font-weight: 700;
  color: var(--accent-strong);
}

.split-active-card__actions { display: flex; gap: 10px; }

/* ==========================================================
   Modal
   ========================================================== */
.modal-root {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  animation: backdrop-in 0.15s ease;
}

.modal-root[hidden] { display: none; }

@keyframes backdrop-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 460px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  animation: modal-in 0.2s var(--ease-fluid);
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.97) translateY(4px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.modal__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.modal__title { font-size: 16px; }
.modal__subtitle { margin: 4px 0 0; font-size: 12.5px; color: var(--text-secondary); }

.modal__close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1;
  padding: 4px;
  transition: color 0.15s ease;
}
.modal__close:hover { color: var(--text-primary); }

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.modal__body { display: flex; flex-direction: column; gap: 14px; }

.checkbox-group { display: flex; flex-direction: column; gap: 8px; }
.checkbox-row { display: flex; align-items: center; gap: 8px; font-size: 13px; }

.token-reveal {
  background: var(--bg-canvas);
  color: var(--text-primary);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  word-break: break-all;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.token-warning {
  background: var(--warning-soft);
  color: var(--warning);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 12.5px;
}

/* ==========================================================
   Toasts
   ========================================================== */
.toast-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 200;
}

.toast {
  background: var(--bg-surface-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  font-size: 13px;
  max-width: 320px;
  border-left: 3px solid var(--accent);
  animation: toast-in 0.2s var(--ease-fluid);
}

.toast--error { border-left-color: var(--danger); }

@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================
   Barra de progresso no topo (chamadas à API em andamento)
   ========================================================== */
.top-progress-bar {
  position: fixed;
  top: 0;
  left: 0;
  height: 2px;
  width: 0%;
  background: var(--accent);
  box-shadow: 0 0 8px var(--accent);
  z-index: 300;
  opacity: 0;
  transition: width 0.3s ease, opacity 0.2s ease;
}

.top-progress-bar.is-active {
  opacity: 1;
  width: 70%;
  transition: width 8s cubic-bezier(0.15, 0.8, 0.4, 1);
}

.top-progress-bar.is-done {
  width: 100%;
  opacity: 0;
  transition: width 0.2s ease, opacity 0.4s ease 0.1s;
}

/* ==========================================================
   Skeleton loading (tabelas)
   ========================================================== */
.skeleton {
  display: inline-block;
  height: 12px;
  border-radius: 4px;
  width: 100%;
  background: linear-gradient(90deg, var(--bg-surface-hover) 25%, var(--bg-surface) 50%, var(--bg-surface-hover) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
}

.skeleton--sm { width: 60%; }
.skeleton--badge { width: 64px; height: 18px; border-radius: 999px; }

@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ==========================================================
   Spinner (botões e estados de carregamento pontuais)
   ========================================================== */
.spinner {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spinner-spin 0.6s linear infinite;
  flex-shrink: 0;
}

/* Antes usado para botões claros - agora todo o painel é escuro, então
   este variante fica visualmente igual ao padrão (mantido só para não
   quebrar quem já referencia esta classe). */
.spinner--dark {
  border-color: rgba(255, 255, 255, 0.25);
  border-top-color: var(--text-primary);
}

@keyframes spinner-spin {
  to { transform: rotate(360deg); }
}

.btn[data-loading="true"] {
  pointer-events: none;
  opacity: 0.85;
}

@media (prefers-reduced-motion: reduce) {
  .skeleton { animation: none; }
  .spinner { animation-duration: 1.2s; }
  .top-progress-bar { transition: none; }
  .toast { animation: none; }
  .view.is-active { animation: none; }
  .modal { animation: none; }
  .modal-root { animation: none; }
  .login-card { animation: none; }
}

/* ==========================================================
   Responsivo
   ========================================================== */
@media (max-width: 860px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }

  .sidebar {
    flex-direction: row;
    align-items: center;
    padding: 12px 16px;
    overflow-x: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .sidebar__brand { padding: 0 12px 0 0; }
  .sidebar__nav { flex-direction: row; }
  .sidebar__footer { flex-direction: row; border-top: none; padding-top: 0; margin-left: auto; }
  .admin-chip { display: none; }

  .content { padding: 20px; }
  .form-grid { grid-template-columns: 1fr; }
}