/* ===========================================================================
   Painel de Propostas · Zauber Brand
   Tokens copiados do Design System (roxo único, tudo é cartão, Sora).
   Este CSS vive só em /admin — as propostas são documentos isolados.
   ========================================================================= */

:root {
  /* Marca */
  --brand: #5005f2;
  --brand-hover: #3f04c8;
  --brand-grad: linear-gradient(105deg, #5005f2, #7b22d9);
  --ink-blue: #2e2b5e;
  --lavender: #a89cf0;

  /* Superfícies */
  --bg: #f4f3f9;
  --surface: #ffffff;
  --surface-soft: #faf9fd;
  --lilac: #f1edfc;
  --evidence: #f3efff;
  --tile: #efeafe;
  --badge-bg: #eee9fe;
  --dark: #14152b;

  /* Texto */
  --text-1: #14152b;
  --text-2: #3a3d57;
  --text-3: #5a5f78;
  --text-4: #6a6f86;
  --text-5: #7a7f95;
  --text-6: #9a9ab0;

  /* Bordas */
  --border: #edecf3;
  --border-lilac: #e7e1f7;
  --border-accent: #d9ccff;
  --border-input: #e3e2ec;
  --chip: #f3f2fb;

  /* Elevação */
  --shadow-card: 0 1px 2px rgba(20, 21, 43, .04), 0 14px 30px rgba(20, 21, 43, .04);
  --shadow-brand: 0 12px 26px rgba(80, 5, 242, .26);
  --shadow-brand-sm: 0 8px 18px rgba(80, 5, 242, .22);
  --shadow-emph: 0 20px 44px rgba(20, 21, 43, .28);

  /* Forma */
  --r-panel: 22px;
  --r-card: 20px;
  --r-sm: 16px;
  --r-btn: 12px;
  --r-chip: 8px;

  /* Estado */
  --danger: #c62828;
  --danger-bg: #fdeceb;
  --danger-border: #f6cfcc;
  --success: #1b7a4b;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  font-family: 'Sora', system-ui, -apple-system, sans-serif;
  color: var(--text-1);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { text-decoration: none; color: var(--brand); }
a:hover { color: var(--brand-hover); }
p { text-wrap: pretty; }
::selection { background: var(--brand); color: #fff; }
[hidden] { display: none !important; }

/* ── Marca ───────────────────────────────────────────────────────────── */
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand-mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: var(--brand); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex: none;
}

/* O Z é mais largo que alto (105.85 × 84.05): dimensiona-se pela largura. */
.brand-mark img { width: 58%; height: auto; display: block; }

.brand-mark--lg {
  width: 46px; height: 46px; border-radius: 14px;
  font-size: 21px; box-shadow: var(--shadow-brand-sm);
}

.brand-text {
  font-size: 15px; font-weight: 700; letter-spacing: -.01em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Botões ──────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 11px 19px; border-radius: var(--r-btn);
  border: 1px solid transparent; cursor: pointer;
  white-space: nowrap; line-height: 1.2;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn svg { flex: none; }

.btn-primary { background: var(--brand); color: #fff; box-shadow: var(--shadow-brand-sm); }
.btn-primary:hover:not(:disabled) { background: var(--brand-hover); }

.btn-secondary { background: var(--surface); color: var(--text-1); border-color: var(--border-input); }
.btn-secondary:hover:not(:disabled) { border-color: var(--brand); color: var(--brand); }

.btn-ghost { background: transparent; color: var(--text-4); border-color: transparent; }
.btn-ghost:hover:not(:disabled) { color: var(--brand); background: var(--badge-bg); }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover:not(:disabled) { background: #a81f1f; }

.btn-block { width: 100%; }

/* Ação compacta dentro do card */
.btn-mini {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit; font-size: 12.5px; font-weight: 600;
  padding: 7px 12px; border-radius: 9px;
  background: var(--chip); color: var(--text-2);
  border: 1px solid transparent; cursor: pointer; line-height: 1.2;
}
.btn-mini:hover { background: var(--badge-bg); color: var(--brand); }
.btn-mini--danger:hover { background: var(--danger-bg); color: var(--danger); }
.btn-mini svg { flex: none; }

/* ── Badges e pills ──────────────────────────────────────────────────── */
.badge {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 7px 15px; background: var(--badge-bg); color: var(--brand);
  border-radius: 999px; font-size: 12px; font-weight: 600;
  letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
}

.pill {
  display: inline-flex; align-items: center; max-width: 100%;
  background: var(--surface); border: 1px solid var(--border-lilac); color: var(--brand);
  padding: 5px 12px; border-radius: 999px;
  font-size: 12.5px; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Login ───────────────────────────────────────────────────────────── */
.login {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; position: relative; overflow: hidden;
}
.login::before,
.login::after {
  content: ''; position: absolute; pointer-events: none; border-radius: 50%;
}
.login::before {
  top: -200px; right: -120px; width: 540px; height: 540px;
  background: radial-gradient(circle, rgba(80, 5, 242, .12), rgba(80, 5, 242, 0) 70%);
}
.login::after {
  bottom: -160px; left: -160px; width: 480px; height: 480px;
  background: radial-gradient(circle, rgba(150, 100, 255, .12), rgba(150, 100, 255, 0) 70%);
}

.login-card {
  position: relative; width: 100%; max-width: 400px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-panel); padding: clamp(28px, 4vw, 38px);
  box-shadow: var(--shadow-card);
}

.login-title {
  font-size: 27px; font-weight: 700; letter-spacing: -.02em;
  margin: 20px 0 0; color: var(--text-1);
}
.login-sub { font-size: 14.5px; color: var(--text-4); line-height: 1.6; margin: 8px 0 26px; }

/* ── Campos ──────────────────────────────────────────────────────────── */
.field { display: block; margin-bottom: 16px; }
.field-label {
  display: block; font-size: 12.5px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--text-6); margin-bottom: 8px;
}
.field-hint { font-size: 12.5px; color: var(--text-5); line-height: 1.55; margin: 7px 0 0; }

.input {
  width: 100%; font-family: inherit; font-size: 14.5px; color: var(--text-1);
  background: var(--surface); border: 1px solid var(--border-input);
  border-radius: var(--r-btn); padding: 12px 15px; line-height: 1.4;
}
.input::placeholder { color: var(--text-6); }
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px rgba(80, 5, 242, .12); }
.input:disabled { background: var(--surface-soft); color: var(--text-5); }

textarea.input { resize: vertical; min-height: 150px; line-height: 1.6; }
textarea.input.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }

.form-error {
  display: flex; align-items: flex-start; gap: 9px;
  background: var(--danger-bg); border: 1px solid var(--danger-border);
  color: var(--danger); border-radius: var(--r-btn);
  padding: 11px 14px; font-size: 13.5px; font-weight: 500;
  line-height: 1.5; margin: 0 0 16px;
}

/* Prefixo de URL: propostas.zauberbrand.com/____ */
.slug-field { display: flex; align-items: stretch; }
.slug-prefix {
  display: flex; align-items: center; flex: none;
  background: var(--surface-soft); border: 1px solid var(--border-input); border-right: none;
  border-radius: var(--r-btn) 0 0 var(--r-btn);
  padding: 0 12px; font-size: 13px; color: var(--text-5); white-space: nowrap;
}
.slug-field .input { border-radius: 0 var(--r-btn) var(--r-btn) 0; }

/* ── Topo do painel ──────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  background: rgba(244, 243, 249, .82);
  backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(20, 21, 43, .06);
}
.topbar-inner {
  max-width: 1180px; margin: 0 auto; padding: 15px 24px;
  display: flex; align-items: center; justify-content: space-between; gap: 20px;
}
.topbar-actions { display: flex; align-items: center; gap: 12px; }

.container { max-width: 1180px; margin: 0 auto; padding: 32px 24px 80px; }

/* ── Barra de ferramentas ────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; }

.search { position: relative; flex: 1; min-width: 0; }
.search-icon {
  position: absolute; left: 14px; top: 50%; transform: translateY(-50%);
  color: var(--text-6); pointer-events: none;
}
.search-input { padding-left: 42px; }
.search-input::-webkit-search-cancel-button { -webkit-appearance: none; }

/* ── Grade de cards ──────────────────────────────────────────────────── */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 18px; }

/* Sem overflow:hidden aqui — senão o tooltip das ações seria cortado.
   O recorte fica na própria thumbnail, que é o único filho que precisa dele. */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); box-shadow: var(--shadow-card);
  display: flex; flex-direction: column;
}
.card:hover { border-color: var(--border-accent); }

