/* ============================================
   Proposta IA — Styles
   Dark Premium Theme (Gênesis IA)
   ============================================ */

:root {
  /* Surfaces */
  --bg: #0a0a0f;
  --bg-elev: #13161f;
  --bg-card: rgba(255,255,255,.05);
  --border: rgba(255,255,255,.10);
  --border-hover: rgba(167,139,250,.4);

  /* Text */
  --text: #e8e8ec;
  --text-muted: #9ca3af;
  --text-dim: #7d8592;

  /* Accents */
  --accent-purple: #a78bfa;
  --accent-pink: #f472b6;
  --accent-amber: #fbbf24;
  --accent-orange: #d97706;

  /* Status */
  --good: #10b981;
  --mid: #eab308;
  --low: #ef4444;

  /* Spacing */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;

  /* Radius */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
}

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

html {
  scroll-behavior: smooth;
  -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: 100vh;
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
}

.bg-gradient {
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse at top, #1a1030 0%, #0a0a0f 55%),
    radial-gradient(ellipse at bottom right, #0c2030 0%, transparent 60%);
}

/* Screens */
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }

/* ============================================
   MEMBERSHIP GATE
   ============================================ */
#gate-screen {
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

.gate-container {
  width: 100%;
  max-width: 420px;
  text-align: center;
}

.gate-header { margin-bottom: var(--space-2xl); }

.gradient-text {
  font-size: clamp(28px, 5vw, 42px);
  font-weight: 800;
  letter-spacing: -.02em;
  background: linear-gradient(135deg, #fff 0%, var(--accent-purple) 50%, var(--accent-pink) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
  margin-bottom: var(--space-md);
}

.subtitle {
  color: var(--text-muted);
  font-size: 15px;
  line-height: 1.55;
  margin-bottom: var(--space-md);
}

.community-badge {
  display: inline-block;
  background: rgba(167,139,250,.12);
  color: var(--accent-purple);
  padding: 6px 16px;
  border-radius: 100px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid rgba(167,139,250,.2);
}

/* Gate Form */
.gate-form {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  text-align: left;
  margin-bottom: var(--space-lg);
}

.form-group { margin-bottom: var(--space-lg); }

.form-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-sm);
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.form-group input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(167,139,250,.2);
}

.form-group input::placeholder { color: var(--text-dim); }

/* Buttons */
.btn-primary {
  width: 100%;
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  color: #fff;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: filter .2s, transform .1s;
  min-height: 48px;
}

.btn-primary:hover { filter: brightness(1.1); transform: scale(1.02); }
.btn-primary:active { transform: scale(.98); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; transform: none; filter: none; }

.btn-secondary {
  width: 100%;
  padding: 14px 24px;
  background: var(--bg-elev);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .2s;
  min-height: 48px;
}

.btn-secondary:hover { border-color: var(--border-hover); }

.btn-danger {
  width: 100%;
  padding: 12px 24px;
  background: rgba(239,68,68,.1);
  color: var(--low);
  border: 1px solid rgba(239,68,68,.2);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  min-height: 44px;
}

.btn-danger:hover { background: rgba(239,68,68,.2); }

.btn-icon {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  transition: border-color .2s, color .2s;
}

.btn-icon:hover { border-color: var(--border-hover); color: var(--text); }

.error-message {
  color: var(--low);
  font-size: 14px;
  margin-top: var(--space-md);
  text-align: center;
}

.gate-footer {
  color: var(--text-dim);
  font-size: 13px;
}

.gate-footer a {
  color: var(--accent-purple);
  text-decoration: none;
}

.gate-footer a:hover { text-decoration: underline; }

/* ============================================
   API KEY SETUP SCREEN
   ============================================ */
#key-screen {
  align-items: center;
  justify-content: center;
  padding: var(--space-lg);
}

.key-container {
  width: 100%;
  max-width: 520px;
}

