/* ======================================================
   customer-profile.css — Mobile Client Profile (Step 4)
   Prefix: .cp-
   Uses tokens from tokens.css. No hardcoded values.
   ====================================================== */

/* ── Page shell ─────────────────────────────────────── */
#page-customers {
  background: var(--page-bg);
  min-height: 100vh;
  padding-bottom: calc(var(--nav-height-mobile) + 16px);
}

/* ── Skeleton loader ─────────────────────────────────── */
.cp-skeleton {
  background: linear-gradient(90deg, var(--gray-200) 25%, var(--gray-100) 50%, var(--gray-200) 75%);
  background-size: 200% 100%;
  animation: cp-shimmer 1.4s infinite;
  border-radius: var(--radius-md);
}
@keyframes cp-shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

.cp-skeleton-header {
  height: 160px;
  border-radius: 0;
  margin-bottom: 12px;
}
.cp-skeleton-card {
  height: 72px;
  margin: 0 16px 12px;
}
.cp-skeleton-row {
  height: 44px;
  margin: 0 16px 8px;
}

/* ── Error / empty states ────────────────────────────── */
.cp-error-state, .cp-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 48px 24px;
  text-align: center;
  gap: 12px;
}
.cp-error-ico, .cp-empty-ico {
  font-size: 40px;
  line-height: 1;
}
.cp-error-title, .cp-empty-title {
  font-size: var(--font-md);
  font-weight: 700;
  color: var(--text-primary);
}
.cp-error-sub, .cp-empty-sub {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  line-height: var(--line-height-normal);
  max-width: 260px;
}

/* ── Header ──────────────────────────────────────────── */
.cp-header {
  background: var(--surface);
  padding: 0 0 16px;
  border-bottom: 1px solid var(--border);
}

.cp-header-bar {
  display: flex;
  align-items: center;
  padding: 12px 16px 0;
  gap: 8px;
  min-height: var(--tap-min);
}

.cp-back-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--brand);
  border-radius: var(--radius-md);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.cp-back-btn:active { background: var(--brand-light); }
.cp-back-btn svg { display: block; }

.cp-header-spacer { flex: 1; }

.cp-more-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: var(--radius-md);
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.cp-more-btn:active { background: var(--gray-100); }

.cp-header-identity {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px 0;
}

.cp-avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-pill);
  background: var(--brand-light);
  color: var(--brand);
  font-size: 20px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  border: 2px solid var(--brand-border);
}
.cp-avatar img { width: 100%; height: 100%; object-fit: cover; }

.cp-header-info { min-width: 0; flex: 1; }

.cp-header-name {
  font-size: var(--font-lg);
  font-weight: 700;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.2;
}

.cp-header-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.cp-chip {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  font-size: var(--font-xs);
  font-weight: 600;
  white-space: nowrap;
}
.cp-chip-active   { background: var(--success-bg);  color: var(--success); }
.cp-chip-prospect { background: var(--info-bg);     color: var(--info);    }
.cp-chip-inactive { background: var(--gray-100);    color: var(--gray-600);}
.cp-chip-blocked  { background: var(--danger-bg);   color: var(--danger);  }
.cp-chip-dual     { background: var(--warning-bg);  color: var(--warning); }
.cp-chip-tech     { background: var(--gray-200);    color: var(--gray-700);}

.cp-header-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 8px 16px 0;
}
.cp-meta-row {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--font-sm);
  color: var(--text-secondary);
}
.cp-meta-row svg { color: var(--text-tertiary); flex-shrink: 0; }
.cp-meta-phone { color: var(--brand); font-weight: 600; }

/* ── Quick Actions ───────────────────────────────────── */
.cp-quick-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.cp-quick-actions::-webkit-scrollbar { display: none; }