/* Thumbnail: preview real da proposta, escalado. */
.thumb {
  position: relative; display: block; width: 100%;
  aspect-ratio: 16 / 10; overflow: hidden;
  border-radius: calc(var(--r-card) - 1px) calc(var(--r-card) - 1px) 0 0;
  background: var(--poster, var(--brand));
  border-bottom: 1px solid var(--border); cursor: pointer;
}

.thumb-poster {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 22px; text-align: center;
  font-size: 15px; font-weight: 700; letter-spacing: -.01em; line-height: 1.3;
  color: #fff; text-shadow: 0 1px 3px rgba(0, 0, 0, .25);
  background: var(--poster, var(--brand));
}

.thumb-frame {
  position: absolute; top: 0; left: 0;
  width: 1280px; height: 800px; border: 0;
  transform: scale(var(--thumb-scale, .25)); transform-origin: 0 0;
  opacity: 0; pointer-events: none; background: #fff;
}
.thumb-frame.is-ready { opacity: 1; }

.thumb-overlay {
  position: absolute; inset: 0; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  background: rgba(20, 21, 43, .42); opacity: 0;
}
.thumb:hover .thumb-overlay { opacity: 1; }
.thumb-overlay span {
  display: inline-flex; align-items: center; gap: 8px;
  background: #fff; color: var(--brand);
  padding: 10px 18px; border-radius: 11px;
  font-size: 13.5px; font-weight: 700; box-shadow: 0 12px 26px rgba(0, 0, 0, .18);
}