.key-container h2 {
  font-size: clamp(22px, 4vw, 28px);
  font-weight: 700;
  letter-spacing: -.01em;
  line-height: 1.25;
  margin-bottom: var(--space-sm);
}

.key-inputs {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin: var(--space-xl) 0;
}

.key-input-group {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.key-input-group label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  margin-bottom: var(--space-sm);
}

.key-input-wrapper {
  position: relative;
  display: flex;
  gap: var(--space-sm);
}

.key-input-wrapper input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 14px;
  font-family: monospace;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.key-input-wrapper input:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(167,139,250,.2);
}

.key-toggle {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  padding: 0 12px;
  cursor: pointer;
  font-size: 13px;
  min-width: 44px;
}

.key-status {
  font-size: 12px;
  margin-top: var(--space-xs);
  color: var(--text-dim);
}

.key-status.saved { color: var(--good); }

.key-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
}

.key-info {
  margin-top: var(--space-xl);
  color: var(--text-muted);
  font-size: 14px;
}

.key-info summary {
  cursor: pointer;
  color: var(--accent-purple);
  font-weight: 500;
}

.key-info-content {
  margin-top: var(--space-md);
  padding: var(--space-lg);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
}

.key-info-content p { margin-bottom: var(--space-sm); }
.key-info-content code {
  background: var(--bg-elev);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
}

.key-info-note {
  margin-top: var(--space-md);
  font-size: 13px;
  color: var(--text-dim);
}

/* ============================================
   APP SCREEN
   ============================================ */
#app-screen { min-height: 100vh; }

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-xl);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: rgba(10,10,15,.9);
  backdrop-filter: blur(12px);
  z-index: 100;
}

.app-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -.01em;
  background: linear-gradient(135deg, #fff, var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-right { display: flex; gap: var(--space-sm); }

.app-main {
  flex: 1;
  padding: var(--space-xl);
  max-width: 1000px;
  margin: 0 auto;
  width: 100%;
}

.app-footer {
  text-align: center;
  padding: var(--space-xl);
  color: var(--text-dim);
  font-size: 13px;
  border-top: 1px solid var(--border);
}

.footer-links { margin-top: 8px; }
.footer-links a { color: var(--text-dim); text-decoration: none; font-size: 12px; }
.footer-links a:hover { color: var(--accent-purple); text-decoration: underline; }
.footer-sep { margin: 0 8px; color: var(--text-dim); opacity: .4; }

/* ============================================
   MODAL
   ============================================ */
.modal { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; }
.modal-overlay { position: absolute; inset: 0; background: rgba(0,0,0,.7); backdrop-filter: blur(4px); }
.modal-content {
  position: relative;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  width: 90%;
  max-width: 480px;
  max-height: 80vh;
  overflow-y: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--space-lg);
}

.modal-header h3 { font-size: 18px; font-weight: 700; letter-spacing: -.01em; }

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  margin-top: var(--space-lg);
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.screen.active { animation: fadeIn .4s ease-out; }

/* ============================================
   PROPOSTA IA — TOOL UI
   ============================================ */
.intro-block { margin-bottom: var(--space-xl); }

.intro-title {
  font-size: clamp(20px, 3vw, 26px);
  font-weight: 700;
  letter-spacing: -.01em;
  margin-bottom: var(--space-sm);
}
.intro-title span { color: var(--accent-purple); }

.intro-sub {
  color: var(--text-muted);
  font-size: 15px;
  max-width: 680px;
}

/* Builder layout */
.builder-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr);
  gap: var(--space-lg);
  align-items: start;
}

.panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  animation: fadeIn .5s ease-out backwards;
}

.output-panel { position: sticky; top: 84px; }

.panel-title {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: -.005em;
  margin-bottom: var(--space-lg);
}

.panel-num {
  width: 26px;
  height: 26px;
  flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-purple), var(--accent-pink));
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Fields */
.field { margin-bottom: var(--space-lg); }

.field label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: var(--space-sm);
}

