/* tr3vo-studio — Author App — Mobile-first, AA contrast */
:root {
  --bg: #FAFAF8;
  --surface: #FFFFFF;
  --border: #E8E4DE;
  --text: #1A1A1A;
  --text-muted: #6B6460;
  --accent: #A66B30;
  --accent-light: #F5EDE3;
  --accent-hover: #8A5525;
  --success: #2D7D5C;
  --success-bg: #EBF7F2;
  --error: #B83228;
  --error-bg: #FDF0EF;
  --warning-bg: #FEF9EC;
  --r: 8px;
  --r-lg: 14px;
  --shadow: 0 1px 4px rgba(0,0,0,.07), 0 4px 16px rgba(0,0,0,.05);
  --max-w: 680px;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; -webkit-text-size-adjust: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  min-height: 100dvh;
}

/* ── Foco visível (acessibilidade) ── */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Layout base ── */
.container {
  max-width: var(--max-w);
  margin: 0 auto;
  padding: 0 16px;
}

/* ── Topbar ── */
.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar-logo { font-size: 1.25rem; font-weight: 700; color: var(--accent); letter-spacing: -0.5px; }
.topbar-user { font-size: .85rem; color: var(--text-muted); display: flex; align-items: center; gap: 12px; }
.btn-ghost { background: none; border: none; cursor: pointer; color: var(--text-muted); font-size: .85rem; padding: 4px 8px; border-radius: 4px; }
.btn-ghost:hover { color: var(--text); background: var(--bg); }

/* ── Botões ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--r);
  font-size: .95rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: background .15s, opacity .15s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover:not(:disabled) { background: #236650; }
.btn-sm { padding: 6px 14px; font-size: .85rem; }
.btn-full { width: 100%; }

/* ── Formulários ── */
.field { margin-bottom: 16px; }
.field label { display: block; font-size: .875rem; font-weight: 500; margin-bottom: 6px; color: var(--text); }
.field input, .field textarea, .field select {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  font-size: 1rem;
  background: var(--surface);
  color: var(--text);
  transition: border-color .15s;
  font-family: inherit;
}
.field input:focus, .field textarea:focus, .field select:focus { border-color: var(--accent); outline: none; }
.field textarea { resize: vertical; min-height: 80px; }
.error-msg { color: var(--error); font-size: .85rem; margin-top: 8px; }
.success-msg { color: var(--success); font-size: .85rem; margin-top: 8px; }

/* ── Cards ── */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: 20px;
  margin-bottom: 16px;
}
.card-header { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 12px; }
.card-title { font-size: 1rem; font-weight: 600; }
.card-meta { font-size: .8rem; color: var(--text-muted); margin-top: 4px; }

