/* =========================================================
   crm-detail-density.css
   CRM Inquiry Detail View — Components + Density

   Load after: freight-density.css (last in stack)
   Tokens: variablesv2.css  (--text-faint, NOT --text-muted)
   Scope: detail view only. Board cards / topbar untouched.

   Design intent:
   - Broker  → decision first, details second
   - Customer → status + next action first
   - Admin   → full data, no hand-holding
   - React-ready: every block is a semantic class, no inline deps
========================================================= */


/* =========================================================
   1. <details> / <summary> — Collapsible Sections
   Zero coverage in existing CSS. Browser defaults are ugly.
   Match your 0.15s transition language from appv2.css.
========================================================= */

details.crm-collapsible {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  overflow: hidden;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}

details.crm-collapsible + details.crm-collapsible {
  margin-top: 8px;
}

details.crm-collapsible[open] {
  box-shadow: var(--shadow-md);
}

details.crm-collapsible > summary {
  padding: 12px 16px;
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  user-select: none;
  font-weight: 700;
  font-size: 0.88rem;
  line-height: 1.2;
  color: var(--text);
  transition: background 0.12s ease;
}

details.crm-collapsible > summary::-webkit-details-marker { display: none; }
details.crm-collapsible > summary::marker { content: ""; }
details.crm-collapsible > summary:hover { background: var(--surface-soft); }
details.crm-collapsible > summary:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: -2px;
  border-radius: var(--radius-lg);
}

.crm-collapsible__head {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.crm-collapsible__title {
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.crm-collapsible__sub {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-faint);
  line-height: 1.2;
}

.crm-collapsible__meta {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* CSS-only chevron */
.crm-collapsible__chevron {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.55rem;
  color: var(--text-faint);
  transition: transform 0.18s ease, background 0.12s ease, color 0.12s ease;
  flex-shrink: 0;
}

details.crm-collapsible[open] .crm-collapsible__chevron {
  transform: rotate(180deg);
  background: var(--primary-soft);
  color: var(--primary);
  border-color: var(--primary);
}

.crm-collapsible__body {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  animation: crm-reveal 0.15s ease forwards;
}

@keyframes crm-reveal {
  from { opacity: 0; transform: translateY(-3px); }
  to   { opacity: 1; transform: translateY(0); }
}


/* =========================================================
   2. Broker Decision Banner
   First element broker sees. Answers "Can I quote this?"
   Four states match quality.label from getRequestQuality().
========================================================= */

.crm-decision-banner {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  background: var(--surface-soft);
  margin-bottom: 12px;
  transition: box-shadow 0.15s ease;
}

.crm-decision-banner:hover { box-shadow: var(--shadow-md); }

.crm-decision-banner--ready {
  border-left-color: var(--success);
  background: var(--success-soft);
}

.crm-decision-banner--usable {
  border-left-color: var(--primary);
  background: var(--primary-soft);
}

.crm-decision-banner--needs-info {
  border-left-color: var(--warning);
  background: var(--warning-soft);
}

.crm-decision-banner--attention {
  border-left-color: var(--danger);
  background: var(--danger-soft);
  animation: crm-attention-pulse 2.4s ease-in-out infinite;
}

@keyframes crm-attention-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.10); }
  50%       { box-shadow: 0 0 0 4px rgba(220, 38, 38, 0); }
}

.crm-decision-banner__icon {
  font-size: 1.4rem;
  line-height: 1;
  flex-shrink: 0;
  padding-top: 1px;
}

.crm-decision-banner__body {
  flex: 1;
  min-width: 160px;
}

.crm-decision-banner__headline {
  font-size: 0.96rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
  margin: 0 0 3px;
}

.crm-decision-banner__sub {
  font-size: 0.82rem;
  color: var(--text-soft);
  line-height: 1.5;
  margin: 0;
}

.crm-decision-banner__gaps {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.crm-decision-banner__gap-pill {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-soft);
  white-space: nowrap;
}

.crm-decision-banner__actions {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  flex-shrink: 0;
}

/* Primary CTA must stand out — slightly larger than density-compressed default */
.crm-decision-banner__actions .btn--primary {
  min-height: 36px;
  font-weight: 700;
  white-space: nowrap;
}