.field .req { color: var(--accent-pink); }
.field .opt { color: var(--text-dim); font-weight: 500; font-size: 12px; }

.field textarea,
.field input[type="text"],
.field select {
  width: 100%;
  padding: 12px 14px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  font-size: 16px;
  font-family: inherit;
  font-variant-numeric: tabular-nums;
  outline: none;
  transition: border-color .2s, box-shadow .2s;
}

.field textarea {
  resize: vertical;
  min-height: 92px;
  line-height: 1.6;
}

.field textarea:focus,
.field input[type="text"]:focus,
.field select:focus {
  border-color: var(--accent-purple);
  box-shadow: 0 0 0 3px rgba(167,139,250,.18);
}

.field textarea::placeholder,
.field input::placeholder { color: var(--text-dim); }

.field select {
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'><polyline points='6 9 12 15 18 9'/></svg>");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 38px;
}

.field-hint {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 6px;
}

.field-hint-tight {
  margin-top: -6px;
  margin-bottom: var(--space-lg);
}

.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}
.field-row .field { margin-bottom: var(--space-lg); }

.warn-message {
  margin-top: var(--space-md);
  font-size: 14px;
  color: var(--accent-amber);
  text-align: center;
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent-purple);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
}

#generate-btn { margin-top: var(--space-xs); }

/* Output panel */
.output-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm) var(--space-md);
  margin-bottom: var(--space-lg);
  flex-wrap: wrap;
}
.output-head .panel-title { margin-bottom: 0; white-space: nowrap; }

.output-actions { display: flex; gap: var(--space-sm); flex-wrap: wrap; }

.btn-mini {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 7px 12px;
  font-size: 13px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: border-color .2s, color .2s, background .2s;
}
.btn-mini:hover { border-color: var(--border-hover); color: var(--text); }
.btn-mini-ok { color: var(--good) !important; border-color: rgba(16,185,129,.4) !important; }

/* Output states */
.output-empty,
.output-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: var(--space-2xl) var(--space-lg);
  min-height: 340px;
  color: var(--text-dim);
}
.output-empty { display: flex; }
.output-empty svg { color: var(--accent-purple); opacity: .55; margin-bottom: var(--space-md); }
.output-empty p,
.output-loading p {
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 6px;
}
.output-empty span,
.output-loading span { font-size: 13px; color: var(--text-dim); }

.spinner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid rgba(167,139,250,.2);
  border-top-color: var(--accent-purple);
  animation: spin .8s linear infinite;
  margin-bottom: var(--space-md);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* Proposal document */
.proposal-doc {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-xl);
}

.pd-title {
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -.01em;
  line-height: 1.3;
  color: var(--text);
  margin-bottom: var(--space-xs);
}

.pd-parties {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: var(--space-lg);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid var(--border);
}
.pd-parties strong { color: var(--accent-pink); font-weight: 600; }

.pd-section { margin-bottom: var(--space-lg); }
.pd-section:last-child { margin-bottom: 0; }

.pd-h {
  font-size: 13px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent-purple);
  margin-bottom: var(--space-sm);
}

.pd-text {
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.75;
  margin-bottom: var(--space-sm);
}
.pd-text:last-child { margin-bottom: 0; }
.pd-mark {
  background: rgba(251,191,36,.16);
  border: 1px solid rgba(251,191,36,.32);
  color: var(--accent-amber);
  padding: 1px 7px;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
}

.pd-list { margin: 0; padding-left: 20px; }
.pd-list li {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.65;
  margin-bottom: 6px;
}
.pd-list li:last-child { margin-bottom: 0; }