.card-body { padding: 20px 22px; display: flex; flex-direction: column; gap: 11px; flex: 1; }

.card-name {
  font-size: 17px; font-weight: 700; line-height: 1.25;
  margin: 0; color: var(--text-1);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.card-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.card-date {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; color: var(--text-5); line-height: 1.55;
}

/* Ações: só ícones, sempre numa única linha. O rótulo vira tooltip no hover. */
.card-actions {
  display: flex; align-items: center; gap: 6px; flex-wrap: nowrap;
  margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border);
}

.icon-btn {
  position: relative; flex: none;
  width: 34px; height: 34px; border-radius: 9px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--chip); color: var(--text-2);
  border: 1px solid transparent; cursor: pointer; padding: 0;
}
.icon-btn:hover { background: var(--badge-bg); color: var(--brand); }
.icon-btn:focus-visible { outline: none; border-color: var(--brand); background: var(--badge-bg); color: var(--brand); }
.icon-btn--danger:hover { background: var(--danger-bg); color: var(--danger); }
.icon-btn--danger:focus-visible { border-color: var(--danger); background: var(--danger-bg); color: var(--danger); }

/* Balão do rótulo — o title nativo fica só como fallback de acessibilidade. */
.icon-btn::after {
  content: attr(data-label);
  position: absolute; bottom: calc(100% + 7px); left: 50%;
  transform: translateX(-50%);
  background: var(--dark); color: #fff;
  padding: 6px 10px; border-radius: 8px;
  font-size: 12px; font-weight: 600; line-height: 1.2;
  white-space: nowrap; letter-spacing: 0;
  box-shadow: 0 8px 18px rgba(20, 21, 43, .22);
  opacity: 0; visibility: hidden; pointer-events: none; z-index: 5;
}
.icon-btn:hover::after,
.icon-btn:focus-visible::after { opacity: 1; visibility: visible; }

/* Nas pontas o balão encosta na borda do card em vez de vazar para fora. */
.card-actions .icon-btn:first-child::after { left: 0; transform: none; }
.card-actions .icon-btn:last-child::after { left: auto; right: 0; transform: none; }

