/* ── Tokens ─────────────────────────────────────────────────────────────── */
:root {
  --bg:        #F7F7F7;
  --surface:   #FFFFFF;
  --border:    #E4E4E7;
  --text:      #18181B;
  --muted:     #71717A;
  --accent:    #2563EB;
  --accent-h:  #1D4ED8;
  --danger:    #DC2626;
  --radius:    6px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: var(--font); font-size: 14px; color: var(--text); background: var(--bg); line-height: 1.5; -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
button { font-family: var(--font); }

/* ── Topbar ─────────────────────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.topbar__inner {
  max-width: 960px; margin: 0 auto;
  padding: 0 24px; height: 52px;
  display: flex; align-items: center;
}
.topbar__brand { font-size: 15px; font-weight: 600; letter-spacing: -0.015em; }

/* ── Home layout ────────────────────────────────────────────────────────── */
.home {
  max-width: 960px; margin: 0 auto;
  padding: 32px 24px;
  display: flex; flex-direction: column; gap: 20px;
}

/* ── Card ───────────────────────────────────────────────────────────────── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
}
.card__eyebrow {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--muted); margin-bottom: 18px;
}

/* ── Selector row ───────────────────────────────────────────────────────── */
.selector-row {
  display: flex; align-items: flex-end; gap: 12px;
}
.field-group { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.field-label {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted);
}

/* ── Controls ───────────────────────────────────────────────────────────── */
.select, .input, .textarea {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px;
  font-size: 13px; color: var(--text);
  font-family: var(--font);
  outline: none;
  transition: border-color 0.12s;
}
.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2371717A' d='M6 8.5L1.5 3.5h9z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
}
.select:focus, .input:focus, .textarea:focus {
  border-color: var(--accent);
  background: var(--surface);
}
.textarea { resize: vertical; min-height: 84px; }

/* ── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius);
  font-size: 13px; font-weight: 500;
  border: 1px solid transparent; cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
  white-space: nowrap; line-height: 1;
}
.btn--primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn--primary:hover { background: var(--accent-h); border-color: var(--accent-h); }
.btn--primary:disabled { opacity: 0.55; cursor: not-allowed; }
.btn--ghost { background: transparent; color: var(--muted); border-color: var(--border); }
.btn--ghost:hover { color: var(--text); border-color: #C4C4C7; }
.btn--ghost.btn--danger { color: var(--danger); }
.btn--ghost.btn--danger:hover { background: #FEF2F2; border-color: #FECACA; }
.btn--sm { padding: 5px 10px; font-size: 12px; }
.btn--block { width: 100%; padding: 10px 16px; font-size: 14px; }

/* ── Table ──────────────────────────────────────────────────────────────── */
.table { width: 100%; border-collapse: collapse; }
.table th {
  font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--muted);
  padding: 0 12px 10px 0;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 11px 12px 11px 0;
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  vertical-align: middle;
}
.table tbody tr:last-child td { border-bottom: none; }
.proposal-link { color: var(--text); font-weight: 500; }
.proposal-link:hover { color: var(--accent); }
.cell-muted { color: var(--muted); }
.cell-actions { text-align: right; }
.cell-actions { display: flex; gap: 6px; justify-content: flex-end; }
.empty-state { color: var(--muted); font-size: 13px; padding: 4px 0; }

/* ── Toast ──────────────────────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(6px);
  background: var(--text); color: #fff;
  padding: 9px 18px; border-radius: var(--radius);
  font-size: 13px; opacity: 0; pointer-events: none;
  transition: opacity 0.18s, transform 0.18s; z-index: 100;
}
.toast--show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Editor page ────────────────────────────────────────────────────────── */
.editor-page { overflow: hidden; height: 100vh; }

.editor {
  display: flex; height: 100vh; overflow: hidden;
}

/* ── Sidebar ────────────────────────────────────────────────────────────── */
.sidebar {
  width: 360px; flex-shrink: 0;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  height: 100vh; overflow: hidden;
}

.sidebar__header {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
  flex-shrink: 0;
}
.back-link { font-size: 13px; color: var(--muted); }
.back-link:hover { color: var(--text); }
.sidebar__title { font-size: 13px; font-weight: 600; color: var(--text); }

.sidebar__form { display: flex; flex-direction: column; flex: 1; overflow: hidden; }

.form-fields {
  flex: 1; overflow-y: auto; padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
}

.form-field { display: flex; flex-direction: column; gap: 6px; }

