/* ======================================================
   RAPHAS ORÇAMENTOS — CSS Mobile-First
   Design: tela única, botões grandes, intuitivo
   ====================================================== */

:root {
  --bg: #0f172a;
  --surface: #1e293b;
  --card: #111827;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --green: #22c55e;
  --red: #ef4444;
  --yellow: #fbbf24;
  --border: rgba(148,163,184,.15);
  --radius: 14px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*,*::before,*::after { box-sizing: border-box; margin: 0; padding: 0; }
html,body { height: 100%; overflow: hidden; }
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

/* ---- APP SHELL ---- */
.app {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
}

/* ---- HEADER ---- */
.app__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 12px;
  height: 52px;
  background: rgba(15,23,42,.96);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
  z-index: 100;
}
.hdr-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}
.hdr-logo {
  background: var(--accent);
  color: #000;
  font-weight: 800;
  font-size: .8rem;
  width: 30px; height: 30px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hdr-name {
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
}
.hdr-actions {
  display: flex;
  gap: 4px;
}
.hdr-btn {
  width: 40px; height: 40px;
  border-radius: 10px;
  border: none;
  background: transparent;
  color: var(--muted);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 1.1rem;
  transition: background .15s, color .15s;
  -webkit-tap-highlight-color: transparent;
}
.hdr-btn:active {
  background: rgba(255,255,255,.08);
  color: var(--accent);
}

/* ---- MAIN ---- */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  overflow-x: hidden;
  position: relative;
  -webkit-overflow-scrolling: touch;
}

/* ---- STEP (Tela única) ---- */
.step {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 20px 16px calc(16px + var(--safe-bottom));
  gap: 14px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

.step-hint {
  text-align: center;
  font-size: .9rem;
  color: var(--muted);
  line-height: 1.5;
}

/* ---- TEXTAREA ---- */
.txt {
  width: 100%;
  min-height: 130px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  transition: border-color .2s;
}
.txt:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56,189,248,.12);
}
.txt::placeholder {
  color: rgba(148,163,184,.45);
  font-size: .88rem;
}

/* ---- ACTION ROW ---- */
.act-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

/* Botão principal: grande, full-width */
.btn-go {
  flex: 1;
  min-height: 52px;
  border-radius: var(--radius);
  border: none;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 14px rgba(37,99,235,.35);
  transition: transform .1s, box-shadow .2s;
  -webkit-tap-highlight-color: transparent;
}
.btn-go:active {
  transform: scale(.97);
  box-shadow: 0 2px 8px rgba(37,99,235,.3);
}
.btn-go:disabled {
  opacity: .6;
  cursor: wait;
}

/* Botões redondos auxiliares */
.btn-round {
  width: 52px; height: 52px;
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.btn-round:active { transform: scale(.93); }
.btn-round--red {
  border-color: rgba(239,68,68,.3);
  color: #f87171;
}

/* ---- FEEDBACK AREA ---- */
.feedback {
  border-radius: var(--radius);
  padding: 16px;
  overflow-y: auto;
  animation: fadeUp .25s ease;
}
.feedback.hidden { display: none; }
.feedback.info {
  background: rgba(56,189,248,.08);
  border: 1px solid rgba(56,189,248,.25);
  color: var(--accent);
}
.feedback.error {
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.25);
  color: var(--red);
}
.feedback.success {
  background: rgba(34,197,94,.05);
  border: 1px solid rgba(34,197,94,.2);
  color: var(--text);
}

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