.cp-qa-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 64px;
  min-height: var(--tap-min);
  padding: 8px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  cursor: pointer;
  color: var(--text-primary);
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
.cp-qa-btn:active { background: var(--gray-100); transform: scale(.96); }
.cp-qa-btn-ico { font-size: 20px; line-height: 1; }
.cp-qa-btn.primary { background: var(--brand); color: #fff; border-color: var(--brand); }
.cp-qa-btn.wa { background: #25D366; color: #fff; border-color: #25D366; }
.cp-qa-btn.primary:active { background: var(--brand-dark); }
.cp-qa-btn.wa:active { background: #1FAA52; }

/* ── Next Action card ────────────────────────────────── */
.cp-next-action {
  margin: 12px 16px 0;
  background: var(--surface);
  border: 1.5px solid var(--brand-border);
  border-radius: var(--radius-xl);
  padding: 14px 16px;
}
.cp-na-header {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}
.cp-na-icon {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--brand-light);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.cp-na-icon.high  { background: var(--danger-bg);  }
.cp-na-icon.normal{ background: var(--warning-bg); }
.cp-na-text { flex: 1; min-width: 0; }
.cp-na-title {
  font-size: var(--font-base);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
}
.cp-na-reason {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.4;
}
.cp-na-priority-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 6px;
}
.cp-na-priority-dot.high   { background: var(--danger);  }
.cp-na-priority-dot.normal { background: var(--warning); }
.cp-na-action-btn {
  margin-top: 12px;
  width: 100%;
  height: 44px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--brand);
  color: #fff;
  font-size: var(--font-base);
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cp-na-action-btn:active { background: var(--brand-dark); }

/* ── Summary ─────────────────────────────────────────── */
.cp-summary {
  margin: 12px 16px 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.cp-metric {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  box-shadow: var(--shadow-sm);
}
.cp-metric-label {
  font-size: var(--font-xs);
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.cp-metric-value {
  font-size: 22px;
  font-weight: 800;
  color: var(--text-primary);
  margin-top: 3px;
  font-variant-numeric: tabular-nums;
}
.cp-metric-value.danger  { color: var(--danger);  }
.cp-metric-value.success { color: var(--success); }
.cp-metric-sub {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
  margin-top: 1px;
}

/* ── Tabs ────────────────────────────────────────────── */
.cp-tabs-bar {
  display: flex;
  background: var(--surface);
  border-bottom: 1.5px solid var(--border);
  margin-top: 14px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  position: sticky;
  top: 0;
  z-index: 10;
}
.cp-tabs-bar::-webkit-scrollbar { display: none; }

.cp-tab-btn {
  flex: 1;
  min-width: 72px;
  padding: 12px 4px 10px;
  border: none;
  border-bottom: 2.5px solid transparent;
  background: none;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  transition: color var(--duration-fast), border-color var(--duration-fast);
}
.cp-tab-btn.active {
  color: var(--brand);
  border-bottom-color: var(--brand);
}
.cp-tab-btn:active { opacity: 0.7; }

.cp-tab-content { padding: 14px 16px 0; }

/* ── Entity cards (lead/job/estimate in Overview) ─────── */
.cp-entity-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 14px 16px;
  margin-bottom: 12px;
  box-shadow: var(--card-shadow);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cp-entity-card:active { transform: scale(.99); opacity: .9; }
.cp-entity-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}
.cp-entity-card-label {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.cp-entity-card-title {
  font-size: var(--font-base);
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.cp-entity-card-meta {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  line-height: 1.4;
}
.cp-entity-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
  gap: 8px;
}
.cp-entity-card-amount {
  font-size: var(--font-md);
  font-weight: 800;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}
.cp-entity-card-amount.balance { color: var(--danger); }

/* ── Section heading ─────────────────────────────────── */
.cp-section-title {
  font-size: var(--font-sm);
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 16px 0 8px;
}
.cp-section-title:first-child { margin-top: 0; }

/* ── Contact info ────────────────────────────────────── */
.cp-info-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-xl);
  margin-bottom: 12px;
  overflow: hidden;
}
.cp-info-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.cp-info-row:last-child { border-bottom: none; }
.cp-info-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  background: var(--gray-100);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
  font-size: 15px;
}
.cp-info-key {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
  font-weight: 600;
}
.cp-info-val {
  font-size: var(--font-base);
  color: var(--text-primary);
  font-weight: 500;
  margin-top: 1px;
  word-break: break-word;
}

/* ── Activity / Timeline ─────────────────────────────── */
.cp-timeline { display: flex; flex-direction: column; gap: 0; }

.cp-timeline-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cp-timeline-item:last-child { border-bottom: none; }
.cp-timeline-item:active { opacity: 0.7; }

.cp-timeline-icon-wrap {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}
.cp-timeline-icon-wrap.message     { background: var(--info-bg); }
.cp-timeline-icon-wrap.lead_event  { background: var(--brand-light); }
.cp-timeline-icon-wrap.job_event   { background: var(--warning-bg); }
.cp-timeline-icon-wrap.transaction { background: var(--success-bg); }
.cp-timeline-icon-wrap.photo       { background: var(--gray-100); }

.cp-timeline-body { flex: 1; min-width: 0; }
.cp-timeline-title {
  font-size: var(--font-base);
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cp-timeline-desc {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  margin-top: 2px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.cp-timeline-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}
.cp-timeline-time {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
}
.cp-timeline-actor {
  font-size: var(--font-xs);
  color: var(--text-tertiary);
}
.cp-timeline-amount {
  font-size: var(--font-sm);
  font-weight: 700;
  color: var(--success);
  font-variant-numeric: tabular-nums;
}

.cp-load-more-btn {
  width: 100%;
  height: 48px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--brand);
  font-size: var(--font-base);
  font-weight: 600;
  cursor: pointer;
  margin-top: 12px;
  -webkit-tap-highlight-color: transparent;
}
.cp-load-more-btn:active { background: var(--gray-100); }
.cp-load-more-btn:disabled { color: var(--text-tertiary); cursor: default; }

/* ── Jobs ────────────────────────────────────────────── */
.cp-job-group-title {
  font-size: var(--font-xs);
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 14px 0 8px;
}
.cp-job-group-title:first-child { margin-top: 0; }

.cp-job-card {
  background: var(--surface);
  border: 0.5px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 14px 16px;
  margin-bottom: 10px;
  box-shadow: var(--card-shadow);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.cp-job-card:active { opacity: .9; transform: scale(.99); }
.cp-job-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.cp-job-card-service {
  font-size: var(--font-base);
  font-weight: 700;
  color: var(--text-primary);
}
.cp-job-card-meta {
  font-size: var(--font-sm);
  color: var(--text-secondary);
  margin-top: 5px;
  line-height: 1.5;
}
.cp-job-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}
.cp-job-open-btn {
  height: 36px;
  padding: 0 14px;
  border: 1px solid var(--brand-border);
  border-radius: var(--radius-md);
  background: var(--brand-light);
  color: var(--brand);
  font-size: var(--font-sm);
  font-weight: 700;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* ── Files / Photos ──────────────────────────────────── */
.cp-files-group-title {
  font-size: var(--font-xs);
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin: 14px 0 8px;
}
.cp-files-group-title:first-child { margin-top: 0; }

.cp-files-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}
@media (min-width: 420px) {
  .cp-files-grid { grid-template-columns: repeat(3, 1fr); }
}

.cp-file-thumb {
  aspect-ratio: 1;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--gray-200);
  cursor: pointer;
  position: relative;
  -webkit-tap-highlight-color: transparent;
}
.cp-file-thumb:active { opacity: 0.8; }
.cp-file-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cp-file-thumb-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text-tertiary);
  font-size: 28px;
}
.cp-file-thumb-label {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(transparent, rgba(0,0,0,0.5));
  color: #fff;
  font-size: 10px;
  font-weight: 600;
  padding: 12px 6px 5px;
}
.cp-file-type-badge {
  position: absolute;
  top: 5px;
  left: 5px;
  background: rgba(0,0,0,0.45);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 4px;
  text-transform: uppercase;
}