/* Stages / timeline */
.pd-step {
  position: relative;
  padding: var(--space-md) 0 var(--space-md) var(--space-lg);
  border-left: 2px solid rgba(167,139,250,.28);
}
.pd-step:last-child { padding-bottom: 0; }
.pd-step::before {
  content: "";
  position: absolute;
  left: -6px;
  top: 20px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--accent-purple);
}
.pd-step-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: var(--space-md);
  flex-wrap: wrap;
}
.pd-step-name { font-size: 14.5px; font-weight: 700; color: var(--text); }
.pd-step-when { font-size: 12.5px; color: var(--text-dim); white-space: nowrap; }
.pd-step-desc { font-size: 13.5px; color: var(--text-muted); margin-top: 3px; line-height: 1.6; }

/* Investment box */
.pd-invest {
  background: rgba(167,139,250,.08);
  border: 1px solid rgba(167,139,250,.22);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
}
.pd-invest .pd-h { margin-bottom: var(--space-sm); }
.pd-invest .pd-text { color: var(--text); }

.pd-meta-row {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 14px;
  color: var(--text-muted);
}
.pd-meta-row strong { color: var(--text); font-weight: 600; }

/* Tips block */
.tips-block {
  margin-top: var(--space-lg);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
}

.block-h {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  font-size: 14px;
  font-weight: 700;
  margin-bottom: var(--space-sm);
}

.block-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-tip { background: var(--good); }

.block-desc {
  font-size: 13px;
  color: var(--text-dim);
  margin-bottom: var(--space-md);
}

.tips-list { margin: 0; padding-left: 20px; }
.tips-list li {
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.65;
  margin-bottom: var(--space-sm);
}
.tips-list li:last-child { margin-bottom: 0; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
  .builder-grid { grid-template-columns: 1fr; gap: var(--space-md); }
  .output-panel { position: static; }
}

@media (max-width: 768px) {
  .app-main { padding: var(--space-md); }
  .app-header { padding: var(--space-md); }
  .gate-form { padding: var(--space-lg); }
  .intro-block { margin-bottom: var(--space-lg); }
  .modal-content { padding: var(--space-lg); }
}

@media (max-width: 480px) {
  .panel { padding: var(--space-lg); }
  .field-row { grid-template-columns: 1fr; gap: 0; }
  .proposal-doc { padding: var(--space-lg); }
  .output-head { flex-direction: column; align-items: flex-start; }
  .output-empty, .output-loading { min-height: 260px; padding: var(--space-xl) var(--space-md); }
  .key-input-group { padding: var(--space-md); }
  .key-input-wrapper input { font-size: 16px; }
  .btn-mini { padding: 9px 14px; min-height: 40px; }
}

@media (max-width: 375px) {
  .gate-container { padding: 0 var(--space-sm); }
  .gate-form { padding: var(--space-md); }
  .key-container { padding: 0 var(--space-sm); }
  .header-right { gap: 6px; }
  .panel { padding: var(--space-md); }
}

/* ============================================
   PRINT — clean proposal-only PDF
   ============================================ */
@media print {
  .bg-gradient, .app-header, .app-footer, .btn-icon,
  .input-panel, .intro-block, .output-head, .output-empty,
  .output-loading, .tips-block,
  #feedback-widget, #feedback-btn, #rate-limit-toast { display: none !important; }

  body { background: #fff; color: #000; }
  .app-main { padding: 0; max-width: 100%; }
  .builder-grid { display: block; }
  .output-panel { position: static; border: none; padding: 0; background: #fff; }
  .proposal-doc {
    background: #fff;
    border: none;
    padding: 0;
    color: #000;
  }
  .pd-title { color: #000; }
  .pd-h { color: #000; }
  .pd-text, .pd-step-name, .pd-meta-row strong { color: #000; }
  .pd-list li, .pd-step-desc, .pd-step-when, .pd-meta-row { color: #333; }
  .pd-parties { color: #444; border-color: #999; }
  .pd-parties strong { color: #000; }
  .pd-invest {
    background: #f5f3ff;
    border: 1px solid #ccc;
  }
  .pd-step { border-left-color: #999; }
  .pd-step::before { background: #666; }
  .pd-section, .pd-step { break-inside: avoid; }
}