/* ---- PARSED PREVIEW ---- */
.parsed-preview h3 {
  margin: 0 0 10px;
  font-size: 1rem;
  color: var(--green);
}
.parsed-preview h4 {
  margin: 14px 0 6px;
  font-size: .92rem;
  color: var(--accent);
}
.parsed-grid {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.parsed-field {
  font-size: .85rem;
  padding: 5px 0;
  border-bottom: 1px solid rgba(255,255,255,.04);
  line-height: 1.4;
}
.parsed-label {
  font-weight: 700;
  color: var(--muted);
  font-size: .75rem;
  text-transform: uppercase;
}
.parsed-value { color: var(--text); }

.parsed-items {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.parsed-item {
  background: rgba(255,255,255,.03);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255,255,255,.06);
  font-size: .85rem;
  line-height: 1.5;
}
.parsed-item small { color: var(--muted); }

/* Botões de ação pós-preview (Gerar Orçamento / Gerar Contrato) */
.parsed-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.btn-apply {
  width: 100%;
  min-height: 54px;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: none;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .1s;
  -webkit-tap-highlight-color: transparent;
}
.btn-apply:active { transform: scale(.97); }

.btn-gen-orc {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37,99,235,.3);
}
.btn-gen-ctr {
  background: linear-gradient(135deg, #7c3aed, #6d28d9);
  color: #fff;
  box-shadow: 0 4px 14px rgba(124,58,237,.3);
}
.btn-discard {
  width: 100%;
  min-height: 46px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: .9rem;
  cursor: pointer;
  transition: transform .1s;
}
.btn-discard:active { transform: scale(.97); }

/* ---- MISSING FIELDS ---- */
.missing-warning {
  background: rgba(251,191,36,.08);
  border: 1px solid rgba(251,191,36,.25);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 10px;
  font-size: .85rem;
  color: var(--yellow);
  line-height: 1.5;
}
.parsed-field--missing {
  background: rgba(251,191,36,.04);
  border: 1px solid rgba(251,191,36,.12);
  border-radius: 10px;
  padding: 8px 12px !important;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.parsed-input {
  width: 100%;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: .9rem;
  outline: none;
  transition: border-color .2s;
}
.parsed-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(56,189,248,.1);
}
.parsed-input::placeholder { color: rgba(148,163,184,.45); }
.parsed-textarea {
  resize: vertical;
  min-height: 72px;
  line-height: 1.5;
}
.parsed-field--editable {
  border-left: 2px solid var(--accent);
  padding-left: 8px;
}
.req-badge {
  display: inline-block;
  background: rgba(239,68,68,.12);
  color: #f87171;
  font-size: .6rem;
  text-transform: uppercase;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
}
.opt-badge {
  display: inline-block;
  background: rgba(148,163,184,.08);
  color: var(--muted);
  font-size: .6rem;
  text-transform: uppercase;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  margin-left: 4px;
  vertical-align: middle;
}
.default-suggestion { display: flex; flex-direction: column; gap: 2px; }
.default-hint { font-size: .7rem; color: var(--green); font-style: italic; opacity: .8; }
.parsed-item-inputs { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }

/* ---- HISTORY OVERLAY ---- */
.hist-overlay {
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 50;
  display: flex;
  flex-direction: column;
  padding: 16px;
  animation: fadeUp .2s ease;
}
.hist-overlay.hidden { display: none; }
.hist-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 12px;
}
.hist-bar h2 { font-size: 1.1rem; }
.hist-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  -webkit-overflow-scrolling: touch;
}
.history-item {
  background: var(--surface);
  padding: 14px;
  border-radius: 12px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: border-color .15s;
}
.history-item:active { border-color: var(--green); }
.history-item h4 { margin: 0 0 4px; color: var(--text); font-size: .95rem; }
.history-item p { margin: 0; font-size: .82rem; color: var(--muted); }
.history-meta {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: .72rem;
  opacity: .7;
}

/* ---- SPINNER ---- */
.spinner {
  display: inline-block;
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,.25);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin .55s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- SHARE / AFTER-PDF BUTTONS ---- */
.btn-share {
  width: 100%;
  min-height: 54px;
  border-radius: var(--radius);
  border: none;
  background: #25D366;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .1s;
}
.btn-share:active { transform: scale(.97); }

.btn-alt {
  width: 100%;
  min-height: 52px;
  border-radius: var(--radius);
  border: none;
  background: #7c3aed;
  color: #fff;
  font-weight: 700;
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform .1s;
}
.btn-alt:active { transform: scale(.97); }

.btn-new {
  width: 100%;
  min-height: 48px;
  border-radius: var(--radius);
  border: 1.5px solid var(--accent);
  background: transparent;
  color: var(--accent);
  font-weight: 700;
  font-size: .95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform .1s;
}
.btn-new:active { transform: scale(.97); }

/* ---- TIPO BUTTONS (reutilizado no preview se necessário) ---- */
.tipo-btn {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: rgba(255,255,255,.02);
  color: var(--text);
  font-size: .9rem;
  cursor: pointer;
  font-weight: 500;
  transition: all .15s;
  -webkit-tap-highlight-color: transparent;
}
.tipo-btn:active { transform: scale(.97); }
.tipo-btn.active {
  background: linear-gradient(135deg, rgba(56,189,248,.15), rgba(34,197,94,.1));
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}

/* ---- DESKTOP (>640px) ---- */
@media (min-width: 640px) {
  .step { max-width: 560px; padding: 32px 24px; }
  .txt { min-height: 160px; }
  .parsed-actions { flex-direction: row; flex-wrap: wrap; }
  .btn-apply { width: auto; flex: 1; min-width: 200px; }
  .btn-discard { width: auto; flex: 0; min-width: 140px; }
}

/* ---- Botão mic gravando ---- */
.btn-round.recording {
  background: rgba(239,68,68,.15);
  border-color: var(--red);
  animation: pulse 1.2s infinite;
}
@keyframes pulse {
  0%,100% { opacity: 1; }
  50% { opacity: .4; }
}