/* ── Edit bottom sheet ───────────────────────────────── */
.cp-sheet-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: var(--z-sheet);
  display: none;
  align-items: flex-end;
}
.cp-sheet-overlay.open { display: flex; }
.cp-sheet {
  width: 100%;
  max-height: 90vh;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: cp-sheet-up var(--duration-normal) var(--ease-out);
}
@keyframes cp-sheet-up { from { transform: translateY(100%); } to { transform: translateY(0); } }

.cp-sheet-handle {
  width: 36px;
  height: 4px;
  background: var(--gray-300);
  border-radius: 2px;
  margin: 10px auto 0;
  flex-shrink: 0;
}
.cp-sheet-title {
  font-size: var(--font-md);
  font-weight: 700;
  color: var(--text-primary);
  padding: 14px 20px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.cp-sheet-body {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px 20px;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.cp-sheet-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 10px;
  flex-shrink: 0;
  background: var(--surface);
}
.cp-sheet-save-btn {
  flex: 1;
  height: 52px;
  border: none;
  border-radius: var(--radius-lg);
  background: var(--brand);
  color: #fff;
  font-size: var(--font-md);
  font-weight: 700;
  cursor: pointer;
}
.cp-sheet-save-btn:disabled { opacity: 0.6; cursor: default; }
.cp-sheet-cancel-btn {
  height: 52px;
  padding: 0 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: var(--font-md);
  font-weight: 600;
  cursor: pointer;
}

.cp-field { display: flex; flex-direction: column; gap: 6px; }
.cp-field-label {
  font-size: var(--font-sm);
  font-weight: 700;
  color: var(--text-secondary);
}
.cp-field input,
.cp-field select,
.cp-field textarea {
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: 11px 13px;
  font-size: var(--font-base);
  color: var(--text-primary);
  background: var(--surface);
  outline: none;
  font-family: var(--font-family);
  line-height: 1.4;
}
.cp-field input:focus,
.cp-field select:focus,
.cp-field textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(var(--brand-rgb), .12);
}
.cp-field textarea { resize: vertical; min-height: 80px; }

