/* ============================================================
   Manager Decision Agent — custom styles
   Design direction: editorial / document-first
   Palette: parchment ground, forest-green anchor, ink neutrals
   Typography: DM Serif Display (headings) + DM Sans (body)
   ============================================================ */

/* ── Reset / base ─────────────────────────────────────── */

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

body {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.9375rem; /* 15px — tighter than default 16 */
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Field groups ─────────────────────────────────────── */

.field-group {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.field-label {
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.03em;
  color: #52493e; /* ink-500 */
  text-transform: none;
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
}

.field-hint {
  font-size: 0.7rem;
  font-weight: 400;
  color: #a39c8f; /* ink-300 */
  letter-spacing: 0;
}

/* ── Inputs ───────────────────────────────────────────── */

.agent-input,
.agent-select,
.agent-textarea {
  width: 100%;
  background: #faf8f3; /* parch-50 — same as page bg */
  border: 1px solid #e8e1cf; /* parch-200 */
  color: #342e23; /* ink-600 */
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 1rem; /* 16px — prevents iOS Safari auto-zoom on focus */
  line-height: 1.5;
  padding: 0.5rem 0.75rem;
  border-radius: 0; /* no rounded — editorial feel */
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease;
  appearance: none;
  -webkit-appearance: none;
}

.agent-input:focus,
.agent-select:focus,
.agent-textarea:focus {
  border-color: #1e5220; /* forest-600 */
  box-shadow: 0 0 0 2px rgba(30, 82, 32, 0.12);
}

.agent-input::placeholder,
.agent-textarea::placeholder {
  color: #a39c8f; /* ink-300 */
  font-style: italic;
}

.agent-textarea {
  resize: vertical;
  min-height: 4rem;
}

/* Select arrow */
.input-wrap {
  position: relative;
}

.agent-select {
  padding-right: 2rem;
  cursor: pointer;
}

.input-wrap::after {
  content: '';
  position: absolute;
  right: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid #7a7163; /* ink-400 */
  pointer-events: none;
}

/* ── Buttons ──────────────────────────────────────────── */

.btn-primary {
  display: inline-flex;
  align-items: center;
  background: #1e5220; /* forest-600 */
  color: #f0f4f0; /* forest-50 */
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.5rem 1.125rem;
  border: none;
  border-radius: 0;
  cursor: pointer;
  transition: background 150ms ease;
  text-decoration: none;
}

.btn-primary:hover {
  background: #163d18; /* forest-700 */
}

.btn-primary:active {
  background: #0e2a10;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  background: transparent;
  color: #7a7163; /* ink-400 */
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.8125rem;
  font-weight: 400;
  padding: 0.5rem 0;
  border: none;
  cursor: pointer;
  transition: color 150ms ease;
  text-decoration: none;
}

.btn-ghost:hover {
  color: #342e23; /* ink-600 */
}

/* Bordered ghost — used for secondary actions that need a target shape */
.btn-ghost-bordered {
  display: inline-flex;
  align-items: center;
  background: transparent;
  color: #524b3e; /* ink-500 */
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.8125rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  padding: 0.5rem 1rem;
  border: 1px solid #d4c9b0; /* parch-300 */
  border-radius: 0;
  cursor: pointer;
  transition: border-color 150ms ease, color 150ms ease, background 150ms ease;
  text-decoration: none;
}

.btn-ghost-bordered:hover {
  border-color: #1e5220; /* forest-600 */
  color: #1e5220;
  background: #f0f4f0; /* forest-50 */
}

/* Print: hide chrome, render the replan as a clean document */
@media print {
  header, .loading-overlay, button, #copy-feedback, .field-group, .border-t.border-parch-200 {
    display: none !important;
  }
  body { background: white !important; color: black !important; }
  main { padding: 0 !important; max-width: 100% !important; }
  .result-body { border-left: none !important; padding-left: 0 !important; }
  .prose h2 { page-break-after: avoid; }
  .prose p, .prose li { page-break-inside: avoid; }
}

/* ── Loading overlay ──────────────────────────────────── */

.loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(250, 248, 243, 0.88); /* parch-50 tinted */
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;

  /* Hidden by default */
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.loading-overlay.is-visible {
  opacity: 1;
  pointer-events: all;
}

.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2.5rem 3rem;
  /* No card border — the blur backdrop IS the container */
}