/* ---- COMPAT: elementos legados ocultos ---- */
.sidebar, .sidebar-overlay, .content-wrapper,
.chat__messages, .chat__choices, .chat__composer {
  display: none !important;
}

/* ======================================================
   MODAL DE SENHA & PAINEL DE CONFIGURAÇÕES
   ====================================================== */

/* Overlay do modal de senha */
.cfg-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeUp .2s ease;
}
.cfg-modal-overlay.hidden { display: none; }

.cfg-modal-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 28px 24px;
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
}

.cfg-modal-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}
.cfg-modal-subtitle {
  font-size: .88rem;
  color: var(--muted);
  margin-top: -6px;
}

.cfg-pwd-error {
  font-size: .83rem;
  color: var(--red);
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.2);
  border-radius: 8px;
  padding: 8px 12px;
}
.cfg-pwd-error.hidden { display: none; }

.cfg-modal-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

/* Painel de configurações (overlay tipo historyView) */
.cfg-panel {
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 150;
  display: flex;
  flex-direction: column;
  animation: fadeUp .2s ease;
  overflow: hidden;
}
.cfg-panel.hidden { display: none; }

.cfg-panel-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.cfg-panel-title {
  font-size: 1.05rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
}

.cfg-panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
  -webkit-overflow-scrolling: touch;
}

.cfg-section-desc {
  font-size: .83rem;
  color: var(--muted);
  line-height: 1.5;
  background: rgba(56,189,248,.06);
  border: 1px solid rgba(56,189,248,.15);
  border-radius: 10px;
  padding: 10px 14px;
}

.cfg-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.cfg-section-title {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--accent);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.cfg-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.cfg-label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.cfg-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1.5px solid var(--border);
  background: var(--card);
  color: var(--text);
  font-family: inherit;
  font-size: .95rem;
  outline: none;
  transition: border-color .2s;
}
.cfg-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(56,189,248,.1);
}
.cfg-input::placeholder { color: rgba(148,163,184,.4); }
.cfg-hint {
  font-size: .75rem;
  color: var(--muted);
  line-height: 1.4;
}

.cfg-save-msg {
  border-radius: 10px;
  padding: 10px 14px;
  font-size: .88rem;
  font-weight: 600;
}
.cfg-save-msg.hidden { display: none; }
.cfg-save-msg.success {
  background: rgba(34,197,94,.08);
  border: 1px solid rgba(34,197,94,.25);
  color: var(--green);
}
.cfg-save-msg.error {
  background: rgba(239,68,68,.08);
  border: 1px solid rgba(239,68,68,.25);
  color: var(--red);
}

.cfg-panel-actions {
  display: flex;
  gap: 10px;
  padding-top: 8px;
}

/* Botões compartilhados (modal + painel) */
.cfg-btn {
  flex: 1;
  min-height: 48px;
  border-radius: 12px;
  border: none;
  font-family: inherit;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .1s, opacity .15s;
  -webkit-tap-highlight-color: transparent;
}
.cfg-btn:active { transform: scale(.96); }
.cfg-btn--primary {
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: #fff;
  box-shadow: 0 4px 14px rgba(37,99,235,.3);
}
.cfg-btn--ghost {
  background: transparent;
  border: 1.5px solid var(--border);
  color: var(--muted);
}
.cfg-btn--ghost:active { background: rgba(255,255,255,.05); }

/* ---- PROVIDER SELECTOR ---- */
.cfg-provider-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}
.cfg-provider-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 14px 8px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: var(--card);
  cursor: pointer;
  transition: border-color .15s, background .15s;
  text-align: center;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.cfg-provider-card input[type="radio"] {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}
.cfg-provider-card.active {
  border-color: var(--accent);
  background: rgba(56,189,248,.09);
}
.cfg-provider-card:active { transform: scale(.95); }
.cfg-provider-logo { font-size: 1.5rem; line-height: 1; }
.cfg-logo-gemini { color: #38bdf8; }
.cfg-logo-openai { color: #10a37f; }
.cfg-logo-claude { color: #d97706; }
.cfg-provider-name {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
}
.cfg-provider-sub { font-size: .68rem; color: var(--muted); }

.cfg-section-title--provider {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cfg-active-badge {
  display: inline-block;
  width: 8px; height: 8px;
  border-radius: 50%;
  background: transparent;
  flex-shrink: 0;
  transition: background .2s;
}
.cfg-active-badge.active {
  background: var(--green);
  box-shadow: 0 0 6px rgba(34,197,94,.5);
}
.cfg-provider-section { transition: opacity .2s; }
.cfg-provider-section.cfg-inactive {
  opacity: .3;
  pointer-events: none;
}