/* ── Badges de status ── */
.badge {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: uppercase;
}
.badge-active    { background: var(--accent-light); color: var(--accent-hover); }
.badge-pending   { background: var(--warning-bg); color: #7A5B00; }
.badge-complete  { background: var(--success-bg); color: var(--success); }
.badge-new       { background: #EEF2FF; color: #3730A3; }

/* ── Progress bar ── */
.progress-bar-wrap {
  background: var(--bg);
  border-radius: 99px;
  height: 8px;
  overflow: hidden;
  margin: 8px 0;
}
.progress-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width .4s ease;
}
.progress-label { font-size: .8rem; color: var(--text-muted); }

/* ── Chat (interview) ── */
.chat-wrap { display: flex; flex-direction: column; gap: 16px; padding: 20px 16px; }
.chat-msg { max-width: 85%; }
.chat-msg.system { align-self: flex-start; }
.chat-msg.author { align-self: flex-end; }
.chat-bubble {
  padding: 12px 16px;
  border-radius: var(--r-lg);
  line-height: 1.55;
  font-size: .95rem;
}
.chat-msg.system .chat-bubble {
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}
.chat-msg.author .chat-bubble {
  background: var(--accent-light);
  border-bottom-right-radius: 4px;
}
.chat-sender { font-size: .75rem; color: var(--text-muted); margin-bottom: 4px; font-weight: 500; }
.chat-msg.author .chat-sender { text-align: right; }

/* ── Seção transformada ── */
.transformed-card {
  background: var(--surface);
  border: 1.5px solid var(--accent);
  border-radius: var(--r-lg);
  overflow: hidden;
  margin: 8px 0 4px;
}
.transformed-header {
  background: var(--accent-light);
  padding: 10px 16px;
  font-size: .8rem;
  font-weight: 600;
  color: var(--accent-hover);
  display: flex;
  align-items: center;
  gap: 6px;
}
.transformed-body { padding: 16px; font-size: .95rem; line-height: 1.65; white-space: pre-wrap; }
.transformed-actions {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  background: var(--bg);
}
.revise-input-wrap { padding: 12px 16px; border-top: 1px solid var(--border); }
.revise-input-wrap textarea { font-size: .9rem; }

/* ── Input de resposta fixo no bottom ── */
.answer-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  z-index: 10;
}
.answer-bar-inner {
  max-width: var(--max-w);
  margin: 0 auto;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.answer-bar textarea {
  flex: 1;
  resize: none;
  border: 1.5px solid var(--border);
  border-radius: var(--r);
  padding: 10px 14px;
  font-size: .95rem;
  font-family: inherit;
  line-height: 1.5;
  max-height: 160px;
  min-height: 44px;
}
.answer-bar textarea:focus { border-color: var(--accent); outline: none; }

/* ── Loading spinner ── */
.spinner {
  width: 20px; height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-msg { display: flex; align-items: center; gap: 10px; color: var(--text-muted); font-size: .9rem; font-style: italic; }

/* ── Page sections ── */
.page { padding: 24px 0 120px; }
.page-header { padding: 20px 16px 0; }
.page-title { font-size: 1.5rem; font-weight: 700; letter-spacing: -.5px; }
.page-sub { color: var(--text-muted); font-size: .9rem; margin-top: 4px; }
.section-label { font-size: .75rem; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--text-muted); margin: 24px 16px 8px; }

/* ── Auth overlay ── */
#auth-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
}
.overlay-backdrop { position: absolute; inset: 0; background: rgba(26,26,26,.6); backdrop-filter: blur(4px); }
.overlay-card {
  position: relative;
  background: var(--surface);
  border-radius: var(--r-lg);
  padding: 32px 28px;
  width: min(400px, calc(100vw - 32px));
  box-shadow: var(--shadow);
}
.overlay-logo { font-size: 1.75rem; font-weight: 800; color: var(--accent); text-align: center; letter-spacing: -1px; margin-bottom: 4px; }
.overlay-sub { text-align: center; color: var(--text-muted); font-size: .875rem; margin-bottom: 24px; }
.overlay-msg { background: var(--warning-bg); border-radius: var(--r); padding: 10px 14px; font-size: .875rem; color: #7A5B00; margin-bottom: 16px; }
.overlay-hint { text-align: center; font-size: .75rem; color: var(--text-muted); margin-top: 16px; }

/* ── Modal ── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 100; display: flex; align-items: flex-end; justify-content: center; }
.modal-sheet {
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 24px 20px;
  width: 100%;
  max-width: var(--max-w);
  max-height: 90dvh;
  overflow-y: auto;
}
.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 16px; }
.modal-close { float: right; font-size: 1.25rem; background: none; border: none; cursor: pointer; line-height: 1; }

/* ── Approval page ── */
.approval-pair {
  display: grid;
  gap: 12px;
  margin-bottom: 20px;
}
@media (min-width: 600px) {
  .approval-pair { grid-template-columns: 1fr 1fr; }
}
.approval-col { }
.approval-col-label { font-size: .75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 6px; }
.approval-col-content {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--r);
  padding: 14px;
  font-size: .9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  min-height: 80px;
}
.approval-col-content.transformed { border-color: var(--accent); background: var(--accent-light); }

/* ── Progress/status page ── */
.status-icon { font-size: 3rem; text-align: center; margin-bottom: 16px; }
.status-stage { font-size: 1.1rem; font-weight: 600; text-align: center; }
.status-hint { text-align: center; color: var(--text-muted); font-size: .875rem; margin-top: 8px; }
.status-steps { list-style: none; margin: 24px 0; }
.status-steps li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.status-steps li:last-child { border-bottom: none; }
.step-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.step-dot.done { background: var(--success); }
.step-dot.active { background: var(--accent); animation: pulse 1.5s ease-in-out infinite; }
.step-dot.pending { background: var(--border); }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.4} }

/* ── Utilities ── */
.mt-4 { margin-top: 4px; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.text-center { text-align: center; }
.text-muted { color: var(--text-muted); }
.text-sm { font-size: .85rem; }
.hidden { display: none !important; }
.flex { display: flex; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