/* ── Estado vazio ────────────────────────────────────────────────────── */
.empty {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-card); box-shadow: var(--shadow-card);
  padding: clamp(40px, 7vw, 72px) 28px; text-align: center;
}
.empty-icon {
  width: 54px; height: 54px; border-radius: 15px; margin: 0 auto 20px;
  background: var(--tile); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
}
.empty-title { font-size: 21px; font-weight: 700; letter-spacing: -.01em; margin: 0 0 8px; }
.empty-text { font-size: 14.5px; color: var(--text-4); line-height: 1.6; margin: 0; }

/* ── Modais ──────────────────────────────────────────────────────────── */
.modal-host {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; background: rgba(20, 21, 43, .45);
  backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
  overflow-y: auto;
}

.modal {
  position: relative; width: 100%; max-width: 520px; margin: auto;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-panel); box-shadow: var(--shadow-emph);
  padding: clamp(24px, 3vw, 32px);
}
.modal--wide { max-width: 640px; }

.modal-head { margin-bottom: 22px; padding-right: 34px; }
.modal-title { font-size: 21px; font-weight: 700; letter-spacing: -.01em; margin: 12px 0 0; }
.modal-sub { font-size: 14px; color: var(--text-4); line-height: 1.6; margin: 7px 0 0; }

.modal-close {
  position: absolute; top: 20px; right: 20px;
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--chip); border: none; color: var(--text-4);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.modal-close:hover { background: var(--badge-bg); color: var(--brand); }

.modal-actions {
  display: flex; gap: 10px; justify-content: flex-end;
  margin-top: 24px; flex-wrap: wrap;
}
.modal-actions .btn { min-width: 108px; }

.callout {
  display: flex; align-items: flex-start; gap: 11px;
  background: #f6f2ff; border: 1.5px solid var(--border-accent);
  border-radius: 14px; padding: 13px 16px;
  font-size: 13px; color: var(--text-2); line-height: 1.55;
}
.callout svg { color: var(--brand); flex: none; margin-top: 1px; }
.callout code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12.5px; color: var(--brand); word-break: break-all;
}

/* Abas HTML: upload x colar */
.tabs { display: flex; gap: 6px; background: var(--chip); padding: 4px; border-radius: 11px; margin-bottom: 14px; }
.tab {
  flex: 1; font-family: inherit; font-size: 13px; font-weight: 600;
  padding: 9px 12px; border-radius: 8px; border: none;
  background: transparent; color: var(--text-4); cursor: pointer;
}
.tab:hover { color: var(--brand); }
.tab.is-active { background: var(--surface); color: var(--brand); box-shadow: 0 1px 2px rgba(20, 21, 43, .06); }

/* Zona de upload */
.drop {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px;
  min-height: 150px; padding: 26px 20px; text-align: center;
  background: var(--surface-soft); border: 1.5px dashed var(--border-accent);
  border-radius: var(--r-sm); cursor: pointer;
}
.drop:hover, .drop.is-over { background: var(--evidence); border-color: var(--brand); }
.drop-icon {
  width: 44px; height: 44px; border-radius: 12px;
  background: var(--tile); color: var(--brand);
  display: flex; align-items: center; justify-content: center;
}
.drop-title { font-size: 14px; font-weight: 600; color: var(--text-1); }
.drop-text { font-size: 12.5px; color: var(--text-5); line-height: 1.5; margin: 0; }
.drop.has-file { border-style: solid; border-color: var(--brand); background: var(--evidence); }

/* ── Editor de HTML ──────────────────────────────────────────────────── */
.editor-modal {
  width: 100%; max-width: 1180px; height: 100%; max-height: calc(100vh - 48px);
  margin: auto; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--r-panel); box-shadow: var(--shadow-emph); overflow: hidden;
}

.editor-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 16px 22px; border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.editor-title { font-size: 16px; font-weight: 700; margin: 0; letter-spacing: -.01em; }
.editor-path { font-size: 12.5px; color: var(--text-5); margin: 3px 0 0; font-family: ui-monospace, Menlo, monospace; }
.editor-actions { display: flex; gap: 9px; align-items: center; }

