/* ==========================================================================
   SD Manager — Providers & Contacts directory, provider picker
   Builds on tokens from style.css, calendar.css and activities.css.
   ========================================================================== */

.text-link {
  color: var(--accent-text);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--accent-text) 35%, transparent);
  text-underline-offset: 3px;
  border-radius: 4px;
}

.text-link:hover { text-decoration-color: currentColor; }

/* ---------- Avatars / logos ---------- */

.dir-avatar {
  display: inline-grid;
  place-items: center;
  flex: none;
  overflow: hidden;
  border-radius: 12px;
  background: color-mix(in srgb, var(--tone) 14%, var(--surface));
  color: var(--tone);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--tone) 26%, transparent);
}

.dir-avatar--sm { width: 32px; height: 32px; border-radius: 9px; }
.dir-avatar--md { width: 44px; height: 44px; }
.dir-avatar--lg { width: 56px; height: 56px; border-radius: 14px; }
.dir-avatar--xl { width: 80px; height: 80px; border-radius: 20px; }
.dir-avatar .act-icon { width: 55%; height: 55%; stroke-width: 1.8; }

.dir-avatar--img {
  --tone: var(--border-strong);
  background: #fff;
}

.dir-avatar--img img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.dir-tone-indigo { --tone: #4338ca; }
.dir-tone-teal   { --tone: var(--teal-700); }
.dir-tone-violet { --tone: #6d28d9; }
.dir-tone-amber  { --tone: #a16207; }
[data-theme="dark"] .dir-tone-indigo { --tone: #a5b4fc; }
[data-theme="dark"] .dir-tone-teal   { --tone: var(--teal-300); }
[data-theme="dark"] .dir-tone-violet { --tone: #c4b5fd; }
[data-theme="dark"] .dir-tone-amber  { --tone: #fcd34d; }

.dir-type {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.dir-type--organization { background: var(--info-soft); color: var(--info); }
.dir-type--professional { background: var(--accent-soft); color: var(--accent-text); }
.dir-type--contact      { background: color-mix(in srgb, #7c3aed 13%, var(--surface)); color: #6d28d9; }
.dir-type--location     { background: var(--warning-soft); color: var(--warning); }
[data-theme="dark"] .dir-type--contact { color: #c4b5fd; }

/* ---------- List ---------- */

.dir-toolbar {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.dir-types {
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.dir-types::-webkit-scrollbar { display: none; }
.dir .seg button { white-space: nowrap; }
.dir-types button { flex: none; }

.dir-toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.dir-cat { flex: 1; min-width: 200px; max-width: 360px; }

.dir-count {
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-muted);
}

.dir-list {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.card.dir-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.dir-row:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--border)); }
.dir-row:focus-within { border-color: var(--accent); }

.dir-row-main {
  flex: 1;
  min-width: 0;
}

.dir-row-name {
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

/* Whole card is clickable through the name link. */
.dir-row-name a::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
}

.dir-row-name a:focus-visible { outline: none; }
.dir-row:has(.dir-row-name a:focus-visible) { outline: 2px solid var(--focus); outline-offset: 2px; }

.dir-row-sub {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  margin-top: 3px;
  font-size: 13px;
  color: var(--text-muted);
}

.dir-row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 6px;
  font-size: 12.5px;
  color: var(--text-2);
}

.dir-row-meta span {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.dir-row-meta .icon { color: var(--text-muted); }
.dir-row-meta:empty { display: none; }
.dir-row-chev { color: var(--text-muted); }

/* ---------- Detail ---------- */

.dir-hero { margin-bottom: 16px; }

.dir-hero-main {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px;
}

.dir-hero-text { flex: 1; min-width: min(100%, 240px); }
.dir-hero-text .eyebrow { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.dir-hero-text .eyebrow .tag { text-transform: none; letter-spacing: 0.02em; }
.dir-hero-text .page-title { overflow-wrap: anywhere; }

.dir-hero-title {
  margin-top: 4px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-2);
}

.dir-hero-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 14px;
  margin-top: 8px;
  font-size: 14px;
}

.dir-hero-links .icon { margin-right: -8px; color: var(--text-muted); }
.dir-hero-meta { margin-top: 8px; font-size: 12.5px; }

.dir-detail-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.dir-card .card-header { margin-bottom: 12px; }

.dir-contacts {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.dir-contacts li {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  font-size: 14px;
}

.dir-contacts .icon { color: var(--text-muted); }

.dir-c-label {
  min-width: 78px;
  font-size: 12.5px;
  font-weight: 650;
  color: var(--text-muted);
}

.dir-c-value {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.dir-contacts .link-btn { min-height: 32px; padding: 4px 6px; }

.dir-sub-h {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 16px 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--text-2);
}

.dir-pre {
  font-size: 14px;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.dir-inherited {
  margin-top: 16px;
  padding: 2px 14px 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 14px;
}

.dir-private {
  margin-top: 14px;
  padding: 2px 14px 12px;
  border-radius: 14px;
  background: var(--warning-soft);
}

.dir-private .dir-sub-h .icon { color: var(--warning); }

.dir-mini-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.dir-mini-list li {
  display: flex;
  align-items: center;
  gap: 12px;
}

.dir-mini-list li > span:last-child { min-width: 0; }
.dir-mini-name { display: block; font-size: 14px; overflow-wrap: anywhere; }

.dir-mini-sub {
  display: block;
  font-size: 12.5px;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

/* ---------- Directory form ---------- */

/* Record-type tabs live in the dialog's fixed toolbar (always visible while fields scroll). */
.dir-type-choice {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 2px;
}

.dir-type-choice .seg-option { min-width: 0; }
.dir-type-choice .seg-option span { min-height: 40px; padding: 0 8px; white-space: nowrap; }

.dir-type-note {
  margin-top: 8px;
  font-size: 12.5px;
  color: var(--text-muted);
}

/* One compact row on common phones (375px+); 2×2 only on very narrow screens. */
@media (min-width: 370px) {
  .dir-type-choice { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .dir-type-choice .seg-option span { padding: 0 2px; font-size: 12px; }
}

@media (min-width: 520px) {
  .dir-type-choice .seg-option span { padding: 0 8px; font-size: 13.5px; }
}

/* Short viewports (e.g. keyboard open): give the fields the room. The note stays
   available to screen readers through aria-describedby. */
@media (max-height: 600px) {
  .dir-type-note { display: none; }
}

.multi {
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.multi-rows {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 8px;
}

.multi-row {
  display: grid;
  grid-template-columns: minmax(96px, 128px) minmax(0, 1fr) 44px;
  gap: 8px;
}

.multi-row .icon-btn { width: 44px; height: 44px; }

.address-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}

.logo-edit {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 16px;
}

.logo-actions {
  display: flex;
  flex: 1;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 220px;
}

.logo-actions .field-hint { flex-basis: 100%; margin-top: 0; }
.logo-upload { cursor: pointer; }
.logo-upload:focus-within { outline: 2px solid var(--focus); outline-offset: 2px; }
.logo-actions .btn:disabled { cursor: not-allowed; }

.private-field .field-label { display: flex; align-items: center; gap: 6px; }
.private-field .field-label .icon { color: var(--warning); }

.confirm-text { font-size: 15px; color: var(--text-2); }

.confirm-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 12px;
  padding-left: 18px;
  list-style: disc;
  font-size: 14px;
  color: var(--text-2);
}

/* ---------- Provider picker (Activity form) ---------- */

.prov-selected {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 14px;
  background: var(--surface-2);
}

.prov-sel-text {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 160px;
}

.prov-sel-name { font-weight: 650; overflow-wrap: anywhere; }
.prov-sel-sub { font-size: 12.5px; color: var(--text-muted); overflow-wrap: anywhere; }
.prov-sel-actions { display: flex; gap: 6px; }
.prov-sel-actions .btn .icon { width: 16px; height: 16px; }

.prov-search { position: relative; }
.prov-selected + .prov-search { margin-top: 8px; }

.prov-search > .icon {
  position: absolute;
  left: 13px;
  top: 22px;
  width: 18px;
  height: 18px;
  color: var(--text-muted);
  transform: translateY(-50%);
  pointer-events: none;
}

.prov-search .input { padding-left: 40px; }

.prov-list {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 5;
  max-height: 300px;
  overflow-y: auto;
  margin: 0;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow-lg);
  list-style: none;
}

.prov-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 6px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.prov-opt:hover,
.prov-opt[aria-selected="true"] { background: var(--accent-soft); }

.prov-opt-text { display: flex; flex-direction: column; min-width: 0; }
.prov-opt-name { font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.prov-opt-sub { font-size: 12px; color: var(--text-muted); overflow-wrap: anywhere; }

.prov-opt--create {
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 650;
}

.prov-opt--create .icon { width: 18px; height: 18px; }

.prov-empty {
  padding: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

.loc-custom { margin-top: 8px; }

/* Quick view */
.dir-quick-head { display: flex; align-items: center; gap: 14px; margin-bottom: 8px; }
.dir-quick-org { margin-top: 4px; font-weight: 650; }
.dir-quick-h { margin: 16px 0 6px; font-size: 13px; font-weight: 700; color: var(--text-2); }

/* ---------- Responsive ---------- */

@media (min-width: 560px) {
  .address-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .address-grid .field--wide { grid-column: 1 / -1; }
  .address-grid .field:nth-child(3) { grid-column: span 3; }
  .address-grid .field:nth-child(4),
  .address-grid .field:nth-child(5) { grid-column: span 3; }
}

@media (min-width: 768px) {
  .address-grid .field:nth-child(3) { grid-column: span 3; }
  .address-grid .field:nth-child(4) { grid-column: span 1; }
  .address-grid .field:nth-child(5) { grid-column: span 2; }
}

@media (min-width: 1100px) {
  .dir-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dir-detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: start; }
}