/* Spinner: minimal arc, no color noise */
.loading-spinner {
  width: 28px;
  height: 28px;
  border: 2px solid #d4c9b0; /* parch-300 */
  border-top-color: #1e5220; /* forest-600 */
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.loading-label {
  font-family: "DM Serif Display", Georgia, serif;
  font-size: 1.125rem;
  color: #342e23; /* ink-600 */
  text-align: center;
  margin: 0;
}

.loading-sublabel {
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.8rem;
  color: #7a7163; /* ink-400 */
  text-align: center;
  margin: 0;
  font-style: italic;
}

/* ── Button loading state + thinking dots ─────────────── */

.btn-primary.is-loading,
.btn-primary[disabled] {
  background: #346e36;
  cursor: not-allowed;
  pointer-events: none;
  opacity: 0.92;
}

.thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  margin-left: 0.5rem;
}

.thinking-dots i {
  display: inline-block;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.25;
  animation: dotPulse 1.2s infinite ease-in-out;
}

.thinking-dots i:nth-child(2) { animation-delay: 0.18s; }
.thinking-dots i:nth-child(3) { animation-delay: 0.36s; }

@keyframes dotPulse {
  0%, 70%, 100% { opacity: 0.25; transform: translateY(0); }
  35% { opacity: 1; transform: translateY(-2px); }
}

/* Faster overlay fade so the click feels acknowledged immediately */
.loading-overlay {
  transition: opacity 140ms ease;
}

/* Subtle text fade when overlay copy swaps mid-wait */
.loading-label,
.loading-sublabel {
  transition: opacity 200ms ease;
}

/* ── Suggestion chips (clarifier starter answers) ────── */

.suggestion-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.375rem;
  margin: 0.125rem 0 0.5rem 0;
}

.suggestion-chip {
  display: inline-block;
  background: #f3efe4; /* parch-100 */
  color: #524b3e; /* ink-500 */
  font-family: "DM Sans", system-ui, sans-serif;
  font-size: 0.75rem;
  line-height: 1.3;
  padding: 0.3125rem 0.625rem;
  border: 1px solid #e8e1cf; /* parch-200 */
  border-radius: 0; /* match the no-radius design */
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, color 140ms ease;
  text-align: left;
  max-width: 100%;
}

.suggestion-chip:hover {
  background: #e8e1cf; /* parch-200 */
  border-color: #d4c9b0; /* parch-300 */
  color: #342e23; /* ink-600 */
}

.suggestion-chip.is-picked {
  background: #1e5220; /* forest-600 */
  color: #f0f4f0; /* forest-50 */
  border-color: #1e5220;
}

/* ── Error banner ─────────────────────────────────────── */

/* Defined inline via Tailwind in templates, but extend here for any extra treatment */

/* ── Result body — document rule treatment ────────────── */

.result-body {
  border-left: 2px solid #e8e1cf; /* parch-200 */
  padding-left: 1.5rem;
  margin-left: 0;
}

/* On mobile, remove the left rule */
@media (max-width: 600px) {
  .result-body {
    border-left: none;
    padding-left: 0;
  }
}

/* ── Prose overrides — ensure font families match ─────── */

.prose {
  --tw-prose-body: #52493e;
  --tw-prose-headings: #1e1a12;
  --tw-prose-lead: #7a7163;
  --tw-prose-links: #1e5220;
  --tw-prose-bold: #342e23;
  --tw-prose-counters: #7a7163;
  --tw-prose-bullets: #a39c8f;
  --tw-prose-hr: #e8e1cf;
  --tw-prose-quotes: #52493e;
  --tw-prose-quote-borders: #1e5220;
  --tw-prose-captions: #7a7163;
  --tw-prose-code: #342e23;
  --tw-prose-pre-code: #342e23;
  --tw-prose-pre-bg: #f3efe4;
  --tw-prose-th-borders: #e8e1cf;
  --tw-prose-td-borders: #f3efe4;
}

/* ── Mobile adjustments ───────────────────────────────── */

@media (max-width: 640px) {
  /* Stack 3-col grid to 2 on narrow mobile */
  .grid.grid-cols-3 {
    grid-template-columns: 1fr 1fr;
  }

  /* Team name spans full width on smallest viewports */
  @media (max-width: 400px) {
    .grid.grid-cols-3 {
      grid-template-columns: 1fr;
    }
  }

  .loading-card {
    padding: 2rem 1.5rem;
  }
}

/* ── Step number hint (micro-text) ────────────────────── */

/* Handled in templates via Tailwind, nothing extra needed */

/* ── Mono textarea override ───────────────────────────── */

.agent-textarea.font-mono {
  font-family: "JetBrains Mono", "Fira Code", "Courier New", monospace;
  letter-spacing: -0.01em;
  line-height: 1.6;
}