/* Área de código: painel escuro do Design System (#14152b). */
.ed {
  flex: 1; display: flex; overflow: auto; min-height: 0;
  /* flex-start: as colunas crescem com o código, e não com a altura da janela —
     é o que mantém a textarea do tamanho do conteúdo (sem rolagem interna). */
  align-items: flex-start;
  background: var(--dark); font: 13px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  tab-size: 2;
}

.ed-gutter {
  position: sticky; left: 0; z-index: 2; flex: none;
  min-height: 100%;
  padding: 16px 12px 16px 18px; text-align: right;
  background: var(--dark); color: #4e4a72;
  border-right: 1px solid rgba(255, 255, 255, .07);
  user-select: none; white-space: pre;
  font: inherit;
}

.ed-body { position: relative; flex: 1; min-width: 0; min-height: 100%; }

.ed-body pre,
.ed-body textarea {
  margin: 0; padding: 16px 22px;
  font: inherit; letter-spacing: normal;
  white-space: pre; word-spacing: normal; word-break: normal;
  border: 0; min-width: 100%; box-sizing: border-box;
}

.ed-body pre { color: #d9d7ea; pointer-events: none; overflow: visible; }

.ed-body textarea {
  position: absolute; inset: 0; width: 100%;
  background: transparent; color: transparent; caret-color: #fff;
  resize: none; overflow: hidden; outline: none; display: block;
}
.ed-body textarea::selection { background: rgba(80, 5, 242, .45); color: transparent; }

/* Coloração de sintaxe (paleta do bloco escuro do DS) */
.t-tag { color: #a89cf0; }
.t-attr { color: #b9b6cf; }
.t-str { color: #7ee0c0; }
.t-punct { color: #6f6a94; }
.t-cmt { color: #6f6a94; font-style: italic; }
.t-doc { color: #6f6a94; }

/* ── Toasts ──────────────────────────────────────────────────────────── */
.toasts {
  position: fixed; right: 24px; bottom: 24px; z-index: 200;
  display: flex; flex-direction: column; gap: 10px;
  align-items: flex-end; pointer-events: none;
}

.toast {
  display: flex; align-items: flex-start; gap: 10px;
  max-width: 380px; padding: 13px 17px;
  background: var(--dark); color: #fff;
  border-radius: 14px; box-shadow: var(--shadow-emph);
  font-size: 13.5px; font-weight: 500; line-height: 1.5;
}
.toast svg { flex: none; margin-top: 1px; }
.toast--ok svg { color: #6ee7a8; }
.toast--err { background: #4a1418; }
.toast--err svg { color: #ff8a80; }

/* ── Carregando ──────────────────────────────────────────────────────── */
.spinner {
  width: 15px; height: 15px; border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, .35); border-top-color: #fff;
  animation: spin .7s linear infinite;
}
.btn-secondary .spinner { border-color: rgba(80, 5, 242, .25); border-top-color: var(--brand); }
@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* ── Responsivo (desktop primeiro) ───────────────────────────────────── */
@media (max-width: 900px) {
  .grid { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
}

@media (max-width: 720px) {
  .container { padding: 24px 18px 64px; }
  .topbar-inner { padding: 13px 18px; }
  .brand-text { display: none; }
  .badge { display: none; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar .btn { width: 100%; }
  .grid { grid-template-columns: 1fr; }
  .modal-host { padding: 14px; }
  .modal { padding: 22px; }
  .modal-actions { flex-direction: column-reverse; }
  .modal-actions .btn { width: 100%; }
  .editor-modal { max-height: calc(100vh - 28px); }
  .editor-head { padding: 14px 16px; }
  .editor-actions { width: 100%; }
  .editor-actions .btn { flex: 1; }
  .slug-prefix { display: none; }
  .slug-field .input { border-radius: var(--r-btn); }
  .toasts { left: 14px; right: 14px; bottom: 14px; align-items: stretch; }
  .toast { max-width: none; }
}