/* ── Action sheet (More menu) ────────────────────────── */
.cp-action-sheet {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: var(--z-sheet);
  display: none;
  align-items: flex-end;
}
.cp-action-sheet.open { display: flex; }
.cp-action-sheet-inner {
  width: 100%;
  background: var(--surface);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  padding: 8px 0 20px;
  animation: cp-sheet-up var(--duration-normal) var(--ease-out);
}
.cp-action-item {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 15px 22px;
  border: none;
  background: none;
  cursor: pointer;
  font-size: var(--font-base);
  font-weight: 500;
  color: var(--text-primary);
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}
.cp-action-item:active { background: var(--gray-100); }
.cp-action-item.danger { color: var(--danger); }
.cp-action-item-ico { font-size: 20px; width: 28px; flex-shrink: 0; }
.cp-action-cancel {
  width: calc(100% - 32px);
  margin: 10px 16px 0;
  height: 52px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  font-size: var(--font-md);
  font-weight: 700;
  color: var(--text-secondary);
  cursor: pointer;
}

/* ── Status pill (reuse from shared, define here if not already) ── */
.status-pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 9px;
  border-radius: var(--radius-pill);
  font-size: var(--font-xs);
  font-weight: 700;
  white-space: nowrap;
}

/* ── Toast (lightweight) ─────────────────────────────── */
.cp-toast {
  position: fixed;
  bottom: calc(var(--nav-height-mobile) + 16px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--gray-900);
  color: #fff;
  font-size: var(--font-sm);
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-pill);
  z-index: var(--z-toast);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-fast);
  white-space: nowrap;
}
.cp-toast.visible { opacity: 1; }

/* ── Desktop: sidebar layout ─────────────────────────── */
@media (min-width: 769px) {
  #page-customers {
    padding-bottom: 0;
    padding-left: var(--desktop-sidebar-width);
    min-height: 100vh;
  }
  .cp-tabs-bar { top: 0; }
}