.sidebar__footer {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

/* ── Upload ─────────────────────────────────────────────────────────────── */
.upload-input { position: absolute; opacity: 0; width: 0; height: 0; }
.upload-wrap { display: flex; flex-direction: column; gap: 4px; }
.upload-label {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 12px;
  border: 1px dashed var(--border); border-radius: var(--radius);
  cursor: pointer; background: var(--bg);
  font-size: 13px; color: var(--muted);
  transition: border-color 0.12s, color 0.12s;
  width: fit-content;
}
.upload-label:hover { border-color: var(--accent); color: var(--accent); }
.upload-label__text { line-height: 1; }
.upload-filename { font-size: 11px; color: var(--muted); padding-left: 2px; }

/* ── Preview pane ───────────────────────────────────────────────────────── */
.preview-pane {
  flex: 1; display: flex; flex-direction: column;
  background: #EBEBEB; overflow: hidden;
}

.preview-chrome {
  height: 36px; flex-shrink: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
  padding: 0 16px;
}
.preview-chrome__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--border);
  transition: background 0.3s;
  flex-shrink: 0;
}
.preview-chrome__dot.active { background: var(--accent); }
.preview-chrome__label { font-size: 11px; color: var(--muted); letter-spacing: 0.03em; }

.preview-frame {
  flex: 1; width: 100%; border: none;
  background: var(--surface);
}

/* ── Scrollbar (sidebar form area) ─────────────────────────────────────── */
.form-fields::-webkit-scrollbar { width: 4px; }
.form-fields::-webkit-scrollbar-track { background: transparent; }
.form-fields::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

/* ── Responsive (minimal — editor collapses preview on narrow) ──────────── */
@media (max-width: 720px) {
  .editor { flex-direction: column; }
  .sidebar { width: 100%; height: auto; border-right: none; border-bottom: 1px solid var(--border); }
  .preview-pane { min-height: 300px; }
}

/* ── Home — tema escuro ────────────────────────────────────────────────── */
body.home-page {
  --bg:        #0B0B10;
  --surface:   #16161D;
  --border:    #2A2A33;
  --text:      #F4F4F5;
  --muted:     #8E8E99;
  --accent:    #3B82F6;
  --accent-h:  #2563EB;
  --danger:    #F87171;
  background: radial-gradient(ellipse 900px 600px at 100% 100%, #1B1B26 0%, var(--bg) 60%);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

body.home-page::after {
  content: "";
  position: fixed;
  right: 32px;
  bottom: 28px;
  width: 64px;
  height: 64px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%23ffffff' fill-opacity='0.22' d='M12 1.5l2.1 7.4L21.5 11l-7.4 2.1L12 20.5l-2.1-7.4L2.5 11l7.4-2.1z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: contain;
  pointer-events: none;
  z-index: 0;
}

body.home-page .topbar {
  background: transparent;
  border-bottom: none;
  position: relative; z-index: 1;
}
body.home-page .topbar__brand {
  font-size: 19px; font-weight: 700; letter-spacing: -0.02em;
}

body.home-page .home {
  position: relative; z-index: 1;
}

body.home-page .card {
  background: var(--surface);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.03) inset, 0 12px 28px rgba(0, 0, 0, 0.35);
  border-radius: 10px;
}

body.home-page .table tbody tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

body.home-page .btn--primary {
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.4), 0 4px 14px rgba(59, 130, 246, 0.35);
}

body.home-page .btn--ghost.btn--danger:hover {
  background: rgba(248, 113, 113, 0.1);
  border-color: rgba(248, 113, 113, 0.35);
}

body.home-page .toast {
  background: #EDEDF0;
  color: #18181B;
}

/* ── Editor — sidebar em tema escuro ──────────────────────────────────── */
.editor-page .sidebar {
  --bg:        #0B0B10;
  --surface:   #16161D;
  --border:    #2A2A33;
  --text:      #F4F4F5;
  --muted:     #8E8E99;
  --accent:    #3B82F6;
  --accent-h:  #2563EB;
  box-shadow: 0 0 28px rgba(0, 0, 0, 0.25);
}

.editor-page .sidebar .btn--primary {
  box-shadow: 0 0 0 1px rgba(59, 130, 246, 0.4), 0 4px 14px rgba(59, 130, 246, 0.35);
}

.editor-page .sidebar .form-fields::-webkit-scrollbar-thumb {
  background: #3A3A45;
}
