/* css/page-contacts.css — page-scoped styles for the Contacts page
 * (js/pages/contacts.js). Owned by the Contacts page agent; add rules here so
 * page work never touches shared main.css / chrome.css / datatable.css.
 *
 * Table chrome, badges, drawer shell, and form controls come from the shared
 * stylesheets; this file only styles the contact-specific bits: the create
 * form grid and the detail drawer's sections (header, deals, activities,
 * notes). Accent is var(--color-primary) (indigo). */

/* ── Name cell: subtle emphasis + pointer (rows open the detail drawer) ── */
.ct-name {
  font-weight: 600;
  color: var(--color-text);
}

/* ── Create form: two-column field grid ── */
.contact-form .cf-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 var(--spacing-md);
}
.contact-form .cf-grid .form-group,
.contact-form > .form-group {
  margin-bottom: var(--spacing-md);
}

/* ── Detail drawer ── */
.contact-detail {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-lg);
}

.cd-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--spacing-md);
  padding-bottom: var(--spacing-md);
  border-bottom: 1px solid var(--border-color);
}
.cd-name {
  margin: 0 0 0.15rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-text);
}
.cd-sub {
  font-size: 0.875rem;
  color: var(--color-text-secondary);
}
.cd-sub-at {
  opacity: 0.55;
  padding: 0 0.15rem;
}
.cd-header-side {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
  flex-shrink: 0;
}
.cd-linkedin-link {
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-primary);
  white-space: nowrap;
}

/* ── Sections ── */
.cd-section {
  display: block;
}
.cd-section-title {
  margin: 0 0 var(--spacing-sm);
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--color-text-secondary);
}
.cd-count {
  display: inline-block;
  min-width: 1.1rem;
  padding: 0 0.35rem;
  margin-left: 0.25rem;
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text-muted);
  font-size: 0.6875rem;
  font-weight: 700;
  text-align: center;
  letter-spacing: 0;
}
.cd-empty {
  font-size: 0.875rem;
  margin: 0;
  padding: 0.25rem 0;
}

/* Details inline-edit grid */
.cd-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 var(--spacing-md);
}
.cd-grid .form-group {
  margin-bottom: var(--spacing-sm);
}
.cd-grid .form-label {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
  margin-bottom: 0.15rem;
}
.cd-field-full {
  grid-column: 1 / -1;
}

