/* Module: sections 06-09 of automation 02 (WhatsApp CRM).
   #features, #dashboard, #stack and #industries. Every rule is scoped under its section id,
   every invented class starts with crm-. Frames and copy reuse features.css and dashboard.css. */

/* ---------- 07 / Pipeline: layout around the frame ---------- */

#dashboard .crm-dash-main {
  min-width: 0;
}

/* Phone and tablet: one column, side blocks under the board.
   1024 and up: main | side (240px). 1280 and up: rail | main | side. */
#dashboard .crm-dash-body {
  display: block;
}

@media (min-width: 1024px) {
  #dashboard .crm-dash-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 240px;
  }
}

@media (min-width: 1280px) {
  #dashboard .crm-dash-body {
    grid-template-columns: 144px minmax(0, 1fr) 264px;
  }
}

@media (min-width: 1440px) {
  #dashboard .crm-dash-body {
    grid-template-columns: 168px minmax(0, 1fr) 288px;
  }
}

/* Stat labels wrap rather than truncate: the strip is narrower than the stat copy at 1024 */
#dashboard .crm-dash .dashboard-stat-l,
#dashboard .crm-dash .dashboard-stat-s {
  white-space: normal;
}

#dashboard .crm-dash .dashboard-stat-l {
  text-wrap: balance;
}

#dashboard .crm-dash .dashboard-toolbar {
  padding-bottom: 16px;
}

/* The footer keeps its "Synced from HubSpot" line on phones too */
#dashboard .crm-dash .dashboard-foot-sync {
  display: inline;
}

/* ---------- Pipeline board ---------- */

#dashboard .crm-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

#dashboard .crm-col {
  min-width: 0;
  padding: 14px 10px 16px;
  border-left: 1px solid var(--line-soft);
}

#dashboard .crm-col:first-child {
  border-left: 0;
}

#dashboard .crm-col-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 12px;
  min-width: 0;
}

#dashboard .crm-col-name {
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ash);
}

#dashboard .crm-col-count {
  flex: none;
  font-family: var(--font-display);
  font-size: 1.125rem;
  font-weight: 500;
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--bone);
}

#dashboard .crm-col-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

#dashboard .crm-card {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 10px 10px 9px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
}

#dashboard .crm-card--fresh {
  border-color: var(--accent-40);
}

#dashboard .crm-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 0;
}

#dashboard .crm-card-name {
  min-width: 0;
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -0.01em;
  color: var(--bone);
  white-space: nowrap;
  text-overflow: ellipsis;
}

#dashboard .crm-owner {
  display: grid;
  place-items: center;
  flex: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--elev);
  font-family: var(--font-display);
  font-size: 11px;
  line-height: 1;
  letter-spacing: 0;
  color: var(--bone);
}

#dashboard .crm-owner--none {
  background: transparent;
  border-style: dashed;
  font-size: 13px;
  color: var(--ash);
}

#dashboard .crm-card-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

/* Square mono chips, as on the rest of the site */
#dashboard .crm-score,
#dashboard .crm-badge {
  display: inline-block;
  padding: 2px 6px 3px;
  border: 1px solid var(--line);
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.4;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
  color: var(--ash);
}

#dashboard .crm-score--hot {
  border-color: var(--accent-40);
  color: var(--accent);
}

#dashboard .crm-score--warm {
  color: var(--bone-70);
}

#dashboard .crm-score--cold {
  color: var(--ash);
}

#dashboard .crm-score--won {
  border-color: var(--ok);
  color: var(--ok);
}

#dashboard .crm-badge--ok {
  border-color: var(--ok);
  background: var(--ok-20);
  color: var(--ok);
}

/* ---------- Side column: leaderboard and lead sources ---------- */

#dashboard .crm-side {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  border-top: 1px solid var(--line);
}

#dashboard .crm-side > .dashboard-side-block {
  min-width: 0;
}

#dashboard .crm-side > .dashboard-side-block + .dashboard-side-block {
  border-top: 0;
  border-left: 1px solid var(--line);
}

#dashboard .crm-side .dashboard-h {
  white-space: normal;
  text-wrap: balance;
}

@media (min-width: 1024px) {
  #dashboard .crm-side {
    display: block;
    border-top: 0;
    border-left: 1px solid var(--line);
  }

  #dashboard .crm-side > .dashboard-side-block + .dashboard-side-block {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 639px) {
  #dashboard .crm-side {
    grid-template-columns: minmax(0, 1fr);
  }

  #dashboard .crm-side > .dashboard-side-block + .dashboard-side-block {
    border-left: 0;
    border-top: 1px solid var(--line);
  }
}

#dashboard .crm-bars {
  display: grid;
  gap: 16px;
  margin: 0;
  padding: 0 20px 20px;
  list-style: none;
}

