/* =========================================================================
   views/leads.css — Leads — companies table, Gmail-style star column, kanban board
   Split from the old monolithic styles/views.css. LOAD ORDER MATTERS:
   the <link> order in Magnet CRM.html / Client App.html reproduces the
   original file order, so the cascade is unchanged — add new rules to the
   matching feature file, not the end of the list.
   ========================================================================= */
/* ============================ COMPANIES TABLE ========================== */
/* The table fills the available height; #viewScroll handles overflow and the
   leads list reveals rows in batches as you scroll (infinite scroll), so there
   is no pager. */
.table-wrap { padding: var(--space-5) var(--space-6) var(--space-6); display: flex; flex-direction: column; min-height: 100%; }
.table-card {
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  overflow: hidden; background: var(--surface);
  flex: 1 1 auto;   /* fill the wrap's height — never a short floating card */
}
/* empty: header sits at top, the empty state flex-fills the rest of the card
   and centres its illustration */
.table-card.is-empty { display: flex; flex-direction: column; }
.table-card.is-empty .ctable { flex: 0 0 auto; }
.table-card.is-empty .empty-state { flex: 1 1 auto; min-height: 0; }
.ctable { width: 100%; border-collapse: collapse; table-layout: fixed; }
/* infinite scroll: rows past the current batch stay hidden until revealed */
.ctable tbody tr.lead-hidden { display: none; }
.ctable th, .ctable td { text-align: left; padding: 0 var(--space-5); }
.ctable thead th {
  height: 48px; background: var(--surface-sunk);
  font-size: var(--text-sm); font-weight: var(--fw-semibold); color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.ctable .th-inner { display: inline-flex; align-items: center; gap: var(--space-2); }
.ctable .sort-ico {
  display: inline-flex; color: var(--text-soft); cursor: pointer;
  width: 22px; height: 22px; border-radius: var(--radius-xs);
  align-items: center; justify-content: center;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
@media (hover: hover) and (pointer: fine) {
  .ctable .sort-ico:hover { background: var(--gray-150); color: var(--text); }
}
.ctable .sort-ico svg { width: 15px; height: 15px; }
.ctable tbody td { height: 66px; border-bottom: 1px solid var(--border); font-size: var(--text-md); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* default text cells (email, source, custom form fields like "Service") clip
   with an ellipsis instead of wrapping into the next row */
.ctable tbody td.email-cell, .ctable tbody td.source-cell, .ctable tbody td.field-cell { color: var(--text-muted); }
.ctable tbody tr:last-child td { border-bottom: none; }
.ctable tbody tr { transition: background var(--dur) var(--ease), border-color var(--dur) var(--ease), box-shadow var(--dur) var(--ease), transform var(--dur) var(--ease); }
.ctable tbody tr.selected { background: var(--surface-hover); }
@media (hover: hover) and (pointer: fine) {
  .ctable tbody tr:hover { background: var(--surface-hover); }
  .ctable tbody tr.selected:hover { background: var(--surface-hover-strong); }
}

.col-check { width: 30px; padding-right: 0 !important; }
.company-cell { display: flex; align-items: center; gap: var(--space-3); }
.company-cell .name { font-weight: var(--fw-semibold); color: var(--text-strong); white-space: nowrap; }
.contact-cell { display: flex; align-items: center; gap: var(--space-3); }
.contact-cell .name { color: var(--text); font-weight: var(--fw-medium); }
.position-cell { color: var(--text-muted); }
.date-cell { color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.phone-cell { color: var(--text-muted); font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.business-cell { color: var(--text-strong); font-weight: var(--fw-semibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.contact-cell { min-width: 0; }
.contact-cell .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.col-actions { text-align: center; }
.col-actions .th-inner { justify-content: center; }
.ctable th.col-actions, .ctable td.col-actions { padding: 0 12px; }
.ctable td.col-actions { text-align: center; }
.ctable td.col-actions .kebab { margin: 0 auto; }
/* ---------- Gmail-style star column (leadStars.js) -----------------------
   Always-on, narrow, anchored to the left of each lead row. Empty outline by
   default (subtle text-soft); fills yellow on click. Hover ring mimics
   Gmail's 36px focus circle. text-align needs the .ctable td selector to win
   the specificity fight against the global ".ctable th, .ctable td { text-align:
   left }" — without it the star left-aligns and the right padding looks much
   bigger than the left.
------------------------------------------------------------------------- */
.ctable th.col-star, .ctable td.col-star { padding: 0 4px; text-align: center; }
.ctable th.col-star .th-inner { justify-content: center; }
.lead-star {
  position: relative;
  display: inline-flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  margin: 0 auto;
  border: 0; background: transparent; border-radius: 50%;
  color: var(--text-soft); cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}
.lead-star svg { width: 18px; height: 18px; }
@media (hover: hover) and (pointer: fine) {
  .lead-star:hover { background: var(--gray-50); color: var(--text); }
}
.lead-star:active { transform: scale(0.92); }
.lead-star.is-on { color: #f5b400; }   /* Gmail yellow */
.lead-star.is-on svg path { fill: currentColor; }
/* "Starred only" option in the leads Filter menu — gold filled star + label */
.filter-opt .opt-star { display: inline-flex; align-items: center; gap: 8px; }
.filter-opt .opt-star svg { width: 16px; height: 16px; color: #f5b400; }
.filter-opt .opt-star svg path { fill: currentColor; }
.status-cell { display: inline-flex; align-items: center; gap: var(--space-2); max-width: 100%; min-width: 0; }
.status-td { overflow: hidden; }
.status-td .due-chip { flex-shrink: 0; }
.stage-trigger {
  display: inline-flex; align-items: center; gap: 5px; padding: 4px 6px 4px 4px;
  border: none; background: transparent; border-radius: var(--radius-sm); cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}
@media (hover: hover) and (pointer: fine) {
  .stage-trigger:hover { background: var(--surface-hover-strong); }
}
.stage-trigger > svg { width: 14px; height: 14px; color: var(--text-soft); }
.due-chip {
  display: inline-flex; align-items: center; height: 20px; padding: 0 8px;
  border-radius: var(--radius-full); font-size: var(--text-2xs); font-weight: var(--fw-semibold);
  color: var(--primary-700); background: var(--primary-50); white-space: nowrap;
}
/* the chip is a real button now (click → set/change the follow-up date) */
button.due-chip { border: 0; font-family: inherit; cursor: pointer; }
.due-chip--soon { color: var(--on-primary); background: var(--primary-600); }
/* past due — red, unmissable */
.due-chip--overdue { color: #fff; background: var(--danger-600); }
/* honest empty state — no stored date, nothing fabricated */
.due-chip--none { color: var(--text-soft); background: transparent; box-shadow: inset 0 0 0 1px var(--border-strong); }
@media (hover: hover) and (pointer: fine) {
  button.due-chip:hover { filter: brightness(0.96); }
  button.due-chip--none:hover { filter: none; background: var(--surface-hover-strong); color: var(--text); }
}

/* pagination */
.pagination {
  display: flex; align-items: center; gap: var(--space-4);
  padding: var(--space-4) var(--space-6);
}
.pager { display: flex; align-items: center; gap: 4px; }
.pager button {
  min-width: 36px; height: 36px; padding: 0 8px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: var(--radius-sm); color: var(--text-muted);
  font-size: var(--text-md); font-weight: var(--fw-medium);
  border: 1px solid transparent;
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.pager button svg { width: 16px; height: 16px; }
@media (hover: hover) and (pointer: fine) {
  .pager button:hover:not(.active):not(:disabled) { background: var(--gray-100); color: var(--text); }
}
.pager button.active { background: var(--primary-600); color: var(--on-primary); }
.pager button:disabled { opacity: 0.4; cursor: default; }
.pagination .right { margin-left: auto; display: flex; align-items: center; gap: var(--space-3); color: var(--text-muted); font-size: var(--text-md); }
.per-page {
  display: inline-flex; align-items: center; gap: var(--space-2);
  height: 36px; padding: 0 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-weight: var(--fw-medium);
  cursor: pointer; transition: border-color var(--dur) var(--ease);
}
@media (hover: hover) and (pointer: fine) {
  .per-page:hover { border-color: var(--border-strong); }
}
.per-page svg { width: 15px; height: 15px; color: var(--text-soft); }

/* bulk-select floating toolbar */
.bulk-toolbar {
  position: absolute; left: 50%; bottom: 78px; transform: translateX(-50%) translateY(8px);
  z-index: var(--z-toolbar);
  width: min(620px, calc(100% - 96px));
  background: var(--overlay-dark); color: #fff;
  border-radius: var(--radius-lg); box-shadow: var(--shadow-pop);
  padding: var(--space-4);
  opacity: 0; pointer-events: none;
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease);
}
.bulk-toolbar.show { opacity: 1; pointer-events: auto; transform: translateX(-50%) translateY(0); }
.bulk-top { display: flex; align-items: center; gap: var(--space-3); }
.bulk-top .count { font-size: var(--text-md); font-weight: var(--fw-semibold); }
.bulk-top .tools { margin-left: auto; display: flex; align-items: center; gap: var(--space-1); }
.bulk-tool {
  width: 34px; height: 34px; border-radius: var(--radius-sm);
  display: inline-flex; align-items: center; justify-content: center;
  color: rgba(255,255,255,0.82);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease);
}
@media (hover: hover) and (pointer: fine) {
  .bulk-tool:hover { background: rgba(255,255,255,0.12); color: #fff; }
}
.bulk-tool svg { width: 18px; height: 18px; }
.bulk-tool.danger { color: #ff8088; gap: 6px; width: auto; padding: 0 10px; font-size: var(--text-sm); font-weight: var(--fw-medium); }
@media (hover: hover) and (pointer: fine) {
  .bulk-tool.danger:hover { background: rgba(229,72,77,0.16); color: #ff9ba1; }
}
.bulk-sep { width: 1px; height: 22px; background: rgba(255,255,255,0.16); margin: 0 4px; }
.bulk-close { color: rgba(255,255,255,0.7); }
.bulk-actions { display: flex; gap: var(--space-3); margin-top: var(--space-4); }
.bulk-actions button {
  flex: 1; height: 44px; border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  background: rgba(255,255,255,0.08); color: #fff;
  font-size: var(--text-md); font-weight: var(--fw-medium);
  border: 1px solid rgba(255,255,255,0.08);
  transition: background var(--dur) var(--ease);
}
.bulk-actions button svg { width: 18px; height: 18px; }
@media (hover: hover) and (pointer: fine) {
  .bulk-actions button:hover { background: rgba(255,255,255,0.16); }
}

/* ============================ DEALS KANBAN ============================ */
.kanban { display: flex; gap: 22px; padding: var(--space-5) var(--space-6) 0; align-items: stretch; min-height: 100%; }

/* Column lane — light grey track that groups cards under a status.
   Stretches to the full board height so short lanes still run to the bottom. */
.kcol {
  flex: 1; min-width: 0; max-width: none;
  display: flex; flex-direction: column; gap: 10px;
  align-self: stretch;
  background: var(--surface-lane);
  border: none;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  padding: 11px;
}

/* Column header — flat, short, integrated into the lane */
.kcol-head {
  display: flex; align-items: center; gap: 7px;
  height: 30px; padding: 0 2px 8px;
  margin-bottom: 1px;
}
.kcol-head .grip { color: var(--gray-400); display: inline-flex; cursor: grab; }
.kcol-head .grip svg { width: 14px; height: 14px; }
.kcol-head .bar { width: 3px; height: 14px; border-radius: 2px; }
.kcol-head .title { font-size: var(--text-md); font-weight: var(--fw-semibold); color: var(--text-strong); }
.kcol-head .chip-count {
  margin-left: auto; min-width: 0; height: auto; padding: 0;
  background: none; color: var(--text-soft); font-size: var(--text-sm); font-weight: var(--fw-semibold);
}
.kcol[data-stage="Leads"]     .bar { background: var(--stage-leads); }
.kcol[data-stage="Discovery"] .bar { background: var(--stage-discovery); }
.kcol[data-stage="Demo"]      .bar { background: var(--stage-demo); }
.kcol[data-stage="Won"]       .bar { background: var(--stage-won); }
.kcol[data-stage="Lead"]      .bar { background: var(--stage-leads); }
.kcol[data-stage="Follow Up"] .bar { background: var(--stage-discovery); }
.kcol[data-stage="Consult"]   .bar { background: var(--stage-demo); }
.kcol[data-stage="Closed"]    .bar { background: var(--stage-won); }

/* mobile: board scrolls horizontally — one column at a time */
@media (max-width: 640px) {
  #viewScroll > .kanban {
    overflow-x: auto; -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    scroll-padding-inline: max(var(--space-4), var(--safe-left));
    padding: var(--space-4) max(var(--space-4), var(--safe-left)) 0;
  }
  #viewScroll > .kanban > .kcol {
    flex: 0 0 82%; min-width: 0; scroll-snap-align: start;
  }
}

/* Card — compact, white, subtle border, soft shadow */
.kcard {
  background: var(--surface); border: 1px solid var(--border-faint);
  border-radius: var(--radius-md); padding: 12px;
  box-shadow: var(--shadow-xs); cursor: grab;
  transition: box-shadow var(--dur) var(--ease), border-color var(--dur) var(--ease), transform var(--dur) var(--ease);
}
@media (hover: hover) and (pointer: fine) {
  .kcard:hover { box-shadow: var(--shadow-sm); border-color: var(--border-strong); transform: translateY(-1px); }
}
.kcard .badges { display: flex; gap: 6px; margin-bottom: 10px; }
.kcard .deal-title { display: flex; align-items: center; gap: 8px; font-size: var(--text-md); font-weight: var(--fw-semibold); color: var(--text-strong); min-width: 0; }
.kcard .deal-title span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* small fallback brand mark inside cards */
.kcard .deal-title .logo { width: 20px; height: 20px; font-size: 10px; border-radius: var(--radius-xs); }
.kcard .deal-desc {
  margin-top: 7px; font-size: var(--text-sm); color: var(--text-muted); line-height: var(--leading-snug);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kcard .deal-foot {
  display: flex; align-items: center; gap: var(--space-2);
  margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--border-faint);
  font-size: var(--text-sm); white-space: nowrap; flex-wrap: nowrap;
}
.kcard .deal-foot .amount { font-weight: var(--fw-semibold); color: var(--text-strong); white-space: nowrap; }
.kcard .deal-foot .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--gray-400); flex-shrink: 0; }
.kcard .deal-foot .date { color: var(--text-soft); white-space: nowrap; }

/* dashed divider above the Add Task button — slim dashes, sits in normal
   flow directly after the last card (not pinned to the lane bottom). */
.lane-divider {
  height: 1px; margin: 1px 0; border: none;
  background-image: repeating-linear-gradient(to right, var(--border-strong) 0 7px, transparent 7px 13px);
}

/* Add Task — quiet soft placeholder */
.add-task {
  width: 100%; height: 40px; border-radius: var(--radius-md);
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  border: 1px dashed var(--border-strong); background: var(--surface-field);
  color: var(--text-muted); font-size: var(--text-sm); font-weight: var(--fw-medium);
  transition: background var(--dur) var(--ease), color var(--dur) var(--ease), border-color var(--dur) var(--ease);
}
.add-task svg { width: 16px; height: 16px; }
.add-task span { white-space: nowrap; }
@media (hover: hover) and (pointer: fine) {
  .add-task:hover { background: var(--gray-100); color: var(--text); border-color: var(--gray-400); }
}

/* lead card footer (Leads board). min-width:0 + a truncating name keep the
   due-chip INSIDE the card on narrow columns (flex children never shrink
   nowrap content by default, so the chip used to poke past the card edge);
   wrap is the last-resort fallback for ultra-narrow cards. */
.kcard .lead-foot { display: flex; align-items: center; gap: var(--space-2); margin-top: 11px; padding-top: 10px; border-top: 1px solid var(--border-faint); font-size: var(--text-sm); min-width: 0; flex-wrap: wrap; row-gap: 4px; }
.kcard .lead-foot .avatar { width: 22px; height: 22px; font-size: 9px; flex: none; }
.kcard .lead-foot .lname { color: var(--text-muted); font-weight: var(--fw-medium); flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kcard .lead-foot .due-chip { margin-left: auto; flex: none; max-width: 100%; }

/* board drag-and-drop */
.kcard.is-dragging { opacity: 0.45; cursor: grabbing; }
.kcol.drag-over {
  background: var(--surface-hover-strong);
  border-radius: var(--radius-md);
  box-shadow: inset 0 0 0 2px var(--primary-300);
}
