/* ============================================================
   VIDARIA 1.1 CLIENTS CHROME
   ------------------------------------------------------------
   Phase 5: CSS-only restyle for the SuperAdmin Clients surface
   (CustomerAccountsList + AccountView). Scoped under
   body.vds-shell so legacy path is completely untouched.

   Full Leads + Agreements sibling sub-tabs DEFERRED to polish.
   First pass restyles the outer container + account cards +
   action buttons only — existing list rendering preserved.
   ============================================================ */

body.vds-shell .customer-accounts-container {
  background: var(--gray-50);
  padding: var(--space-5);
  max-width: var(--content-max-width);
  margin: 0 auto;
  min-height: calc(100vh - var(--nav-height));
}

body.vds-shell .customer-accounts-container h1,
body.vds-shell .customer-accounts-container h2 {
  color: var(--gray-900);
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-2xl);
  margin: 0 0 var(--space-4);
}

/* Account cards — verified class targeting (.account-card used in
   CustomerAccountsList.js). */
body.vds-shell .account-card {
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-4);
  transition: box-shadow var(--transition-base), transform var(--transition-base);
}
body.vds-shell .account-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

/* Search + filter inputs at the top of the list */
body.vds-shell .customer-accounts-container input[type="text"],
body.vds-shell .customer-accounts-container input[type="search"],
body.vds-shell .customer-accounts-container select {
  height: 36px;
  padding: 0 var(--space-3);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--gray-900);
  outline: none;
}
body.vds-shell .customer-accounts-container input:focus,
body.vds-shell .customer-accounts-container select:focus {
  border-color: var(--vidaria-blue);
  box-shadow: 0 0 0 3px var(--vidaria-blue-tint);
}

/* Primary action buttons inside the clients surface */
body.vds-shell .customer-accounts-container .btn-primary {
  background: var(--vidaria-blue);
  border-color: var(--vidaria-blue);
  color: var(--white);
  transition: background var(--transition-fast);
}
body.vds-shell .customer-accounts-container .btn-primary:hover {
  background: var(--vidaria-blue-hover);
  border-color: var(--vidaria-blue-hover);
}

/* Loading + error state chrome */
body.vds-shell .customer-accounts-container .loading-spinner,
body.vds-shell .customer-accounts-container .error-message {
  background: var(--white);
  border: var(--border);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  text-align: center;
  color: var(--gray-500);
  box-shadow: var(--shadow-sm);
}
body.vds-shell .customer-accounts-container .error-message {
  color: var(--danger-text);
  background: var(--danger-light);
  border-color: var(--danger);
}

/* ============================================================
   CLIENT PORTAL USERS TAB — Vidaria chrome (ClientManagement.js)
   ------------------------------------------------------------
   In-place restyle of the `clients` tab list view. The legacy
   cm-* list/card markup is replaced (under body.vds-shell only)
   by a panel-sidebar + card-grid layout matching the Vidaria
   mockup (demo/css/pages/clients.css). All state, handlers and
   the create/edit form are shared with the legacy path; only the
   list-view JSX + this stylesheet change.
   ============================================================ */

/* Neutralize the legacy max-width container so the panel layout
   can run edge-to-edge inside the tab content area. NOTE: must stay
   scrollable (overflow-y:auto, NOT hidden) — the same wrapper holds
   the tall create/edit form; the list view's panes scroll internally
   so they don't double-scroll. */
body.vds-shell .cm-container {
  max-width: none;
  padding: 0;
  height: 100%;
  overflow-y: auto;
}

/* ---- Two-pane layout ---- */
body.vds-shell .vds-cm-layout {
  display: flex;
  height: 100%;
  min-height: 0;
  background: var(--gray-50);
}

/* ---- Client Groups sidebar ---- */
body.vds-shell .vds-cm-sidebar {
  width: 240px;
  flex-shrink: 0;
  border-right: 1px solid var(--gray-200);
  background: var(--white);
  padding: var(--space-5) var(--space-3);
  overflow-y: auto;
}
body.vds-shell .vds-cm-sidebar-label {
  font-size: 11px;
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--gray-400);
  padding: 0 var(--space-3);
  margin-bottom: var(--space-3);
}
body.vds-shell .vds-cm-group-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  padding: 9px var(--space-3);
  margin-bottom: 2px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--gray-700);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  text-align: left;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}