.crm-decision-banner__actions .btn--secondary {
  min-height: 36px;
  white-space: nowrap;
}


/* =========================================================
   3. Fast Facts Grid
   6 shipment signals. Fixed columns prevent auto-fit
   wrapping bug at 901–1280px on 1366×768 screens.
========================================================= */

.crm-fast-facts {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.crm-fast-fact {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 9px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  min-width: 0;
  transition: border-color 0.12s ease;
}

.crm-fast-fact:hover { border-color: var(--primary); }

.crm-fast-fact__label {
  font-size: 0.62rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  line-height: 1;
}

.crm-fast-fact__value {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.25;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.crm-fast-fact__value--missing {
  color: var(--text-faint);
  font-weight: 500;
  font-style: italic;
}


/* =========================================================
   4. Detail Hero Block
========================================================= */

.crm-detail-hero {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.crm-detail-hero__badges {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.crm-detail-hero__age {
  font-size: 0.76rem;
  color: var(--text-faint);
  font-weight: 600;
}

.crm-detail-hero__title {
  margin: 0;
  font-size: 1.2rem;
  line-height: 1.3;
  letter-spacing: -0.02em;
  color: var(--text);
}

.crm-detail-hero__cargo {
  margin: 6px 0 0;
  font-size: 0.86rem;
  color: var(--text-soft);
  line-height: 1.5;
}


/* =========================================================
   5. Section + Panel Wrappers
   Consistent padding. Eliminates the panel > panel__body >
   detail-card triple-nesting (~42px dead space at density).
========================================================= */

.crm-detail-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  background:
    radial-gradient(circle at top left, var(--primary-soft), transparent 32%),
    linear-gradient(180deg, var(--surface) 0%, var(--surface-soft) 100%);
}

.crm-detail-section {
  padding: 14px 20px;
}

.crm-detail-section + .crm-detail-section {
  padding-top: 0;
}


/* =========================================================
   6. Clarification Cards
========================================================= */

.crm-clarification-list {
  display: grid;
  gap: 8px;
}

.crm-clarification-card {
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface-soft);
}

.crm-clarification-card--pending {
  border-left: 3px solid var(--warning);
  background: var(--warning-soft);
}

.crm-clarification-card--responded {
  border-left: 3px solid var(--success);
  background: var(--surface-soft);
}

.crm-clarification-card__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}

.crm-clarification-card__type {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text);
  text-transform: capitalize;
}

.crm-clarification-card__message {
  font-size: 0.84rem;
  line-height: 1.55;
  color: var(--text-soft);
  margin: 0;
}

.crm-clarification-response {
  margin-top: 10px;
  padding: 9px 11px;
  border-radius: var(--radius-md);
  background: var(--surface);
  border: 1px solid var(--border);
}

.crm-clarification-response__label {
  display: block;
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  margin-bottom: 3px;
}

.crm-clarification-response__text {
  font-size: 0.83rem;
  line-height: 1.5;
  color: var(--text-soft);
  margin: 0;
}

.crm-clarification-reply {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}


/* =========================================================
   7. Marketplace Progress Metrics
========================================================= */

.crm-progress-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.crm-progress-metric {
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.crm-progress-metric__label {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-faint);
  line-height: 1;
}

.crm-progress-metric__value {
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1.2;
  color: var(--text);
}

.crm-progress-alert {
  margin-bottom: 10px;
  padding: 10px 12px;
  border: 1px solid var(--danger);
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--danger);
}

.crm-progress-alert strong {
  display: block;
  margin-bottom: 2px;
}

.crm-progress-guidance {
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--text-faint);
  line-height: 1.5;
}


/* =========================================================
   8. Request Quality Bar (admin view)
========================================================= */

.crm-quality-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}

.crm-quality-bar__track {
  flex: 1;
  height: 7px;
  border-radius: var(--radius-pill);
  background: var(--border);
  overflow: hidden;
}

.crm-quality-bar__fill {
  height: 100%;
  border-radius: var(--radius-pill);
  background: var(--primary);
  transition: width 0.3s ease;
}

