/* estimator.css — Phase 00 styles */

/* ── Layout wrapper ── */
.est-root {
  width: 100%;
}

/* ── Shared phase elements ── */
.est-phase-eyebrow {
  font-family: 'JetBrains Mono', monospace;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent, #1A56DB);
  margin-bottom: 6px;
}

.est-phase-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--fg, #1C1C1E);
  margin: 0 0 6px;
  line-height: 1.2;
}

.est-phase-sub {
  font-size: 14px;
  color: var(--fg-muted, #6B7280);
  margin: 0 0 28px;
  line-height: 1.5;
}

/* ── Landing ── */
.est-landing {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 48px;
  align-items: center;
  padding: 48px 0 56px;
  border-bottom: 1px solid var(--border, #E5E7EB);
}

.est-landing-inner {
  max-width: 420px;
}

.est-landing-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.est-btn-primary {
  height: 42px;
  padding: 0 24px;
  background: var(--accent, #1A56DB);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.est-btn-primary:hover { opacity: .88; }

.est-btn-ghost {
  height: 42px;
  padding: 0 20px;
  background: transparent;
  color: var(--fg-muted, #6B7280);
  border: 1px solid var(--border, #E5E7EB);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  transition: border-color .15s, color .15s;
}
.est-btn-ghost:hover { border-color: var(--fg-muted, #6B7280); color: var(--fg, #1C1C1E); }
.est-btn-ghost.small { height: 34px; padding: 0 14px; font-size: 13px; }

/* Landing diagram */
.est-landing-diagram {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: flex-end;
}

.est-diagram-node {
  padding: 14px 18px;
  border-radius: 10px;
  background: var(--surface, #F9FAFB);
  border: 1px solid var(--border, #E5E7EB);
  min-width: 80px;
  text-align: center;
}
.est-diagram-node.node-b { border-color: var(--accent, #1A56DB); background: color-mix(in srgb, var(--accent, #1A56DB) 8%, var(--surface, #F9FAFB)); }
.est-diagram-node.node-c { border-color: color-mix(in srgb, var(--accent, #1A56DB) 50%, var(--border, #E5E7EB)); }

.est-node-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--fg-muted, #6B7280);
  white-space: nowrap;
}
.node-b .est-node-label { color: var(--accent, #1A56DB); }

.est-diagram-arrow {
  color: var(--border, #E5E7EB);
  font-size: 18px;
  font-weight: 300;
  flex-shrink: 0;
}

/* ── Chat section ── */
.est-chat-section {
  display: flex;
  flex-direction: column;
  padding: 32px 0 0;
  border-bottom: 1px solid var(--border, #E5E7EB);
}

.est-chat-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 20px;
}
.est-chat-header .est-phase-sub { margin-bottom: 0; }

.est-chat-scroll {
  min-height: 320px;
  max-height: 480px;
  overflow-y: auto;
  padding: 4px 0 16px;
  scrollbar-width: thin;
  scrollbar-color: var(--border, #E5E7EB) transparent;
}

/* Messages */
.est-msg {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: flex-start;
}
.est-msg-user { flex-direction: row-reverse; }

.est-avatar {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--surface, #F9FAFB);
  border: 1px solid var(--border, #E5E7EB);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: 600;
  color: var(--fg-muted, #6B7280);
  text-transform: uppercase;
  letter-spacing: .04em;
}
.est-msg-user .est-avatar { background: var(--accent, #1A56DB); border-color: var(--accent, #1A56DB); color: #fff; }

.est-bubble {
  max-width: 82%;
  padding: 12px 16px;
  border-radius: 10px;
  background: var(--surface, #F9FAFB);
  border: 1px solid var(--border, #E5E7EB);
  font-size: 14px;
  line-height: 1.6;
  color: var(--fg, #1C1C1E);
}
.est-msg-user .est-bubble {
  background: color-mix(in srgb, var(--accent, #1A56DB) 10%, var(--surface, #F9FAFB));
  border-color: color-mix(in srgb, var(--accent, #1A56DB) 25%, var(--border, #E5E7EB));
}

/* Thinking dots */
.est-thinking {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 14px 18px;
}
.est-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--fg-muted, #6B7280);
  animation: estDotPulse 1.2s ease-in-out infinite;
}
.est-dot:nth-child(2) { animation-delay: .2s; }
.est-dot:nth-child(3) { animation-delay: .4s; }
@keyframes estDotPulse {
  0%, 80%, 100% { opacity: .25; transform: scale(.85); }
  40% { opacity: 1; transform: scale(1); }
}

/* Suggestions */
.est-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 4px 0 8px 40px;
}
.est-suggestion {
  padding: 7px 14px;
  border-radius: 20px;
  border: 1px solid var(--border, #E5E7EB);
  background: transparent;
  color: var(--fg-muted, #6B7280);
  font-family: inherit;
  font-size: 13px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.est-suggestion:hover {
  border-color: var(--accent, #1A56DB);
  color: var(--accent, #1A56DB);
  background: color-mix(in srgb, var(--accent, #1A56DB) 6%, transparent);
}

/* Input row */
.est-chat-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
  padding: 16px 0 24px;
  border-top: 1px solid var(--border, #E5E7EB);
  margin-top: 8px;
}

.est-chat-input {
  flex: 1;
  min-height: 52px;
  padding: 14px 16px;
  background: var(--surface, #F9FAFB);
  border: 1px solid var(--border, #E5E7EB);
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  color: var(--fg, #1C1C1E);
  resize: none;
  outline: none;
  transition: border-color .15s;
  line-height: 1.5;
}
.est-chat-input::placeholder { color: var(--fg-muted, #6B7280); opacity: .6; }
.est-chat-input:focus { border-color: var(--accent, #1A56DB); }

.est-send-btn {
  width: 42px; height: 42px;
  flex-shrink: 0;
  background: var(--accent, #1A56DB);
  border: none;
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .15s;
}
.est-send-btn:hover:not(:disabled) { opacity: .88; }
.est-send-btn:disabled { opacity: .35; cursor: default; }

/* ── Result section ── */
.est-result-section {
  padding: 32px 0 0;
  border-bottom: 1px solid var(--border, #E5E7EB);
}

.est-result-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 24px;
}

.est-result-card {
  background: var(--surface, #F9FAFB);
  border: 1px solid var(--border, #E5E7EB);
  border-radius: 14px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 24px;
}

.est-result-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.est-result-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--fg, #1C1C1E);
}
.est-result-hint {
  font-size: 12px;
  color: var(--fg-muted, #6B7280);
}

.est-result-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.est-result-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.est-result-label {
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-muted, #6B7280);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.est-result-money {
  display: flex;
  align-items: center;
  gap: 0;
  background: var(--bg, #FFFFFF);
  border: 1px solid var(--border, #E5E7EB);
  border-radius: 8px;
  overflow: hidden;
}
.est-result-prefix {
  padding: 0 10px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  color: var(--fg-muted, #6B7280);
  background: color-mix(in srgb, var(--border, #E5E7EB) 30%, var(--surface, #F9FAFB));
  border-right: 1px solid var(--border, #E5E7EB);
  height: 38px;
  display: flex;
  align-items: center;
}

.est-result-input {
  flex: 1;
  height: 38px;
  padding: 0 12px;
  background: transparent;
  border: none;
  font-family: inherit;
  font-size: 14px;
  color: var(--fg, #1C1C1E);
  outline: none;
}
.est-result-input.mono { font-family: 'JetBrains Mono', monospace; }

/* Deal input (full-width) */
.est-result-field:not(:has(.est-result-money)) .est-result-input {
  background: var(--bg, #FFFFFF);
  border: 1px solid var(--border, #E5E7EB);
  border-radius: 8px;
  padding: 0 12px;
  height: 38px;
  width: 100%;
  box-sizing: border-box;
}

.est-breakdown {
  font-size: 12px;
  color: var(--fg-muted, #6B7280);
  line-height: 1.5;
  padding: 6px 0 0;
  border-top: 1px solid var(--border, #E5E7EB);
  margin-top: 4px;
}

.est-result-ratio {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  background: color-mix(in srgb, var(--accent, #1A56DB) 6%, var(--surface, #F9FAFB));
  border: 1px solid color-mix(in srgb, var(--accent, #1A56DB) 20%, var(--border, #E5E7EB));
  border-radius: 8px;
}
.est-ratio-label {
  font-size: 12px;
  color: var(--fg-muted, #6B7280);
}
.est-ratio-value {
  font-family: 'JetBrains Mono', monospace;
  font-size: 14px;
  font-weight: 600;
  color: var(--accent, #1A56DB);
}

.est-apply-btn {
  height: 44px;
  background: var(--accent, #1A56DB);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s, background .2s;
}
.est-apply-btn:hover:not(:disabled):not(.is-applied) { opacity: .88; }
.est-apply-btn.is-applied { background: var(--green, #16A34A, #16a34a); cursor: default; }

.est-result-continue {
  display: flex;
  justify-content: flex-end;
  padding-bottom: 32px;
}

.est-continue-btn {
  height: 42px;
  padding: 0 24px;
  background: transparent;
  color: var(--accent, #1A56DB);
  border: 1.5px solid var(--accent, #1A56DB);
  border-radius: 8px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.est-continue-btn:hover {
  background: var(--accent, #1A56DB);
  color: #fff;
}

/* ── Responsive ── */
@media (max-width: 680px) {
  .est-landing { grid-template-columns: 1fr; gap: 32px; }
  .est-landing-diagram { justify-content: flex-start; flex-wrap: wrap; }
  .est-result-row { grid-template-columns: 1fr; }
}

/* ── App wrappers ── */
.app-estimator-wrapper .grid.single-col {
  grid-template-columns: 1fr;
  max-width: 860px;
}

.calculator-root {
  /* seamless — inherits .app layout */
}

/* ── Report generator ── */
.rpt-wrapper {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

.rpt-section-wrap {
  padding: 48px 0 56px;
  border-top: 1px solid var(--border, #E5E7EB);
}

.rpt-header { margin-bottom: 28px; }

.rpt-idle { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }

.rpt-error {
  color: var(--red, #DC2626, #dc2626);
  font-size: 13px;
  padding: 8px 14px;
  background: color-mix(in srgb, var(--red, #DC2626, #dc2626) 8%, transparent);
  border-radius: 6px;
  border: 1px solid color-mix(in srgb, var(--red, #DC2626, #dc2626) 20%, transparent);
}

.rpt-generating {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0;
}
.rpt-generating-label {
  font-size: 14px;
  color: var(--fg-muted, #6B7280);
}

.rpt-editor {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--border, #E5E7EB);
  border-radius: 12px;
  overflow: hidden;
}

.rpt-editor-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px;
  background: var(--surface, #F9FAFB);
  border-bottom: 1px solid var(--border, #E5E7EB);
  gap: 12px;
  flex-wrap: wrap;
}
.rpt-preview-label {
  font-size: 12px;
  color: var(--fg-muted, #6B7280);
  font-style: italic;
}
.rpt-toolbar-actions {
  display: flex;
  gap: 8px;
}

.rpt-section {
  border-bottom: 1px solid var(--border, #E5E7EB);
}
.rpt-section:last-of-type { border-bottom: none; }

.rpt-section-header {
  padding: 10px 18px 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent, #1A56DB);
  font-family: 'JetBrains Mono', monospace;
}

.rpt-section-body {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 18px 14px;
  background: transparent;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.7;
  color: var(--fg, #1C1C1E);
  resize: vertical;
  min-height: 90px;
}
.rpt-section-body:focus {
  background: color-mix(in srgb, var(--accent, #1A56DB) 3%, transparent);
}

.rpt-editor-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: var(--surface, #F9FAFB);
  border-top: 1px solid var(--border, #E5E7EB);
  gap: 12px;
}

/* ── FIX 2: Full-width estimator layout ── */
.est-fullwidth-main {
  flex: 1;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 0 32px 48px;
  box-sizing: border-box;
}

/* ── FIX 1: Estimator drawer (floating chat in calculator) ── */
.est-drawer-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 44px;
  padding: 0 18px;
  background: var(--accent, #1A56DB);
  color: #fff;
  border: none;
  border-radius: 22px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(26,86,219,.35);
  transition: transform .15s, box-shadow .15s;
  z-index: 200;
}
.est-drawer-toggle:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(26,86,219,.4); }
.est-drawer-toggle.is-open { background: var(--fg, #1C1C1E); }
.est-drawer-toggle.is-pulse { animation: drawerPulse .6s ease; }
@keyframes drawerPulse {
  0%,100% { box-shadow: 0 4px 16px rgba(26,86,219,.35); }
  50% { box-shadow: 0 4px 28px rgba(22,163,74,.6); }
}

.est-drawer-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}

.est-drawer-panel {
  position: fixed;
  bottom: 84px;
  right: 28px;
  width: 420px;
  max-height: 72vh;
  background: var(--bg, #fff);
  border: 1px solid var(--border, #E5E7EB);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.14);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 199;
}

.est-drawer-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border, #E5E7EB);
  background: var(--surface, #F9FAFB);
  flex-shrink: 0;
}

.est-chat-compact .est-chat-scroll {
  min-height: 200px;
  max-height: 340px;
}
.est-chat-compact {
  padding: 0;
  border-bottom: none;
}
.est-chat-compact .est-chat-input-row {
  padding: 10px 14px 12px;
  border-top: 1px solid var(--border, #E5E7EB);
  margin-top: 0;
}
.est-chat-compact .est-chat-scroll {
  padding: 10px 14px 4px;
}

/* ── FIX 4: Audit panel ── */
.audit-panel {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px 8px;
}

.audit-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  color: var(--fg-muted, #6B7280);
  padding: 10px 0;
  transition: color .15s;
}
.audit-toggle:hover { color: var(--accent, #1A56DB); }

.audit-tag {
  margin-left: 6px;
  padding: 2px 8px;
  background: var(--surface, #F9FAFB);
  border: 1px solid var(--border, #E5E7EB);
  border-radius: 10px;
  font-size: 11px;
  color: var(--fg-muted, #6B7280);
  font-weight: 500;
}

.audit-body {
  border: 1px solid var(--border, #E5E7EB);
  border-radius: 10px;
  padding: 16px 20px;
  background: var(--surface, #F9FAFB);
  margin-bottom: 12px;
}

.audit-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.audit-col-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--accent, #1A56DB);
  margin-bottom: 6px;
  font-family: 'JetBrains Mono', monospace;
}

.audit-col-text {
  font-size: 13px;
  color: var(--fg, #1C1C1E);
  line-height: 1.6;
}

@media (max-width: 680px) {
  .est-drawer-panel { width: calc(100vw - 32px); right: 16px; }
  .audit-row { grid-template-columns: 1fr; }
}