/* ── Deals ── */
.cd-deal {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-md);
  padding: 0.55rem 0.65rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 0.4rem;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.cd-deal:hover {
  background: var(--bg-secondary);
  border-color: var(--color-primary);
}
.cd-deal-main {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
}
.cd-deal-title {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--color-text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cd-deal-stage {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.cd-deal-meta {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex-shrink: 0;
}
.cd-deal-value {
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--color-text);
}
.cd-status {
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-secondary);
  color: var(--text-muted);
}
.cd-status-open  { background: #bee3f8; color: #2b6cb0; }
.cd-status-won   { background: #c6f6d5; color: #22543d; }
.cd-status-lost  { background: #fed7d7; color: #742a2a; }
.cd-status-hold  { background: #fef3c7; color: #92400e; }

/* ── Activities ── */
.cd-logact {
  display: grid;
  grid-template-columns: minmax(90px, 0.7fr) 2fr minmax(130px, 1fr) auto;
  gap: 0.4rem;
  align-items: center;
  margin-bottom: var(--spacing-sm);
}
.cd-logact .form-select,
.cd-logact .form-input {
  margin: 0;
}
.cd-act {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.4rem 0;
  border-bottom: 1px solid var(--border-color);
  cursor: pointer;
}
.cd-act:last-child { border-bottom: none; }
.cd-act-done {
  margin-top: 0.15rem;
  flex-shrink: 0;
}
.cd-act-body {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}
.cd-act-subject {
  font-size: 0.875rem;
  color: var(--color-text);
}
.cd-act-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.cd-act-done-line .cd-act-subject {
  text-decoration: line-through;
  color: var(--text-muted);
}

/* ── Notes ── */
.cd-note-add {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.4rem;
  margin-bottom: var(--spacing-sm);
}
.cd-note-add .form-textarea {
  width: 100%;
  min-height: 3.5rem;
  margin: 0;
}
.cd-note {
  padding: 0.5rem 0.65rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  margin-bottom: 0.4rem;
  background: var(--bg-primary);
}
.cd-note-content {
  font-size: 0.875rem;
  color: var(--color-text);
  white-space: pre-wrap;
  line-height: 1.4;
}
.cd-note-meta {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* ── Narrow drawers / mobile ── */
@media (max-width: 640px) {
  .contact-form .cf-grid,
  .cd-grid {
    grid-template-columns: 1fr;
  }
  .cd-logact {
    grid-template-columns: 1fr 1fr;
  }
}

/* ══════════════════════════════════════════════════════════════════════
 * View toggle + Board / Charts / Map (mirrors page-pipeline.css). The
 * shared .kanban-* card/column styles live in page-pipeline.css (loaded
 * globally); only the contact-specific card content + chart/map shells here.
 * ════════════════════════════════════════════════════════════════════ */
#contacts-page-root {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}
.ct-page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  flex-shrink: 0;
  margin-bottom: 0.65rem;
}
.ct-page-header .page-title { margin: 0; }
.ct-header-actions { display: flex; gap: 0.5rem; align-items: center; flex-wrap: wrap; }
.ct-view-toggle {
  display: inline-flex;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  overflow: hidden;
}
.ct-view-btn {
  padding: 6px 14px;
  background: var(--color-bg);
  border: none;
  cursor: pointer;
  font-size: 0.8125rem;
  font-weight: 600;
  color: var(--color-text-secondary);
}
.ct-view-btn + .ct-view-btn { border-left: 1px solid var(--color-border); }
.ct-view-btn.active { background: var(--color-primary); color: #fff; }

/* View containers (only the active one is shown; JS toggles display) */
.ct-view { flex: 1; min-height: 0; }
.ct-table-view { display: flex; flex-direction: column; }
.ct-board-view { display: flex; }
.ct-charts-view {
  overflow-y: auto;
  grid-template-columns: 1fr 1fr;
  grid-auto-rows: minmax(260px, 1fr);
  gap: 0.85rem;
  padding-bottom: 0.5rem;
}
.ct-empty {
  padding: 2rem;
  text-align: center;
  color: var(--color-text-secondary);
  font-size: 0.875rem;
}

/* Board card content (rendered by renderContactCard) */
.ct-card-head { display: flex; align-items: baseline; justify-content: space-between; gap: 0.4rem; }
.ct-card-name { font-size: 0.8125rem; font-weight: 700; color: var(--color-text); line-height: 1.3; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ct-card-mail { font-size: 0.85rem; text-decoration: none; color: var(--color-primary); flex-shrink: 0; }
.ct-card-mail:hover { text-decoration: underline; }
.ct-card-sub { font-size: 0.75rem; color: var(--color-text-secondary); margin-top: 2px; }
.ct-card-at { opacity: 0.5; padding: 0 1px; }
.ct-col-more {
  font-size: 0.6875rem;
  color: var(--color-text-secondary);
  text-align: center;
  padding: 4px 0 2px;
  font-style: italic;
}

/* Charts */
.ct-chart-card {
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 0.8rem 0.95rem 0.9rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
}
.ct-chart-title { font-size: 0.8125rem; font-weight: 700; color: var(--color-text); margin: 0 0 0.55rem; }
.ct-chart-canvas-wrap { position: relative; flex: 1; min-height: 200px; }
.ct-chart-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--color-text-secondary);
  font-size: 0.8125rem;
  text-align: center;
}
.ct-charts-empty {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  color: var(--color-text-secondary);
  font-size: 0.9rem;
  text-align: center;
}

/* Map (Leaflet) */
.ct-map-view {
  flex-direction: column;
  border: 1px solid var(--color-border);
  border-radius: 12px;
  overflow: hidden;
  background: var(--color-bg-surface);
}
.ct-map-status {
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: #ebf5ff;
  color: #1e40af;
  font-size: 0.8rem;
  border-bottom: 1px solid #bfdbfe;
  flex-shrink: 0;
}
.ct-map-canvas { flex: 1; min-height: 0; position: relative; }
.ct-map-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 1000;
  text-align: center;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--color-border);
  border-radius: 12px;
  padding: 22px 30px;
  box-shadow: var(--shadow-md);
  pointer-events: none;
  max-width: 80%;
}
.ct-map-empty p { margin: 0; color: var(--color-text-secondary); font-size: 0.9rem; }

/* City count badge (one marker per distinct city) */
.ct-city-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #4f46e5;
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 700;
  border: 2px solid #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
  box-sizing: border-box;
}

/* Popup people list */
.ct-map-people { margin-top: 6px; border-top: 1px solid var(--color-border); padding-top: 5px; }
.ct-map-person { font-size: 0.75rem; line-height: 1.35; margin-bottom: 3px; }
.ct-map-person-name { font-weight: 600; color: var(--text-primary); }
.ct-map-person-sub { display: block; color: var(--text-muted); font-size: 0.7rem; }
.ct-map-more { font-size: 0.7rem; color: var(--text-muted); margin-top: 2px; }

@media (max-width: 720px) {
  .ct-charts-view { grid-template-columns: 1fr; }
}