.crm-quality-bar__fill--high  { background: var(--success); }
.crm-quality-bar__fill--mid   { background: var(--primary); }
.crm-quality-bar__fill--low   { background: var(--warning); }

.crm-quality-score {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--text);
  white-space: nowrap;
}

.crm-quality-gaps {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-top: 6px;
}


/* =========================================================
   9. Customer Trust Card
========================================================= */

.crm-trust-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  margin-bottom: 8px;
}

.crm-trust-cell {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.crm-trust-cell__label {
  font-size: 0.68rem;
  color: var(--text-faint);
  font-weight: 600;
}

.crm-trust-cell__value {
  font-size: 0.84rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.crm-contact-hidden {
  font-size: 0.78rem;
  color: var(--text-faint);
  font-style: italic;
  margin: 4px 0 0;
  line-height: 1.4;
}


/* =========================================================
   10. Original Request Description
========================================================= */

.crm-inquiry-description {
  margin-top: 6px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-soft);
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
  line-height: 1.6;
  font-size: 0.86rem;
  color: var(--text-soft);
  box-shadow: inset 0 1px 4px rgba(15, 23, 42, 0.04);
}

.crm-inquiry-description::-webkit-scrollbar { width: 4px; }
.crm-inquiry-description::-webkit-scrollbar-track { background: transparent; }
.crm-inquiry-description::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 999px;
}

.crm-description-signals {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}


/* =========================================================
   11. Badge Hierarchy Modifier
   Quiets secondary badges without touching .status base.
========================================================= */

.crm-badge--secondary {
  opacity: 0.72;
  filter: saturate(0.75);
  font-size: 0.68rem !important;
}

.crm-badge--age {
  background: transparent !important;
  border: none !important;
  color: var(--text-faint) !important;
  font-size: 0.74rem !important;
  padding: 0 !important;
  min-height: auto !important;
  font-weight: 600;
}


/* =========================================================
   12. Customer Status Banner
========================================================= */

.crm-customer-status {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  background: var(--primary-soft);
  margin-bottom: 12px;
}

.crm-customer-status--needs-action {
  border-left-color: var(--warning);
  background: var(--warning-soft);
}

.crm-customer-status--complete {
  border-left-color: var(--success);
  background: var(--success-soft);
}

.crm-customer-status__body {
  flex: 1;
  min-width: 160px;
}

.crm-customer-status__headline {
  font-size: 0.94rem;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 3px;
}

.crm-customer-status__sub {
  font-size: 0.82rem;
  color: var(--text-soft);
  line-height: 1.5;
  margin: 0;
}

.crm-customer-status__badge {
  flex-shrink: 0;
  align-self: center;
}


/* =========================================================
   13. 1366×768 Density Overrides
========================================================= */