#dashboard .crm-bar-row {
  display: grid;
  gap: 8px;
  min-width: 0;
}

#dashboard .crm-bar-top {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  min-width: 0;
}

#dashboard .crm-bar-name {
  min-width: 0;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.3;
  color: var(--bone-80);
  white-space: nowrap;
  text-overflow: ellipsis;
}

#dashboard .crm-bar-val {
  flex: none;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.4;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ash);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

#dashboard .crm-bar-track {
  display: block;
  height: 4px;
  background: var(--line);
}

#dashboard .crm-bar-fill {
  display: block;
  height: 100%;
  width: var(--w);
  background: var(--bone-50);
}

#dashboard .crm-bar-fill--gold {
  background: var(--accent);
}

#dashboard .crm-caption {
  margin: 0;
  padding: 0 20px 18px;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--ash);
}

/* ---------- Entrance: Daniel's card slides into Viewing booked, Hot leads 8 to 9 ----------
   Finished state is the HTML. crm-sections.js adds these only when the section is seen. */

#dashboard .crm-card--pending {
  opacity: 0;
  transform: translate3d(-14px, 0, 0);
}

#dashboard .crm-card--in {
  animation: crm-slide-in 0.7s var(--ease-out) both, crm-flash 2.4s ease-out both;
}

@keyframes crm-slide-in {
  from {
    opacity: 0;
    transform: translate3d(-14px, 0, 0);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes crm-flash {
  0% {
    border-color: var(--accent);
  }
  100% {
    border-color: var(--accent-40);
  }
}

@media (prefers-reduced-motion: reduce) {
  #dashboard .crm-card--pending {
    opacity: 1;
    transform: none;
  }

  #dashboard .crm-card--in {
    animation: none;
  }
}

/* ---------- Pipeline: phone, one column of stacked groups ---------- */

@media (max-width: 1023px) {
  #dashboard .crm-board {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 639px) {
  #dashboard .crm-board {
    grid-template-columns: minmax(0, 1fr);
  }

  /* Each column is a hairline group: name and count on one line, then its cards */
  #dashboard .crm-col {
    padding: 14px 14px 16px;
    border-left: 0;
    border-top: 1px solid var(--line);
  }

  #dashboard .crm-col:first-child {
    border-top: 0;
  }

  #dashboard .crm-col-head {
    margin-bottom: 10px;
  }

  #dashboard .crm-col-name {
    font-size: 13px;
  }

  #dashboard .crm-card {
    padding: 12px 12px 11px;
  }

  #dashboard .crm-card-name {
    font-size: 16px;
  }
}

/* ---------- 08 / Stack: seven tools on hairlines ----------
   Each cell draws its own hairlines, so any column count works. The grid is 7 wide at
   1280 and up, 4 wide (4 + 3) from 1024, 2 wide from 640 and 1 wide below that. */

#stack .crm-stack {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

#stack .crm-stack > * {
  min-width: 0;
  padding: 28px 24px;
  border-left: 0;
  border-top: 0;
}

@media (min-width: 1280px) {
  #stack .crm-stack {
    grid-template-columns: repeat(7, minmax(0, 1fr));
  }

  #stack .crm-stack > *:nth-child(n + 2) {
    border-left: 1px solid var(--line);
  }
}

@media (min-width: 1024px) and (max-width: 1279px) {
  #stack .crm-stack > *:nth-child(4n + 2),
  #stack .crm-stack > *:nth-child(4n + 3),
  #stack .crm-stack > *:nth-child(4n + 4) {
    border-left: 1px solid var(--line);
  }

  #stack .crm-stack > *:nth-child(n + 5) {
    border-top: 1px solid var(--line);
  }
}

@media (min-width: 640px) and (max-width: 1023px) {
  #stack .crm-stack {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #stack .crm-stack > *:nth-child(2n) {
    border-left: 1px solid var(--line);
  }

  #stack .crm-stack > *:nth-child(n + 3) {
    border-top: 1px solid var(--line);
  }
}

@media (max-width: 639px) {
  #stack .crm-stack {
    grid-template-columns: minmax(0, 1fr);
  }

  #stack .crm-stack > *:nth-child(n + 2) {
    border-top: 1px solid var(--line);
  }

  /* One tool per row, same 64px line as the other stack rows. The role wraps in its own
     share of the row so long names ("WhatsApp Cloud API") never run under it. */
  #stack .crm-stack > * {
    padding: 12px 20px;
    min-height: 64px;
  }

  #stack .crm-stack .features-tool-n {
    flex: 1 1 0;
    min-width: 0;
  }

  #stack .crm-stack .features-tool-r {
    flex: 0 1 42%;
    margin-left: 12px;
    white-space: normal;
    line-height: 1.5;
  }
}