body.vds-shell .vds-cm-group-item:hover {
  background: var(--gray-100);
}
body.vds-shell .vds-cm-group-item.active {
  background: var(--vidaria-blue-tint);
  color: var(--vidaria-blue);
  font-weight: var(--font-weight-semibold);
}
body.vds-shell .vds-cm-group-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.vds-shell .vds-cm-group-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--vidaria-blue);
}
body.vds-shell .vds-cm-group-dot.all {
  background: var(--gray-300);
}
body.vds-shell .vds-cm-sidebar-empty {
  padding: var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--gray-400);
}

/* ---- Content pane ---- */
body.vds-shell .vds-cm-content {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: var(--space-6);
}

/* Toolbar */
body.vds-shell .vds-cm-toolbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-6);
  flex-wrap: wrap;
}
body.vds-shell .vds-cm-title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-extrabold, 800);
  color: var(--gray-900);
  margin: 0;
}
body.vds-shell .vds-cm-subtitle {
  font-size: var(--font-size-sm);
  color: var(--gray-500);
  margin-top: 4px;
}
body.vds-shell .vds-cm-toolbar-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
}

/* Search box with leading icon */
body.vds-shell .vds-cm-search-group {
  position: relative;
  width: 280px;
  max-width: 100%;
}
body.vds-shell .vds-cm-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  pointer-events: none;
}
body.vds-shell .vds-cm-search-input {
  width: 100%;
  height: 38px;
  padding: 0 var(--space-3) 0 36px;
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--gray-900);
  outline: none;
}
body.vds-shell .vds-cm-search-input:focus {
  border-color: var(--vidaria-blue);
  box-shadow: 0 0 0 3px var(--vidaria-blue-tint);
}
body.vds-shell .vds-cm-search-input::placeholder { color: var(--gray-400); }

/* Show-inactive toggle */
body.vds-shell .vds-cm-inactive-toggle {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--gray-600);
  cursor: pointer;
  user-select: none;
}
body.vds-shell .vds-cm-inactive-toggle input { accent-color: var(--vidaria-blue); }

/* Add Client button */
body.vds-shell .vds-cm-add-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  padding: 0 16px;
  border: none;
  border-radius: var(--radius-md);
  background: var(--vidaria-blue);
  color: var(--white);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: background var(--transition-fast);
}
body.vds-shell .vds-cm-add-btn:hover { background: var(--vidaria-blue-hover); }

/* ---- Card grid ---- */
body.vds-shell .vds-cm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: var(--space-5);
  align-items: start;
}
body.vds-shell .vds-cm-card {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  transition: box-shadow var(--transition-base), transform var(--transition-base);
}
body.vds-shell .vds-cm-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}
body.vds-shell .vds-cm-card.inactive { opacity: 0.62; }