@media (min-width: 901px) and (max-width: 1400px) {

  .crm-detail-hero { padding: 12px 16px; }
  .crm-detail-hero__title { font-size: 1.05rem; }
  .crm-detail-hero__cargo { font-size: 0.78rem; margin-top: 4px; }
  .crm-detail-hero__badges { gap: 5px; margin-bottom: 6px; }

  .crm-decision-banner {
    padding: 11px 13px;
    gap: 10px;
    margin-bottom: 10px;
    border-radius: var(--radius-md);
  }
  .crm-decision-banner__icon { font-size: 1.2rem; }
  .crm-decision-banner__headline { font-size: 0.86rem; }
  .crm-decision-banner__sub { font-size: 0.76rem; }
  .crm-decision-banner__gap-pill { font-size: 0.62rem; padding: 2px 6px; }
  .crm-decision-banner__gaps { margin-top: 6px; gap: 3px; }
  .crm-decision-banner__actions .btn--primary,
  .crm-decision-banner__actions .btn--secondary {
    min-height: 30px;
    font-size: 0.74rem;
    padding: 0 10px;
  }

  /* 3 cols on density screens — 6 is unreadable */
  .crm-fast-facts {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    padding: 10px 14px;
    gap: 6px;
  }
  .crm-fast-fact { padding: 7px 9px; gap: 2px; border-radius: var(--radius-sm); }
  .crm-fast-fact__label { font-size: 0.56rem; }
  .crm-fast-fact__value { font-size: 0.74rem; }

  details.crm-collapsible > summary { padding: 9px 13px; font-size: 0.8rem; }
  .crm-collapsible__title { font-size: 0.8rem; }
  .crm-collapsible__sub { font-size: 0.66rem; }
  .crm-collapsible__body { padding: 10px 13px; }
  .crm-collapsible__chevron { width: 17px; height: 17px; font-size: 0.5rem; }

  .crm-detail-section { padding: 10px 14px; }

  .crm-clarification-card { padding: 9px 11px; border-radius: var(--radius-md); }
  .crm-clarification-card__type { font-size: 0.74rem; }
  .crm-clarification-card__message { font-size: 0.76rem; }
  .crm-clarification-response { padding: 7px 9px; margin-top: 7px; }
  .crm-clarification-response__text { font-size: 0.74rem; }

  .crm-progress-metrics {
    gap: 6px;
    margin-top: 8px;
    grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  }
  .crm-progress-metric { padding: 7px 9px; gap: 2px; }
  .crm-progress-metric__label { font-size: 0.54rem; }
  .crm-progress-metric__value { font-size: 0.94rem; }
  .crm-progress-alert { padding: 8px 10px; font-size: 0.78rem; margin-bottom: 8px; }
  .crm-progress-guidance { font-size: 0.7rem; margin-top: 7px; }

  .crm-quality-bar__track { height: 6px; }
  .crm-quality-score { font-size: 0.8rem; }

  .crm-trust-cell__label { font-size: 0.6rem; }
  .crm-trust-cell__value { font-size: 0.76rem; }

  .crm-inquiry-description {
    padding: 10px 12px;
    font-size: 0.78rem;
    max-height: 200px;
    margin-top: 4px;
  }

  .crm-customer-status { padding: 10px 12px; gap: 10px; margin-bottom: 10px; }
  .crm-customer-status__headline { font-size: 0.84rem; }
  .crm-customer-status__sub { font-size: 0.74rem; }
}


/* =========================================================
   14. Mobile — below 900px
========================================================= */

@media (max-width: 900px) {
  .crm-fast-facts {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    padding: 10px 12px;
    gap: 6px;
  }
  .crm-decision-banner {
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
  }
  .crm-decision-banner__actions {
    width: 100%;
    justify-content: flex-start;
  }
  .crm-progress-metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .crm-detail-hero { padding: 12px 14px; }
  .crm-detail-section { padding: 10px 12px; }
  .crm-customer-status { flex-direction: column; gap: 8px; }
}

@media (max-width: 560px) {
  .crm-fast-facts {grid-template-columns: repeat(2, minmax(0, 1fr));}
  .crm-progress-metrics { grid-template-columns: 1fr; }
  .crm-trust-grid { grid-template-columns: 1fr; }
}


/* =========================================================
   Quote Card — Clickable Surface
   overlay-link already exists in quotations.css but missing
   cursor:pointer, making the card feel unclickable on hover.
   Also ensures the article itself signals interactivity.
========================================================= */

.quote-card {
  cursor: pointer;
}

.quote-card__overlay-link {
  cursor: pointer;
}


/* =========================================================
   Quote Detail Lifecycle Strip
   Replaces bulky sticky step cards with a compact progress strip.
========================================================= */

.quote-lifecycle-strip details summary::-webkit-details-marker {
  display: none;
}

.quote-lifecycle-strip details[open] summary {
  color: var(--primary);
}

.quote-lifecycle-strip details {
  z-index: 20;
}

.quote-lifecycle-strip details > div {
  position: absolute;
  right: 0;
}

@media (max-width: 900px) {
  .quote-lifecycle-strip details > div {
    position: static;
  }
}


/* =========================================================
   Quote Stage Stepper — Responsive swap
   >900px: full card grid (stepper-desktop visible)
   ≤900px: compact dot-line (stepper-mobile visible)
   The desktop layout keeps overflow-x:auto as a deliberate
   fallback for narrow embedded contexts (modals, iframes).
========================================================= */

.stepper-desktop { display: block; }
.stepper-mobile  { display: none;  }

@media (max-width: 900px) {
  .stepper-desktop { display: none; }
  .stepper-mobile  { display: block !important; }
}