body.vds-shell .vds-cm-card-head {
  display: flex;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
}
body.vds-shell .vds-cm-avatar {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  background: var(--vidaria-blue-tint);
  color: var(--vidaria-blue);
}
/* Deterministic soft avatar palette (idx from initials in JS) */
body.vds-shell .vds-cm-avatar.c0 { background: #e0e7ff; color: #4338ca; }
body.vds-shell .vds-cm-avatar.c1 { background: #d1fae5; color: #047857; }
body.vds-shell .vds-cm-avatar.c2 { background: #fef3c7; color: #b45309; }
body.vds-shell .vds-cm-avatar.c3 { background: #ede9fe; color: #6d28d9; }
body.vds-shell .vds-cm-avatar.c4 { background: #ccfbf1; color: #0f766e; }
body.vds-shell .vds-cm-avatar.c5 { background: #ffe4e6; color: #be123c; }

body.vds-shell .vds-cm-card-ident { flex: 1; min-width: 0; }
body.vds-shell .vds-cm-card-name {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-md);
  font-weight: var(--font-weight-bold);
  color: var(--gray-900);
}
body.vds-shell .vds-cm-tag-inactive {
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-500);
  background: var(--gray-100);
  border-radius: var(--radius-full);
  padding: 2px 8px;
}
body.vds-shell .vds-cm-card-email {
  font-size: var(--font-size-sm);
  color: var(--gray-500);
  margin-top: 1px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
body.vds-shell .vds-cm-card-grouprow {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: var(--space-2);
}

/* Badges */
body.vds-shell .vds-cm-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  border-radius: var(--radius-full);
  line-height: 1.4;
}
body.vds-shell .vds-cm-badge.blue {
  color: var(--vidaria-blue);
  background: var(--vidaria-blue-pale, var(--vidaria-blue-tint));
  border: 1px solid rgba(16, 50, 85, 0.15);
}
body.vds-shell .vds-cm-badge.gray {
  color: var(--gray-600);
  background: var(--gray-100);
  border: 1px solid var(--gray-200);
}
body.vds-shell .vds-cm-badge.gray.muted { color: var(--gray-400); }
body.vds-shell .vds-cm-badge .vds-icon { color: currentColor; }

/* Card rows (stats + access) divided by top borders */
body.vds-shell .vds-cm-card-row {
  padding: var(--space-3) 0;
  border-top: 1px solid var(--gray-100);
}
body.vds-shell .vds-cm-stats {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}
body.vds-shell .vds-cm-stat-right { text-align: right; }
body.vds-shell .vds-cm-stat-label {
  font-size: 11px;
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gray-400);
}
body.vds-shell .vds-cm-stat-value {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  color: var(--gray-700);
  margin-top: 2px;
}
body.vds-shell .vds-cm-access .vds-cm-stat-label { margin-bottom: var(--space-2); }
body.vds-shell .vds-cm-access-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* Card actions */
body.vds-shell .vds-cm-card-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: 4px;
  padding-top: var(--space-3);
  border-top: 1px solid var(--gray-100);
}
body.vds-shell .vds-cm-btn-edit {
  flex: 1;
  height: 34px;
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--gray-700);
  font-family: var(--font-family);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
  cursor: pointer;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}
body.vds-shell .vds-cm-btn-edit:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}
body.vds-shell .vds-cm-btn-icon {
  width: 34px;
  height: 34px;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--gray-500);
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), border-color var(--transition-fast);
}
body.vds-shell .vds-cm-btn-icon:hover {
  background: var(--gray-50);
  color: var(--gray-700);
}
body.vds-shell .vds-cm-btn-icon.danger { color: var(--danger); }
body.vds-shell .vds-cm-btn-icon.danger:hover {
  background: var(--danger-light);
  border-color: var(--danger);
}

/* Empty / loading / error states */
body.vds-shell .vds-cm-state {
  padding: var(--space-6);
  text-align: center;
  color: var(--gray-500);
  font-size: var(--font-size-sm);
}
body.vds-shell .vds-cm-state-error { color: var(--danger-text); }
body.vds-shell .vds-cm-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: 64px var(--space-6);
  text-align: center;
  color: var(--gray-400);
}
body.vds-shell .vds-cm-empty .vds-icon { opacity: 0.4; }
body.vds-shell .vds-cm-empty p {
  margin: 0;
  font-size: var(--font-size-md);
  color: var(--gray-500);
}

/* ---- Create / Edit form chrome (reuses legacy cm-form markup) ---- */
body.vds-shell .cm-form {
  max-width: 760px;
  margin: 0 auto;
  padding: var(--space-6);
  padding-bottom: 48px;
}
body.vds-shell .cm-form-section {
  background: var(--white);
  border: 1px solid var(--gray-200);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  padding: var(--space-5);
  margin-bottom: var(--space-4);
}
body.vds-shell .cm-form-section h4 {
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-bold);
  color: var(--gray-900);
  margin: 0 0 var(--space-4);
}
body.vds-shell .cm-field input,
body.vds-shell .cm-form input[type="text"],
body.vds-shell .cm-form input[type="email"],
body.vds-shell .cm-form input[type="tel"] {
  border: 1px solid var(--gray-300);
  border-radius: var(--radius-md);
  background: var(--white);
  color: var(--gray-900);
}
body.vds-shell .cm-field input:focus,
body.vds-shell .cm-form input:focus {
  border-color: var(--vidaria-blue);
  box-shadow: 0 0 0 3px var(--vidaria-blue-tint);
  outline: none;
}
body.vds-shell .cm-form-actions .btn-primary,
body.vds-shell .cm-form .btn-primary {
  background: var(--vidaria-blue);
  border-color: var(--vidaria-blue);
  color: var(--white);
}
body.vds-shell .cm-form-actions .btn-primary:hover {
  background: var(--vidaria-blue-hover);
  border-color: var(--vidaria-blue-hover);
}
