/* Find Diætist — hybrid map + cards (Theme 1 + Theme 4) */

.dd-finder.find-layout {
  display: grid;
  grid-template-columns: minmax(0, 440px) minmax(0, 1fr);
  gap: 1.5rem;
  align-items: stretch;
  min-height: 560px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

.dd-finder .search-panel,
.dd-finder .map-wrapper {
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
}

.dd-finder .search-panel {
  background: var(--bg-card, #fcfaf7);
  border: 1px solid var(--border-color, #e8e2d9);
  border-radius: var(--radius-md, 12px);
  /* Beat theme.css .search-panel { padding: 40px } */
  padding: 1.1rem 1.15rem !important;
  max-height: 640px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Do not trap page scroll on the whole panel — only the card list scrolls. */
  overscroll-behavior: auto;
}

.dd-finder-toolbar {
  flex: 0 0 auto;
  min-width: 0;
}

.dd-finder .search-panel h3 {
  margin: 0 0 0.35rem;
  font-size: 1.15rem;
  line-height: 1.25;
}

.dd-finder-lead {
  font-size: 0.82rem;
  line-height: 1.4;
  color: var(--text-muted, #5a6e6a);
  margin: 0 0 0.75rem;
}

.dd-finder-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem 0.75rem;
  margin-bottom: 0.65rem;
}

.dd-finder-fields .form-group {
  margin-bottom: 0;
}

.dd-finder-fields .form-group label {
  margin-bottom: 0.25rem;
  font-size: 0.78rem;
}

.dd-finder-fields .form-control {
  padding: 0.55rem 0.7rem;
  font-size: 0.88rem;
  min-height: 42px;
}

/* Animated specialty select */
.dd-finder .dd-select {
  position: relative;
  width: 100%;
}

.dd-finder .dd-select__native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.dd-finder .dd-select__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  width: 100%;
  text-align: left;
  cursor: pointer;
  background: #fff;
  border: 1px solid var(--border-color, #e8e2d9);
  border-radius: var(--radius-sm, 8px);
  color: var(--text-dark, #1e2d2a);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.dd-finder .dd-select__trigger:hover,
.dd-finder .dd-select.is-open .dd-select__trigger {
  border-color: var(--primary, #2d4a43);
}

.dd-finder .dd-select.is-open .dd-select__trigger {
  box-shadow: 0 0 0 2px rgba(45, 74, 67, 0.12);
}

.dd-finder .dd-select__value {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dd-finder .dd-select__arrow {
  flex: 0 0 auto;
  width: 0.55rem;
  height: 0.55rem;
  border-right: 2px solid var(--primary, #2d4a43);
  border-bottom: 2px solid var(--primary, #2d4a43);
  /* Closed: points up */
  transform: rotate(-135deg);
  transition: transform 0.28s ease;
  margin-top: 0.2rem;
}

.dd-finder .dd-select.is-open .dd-select__arrow {
  /* Open: rotates to point down */
  transform: rotate(45deg);
  margin-top: -0.1rem;
}

.dd-finder .dd-select__menu {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  z-index: 40;
  margin: 0;
  padding: 0.3rem;
  list-style: none;
  background: #fff;
  border: 1px solid var(--border-color, #e8e2d9);
  border-radius: 10px;
  box-shadow: 0 12px 28px rgba(30, 45, 42, 0.12);
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transform: translateY(-6px);
  pointer-events: none;
  transition:
    max-height 0.28s ease,
    opacity 0.22s ease,
    transform 0.28s ease;
}

.dd-finder .dd-select.is-open .dd-select__menu {
  max-height: 220px;
  opacity: 1;
  overflow-y: auto;
  transform: translateY(0);
  pointer-events: auto;
}

.dd-finder .dd-select__option {
  padding: 0.5rem 0.65rem;
  border-radius: 7px;
  font-size: 0.86rem;
  line-height: 1.3;
  cursor: pointer;
  color: var(--text-dark, #1e2d2a);
  transition: background 0.15s ease, color 0.15s ease;
}

.dd-finder .dd-select__option:hover {
  background: var(--primary-light, #e9ece9);
}

.dd-finder .dd-select__option.is-selected {
  background: var(--primary, #2d4a43);
  color: #fff;
}

.dd-finder .filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0 0 0.75rem;
}

.dd-finder .pill {
  border: 1px solid var(--border-color, #e8e2d9);
  background: #fff;
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.74rem;
  line-height: 1.2;
  cursor: pointer;
  transition: 0.2s ease;
  white-space: nowrap;
}

.dd-finder .pill.active,
.dd-finder .pill:hover {
  background: var(--primary, #2d4a43);
  color: #fff;
  border-color: var(--primary, #2d4a43);
}

.dd-finder .dietitians-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-top: 0;
  flex: 1 1 auto;
  /* Keep room for at least ~2 compact cards on desktop. */
  min-height: calc(2 * 6.75rem + 0.65rem);
  overflow-y: auto;
  /* auto = chain to page scroll at top/bottom (contain felt “stuck” on phones) */
  overscroll-behavior-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 4px;
  scrollbar-gutter: stable;
}

.dd-finder .dietitian-card {
  display: flex;
  gap: 0.7rem;
  align-items: flex-start;
  padding: 0.7rem 0.8rem;
  background: #fff;
  border: 1px solid var(--border-color, #e8e2d9);
  border-radius: var(--radius-md, 12px);
  cursor: pointer;
  transition: box-shadow 0.2s ease, border-color 0.2s ease;
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: visible;
  box-sizing: border-box;
  container-type: inline-size;
  container-name: dd-card;
}

.dd-finder .dietitian-card:hover,
.dd-finder .dietitian-card.is-active {
  border-color: var(--primary, #2d4a43);
  box-shadow: 0 8px 24px rgba(45, 74, 67, 0.08);
}

.dd-finder .dietitian-avatar {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  flex-shrink: 0;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  object-fit: cover;
  object-position: center top;
  border: 2px solid var(--primary-light, #e9ece9);
}

.dd-finder .dietitian-avatar--fallback {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--primary-light, #e9ece9);
  font-weight: 600;
  color: var(--primary, #2d4a43);
  font-size: 1.1rem;
}

.dd-finder .dietitian-body {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  align-items: stretch;
}

/* Name/location left; icon actions always top-right; specialties full width below */
.dd-finder .dietitian-top {
  display: flex;
  flex-direction: row;
  gap: 0.65rem;
  align-items: flex-start;
  justify-content: flex-start;
  min-width: 0;
  width: 100%;
}

.dd-finder .dietitian-info {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  flex-basis: 0;
}

.dd-finder .dietitian-name {
  font-weight: 600;
  font-size: 0.98rem;
  color: var(--text-dark, #1e2d2a);
  margin-bottom: 0.15rem;
  line-height: 1.3;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.dd-finder .dietitian-person {
  font-size: 0.82rem;
  color: var(--text-muted, #5a6e6a);
  margin-bottom: 0.25rem;
  min-height: 1.2em;
  line-height: 1.3;
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.dd-finder .dietitian-person.is-empty {
  visibility: hidden;
}

.dd-finder .dietitian-location {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  font-size: 0.82rem;
  color: var(--text-muted, #5a6e6a);
  margin-bottom: 0.45rem;
  line-height: 1.35;
  min-height: 1.35em;
  min-width: 0;
  max-width: 100%;
}

.dd-finder .dietitian-location.is-empty {
  visibility: hidden;
}

.dd-finder .dietitian-location span {
  min-width: 0;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
}

.dd-finder .dietitian-specs {
  margin-top: 0;
  min-width: 0;
  max-width: 100%;
  width: 100%;
  overflow: hidden;
}

/* One row of pills; JS hides overflow and appends ".." */
.dd-finder .dietitian-specs-line {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.35rem;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}

.dd-finder .dietitian-spec {
  flex: 0 0 auto;
  font-size: 0.72rem;
  background: var(--primary-light, #e9ece9);
  color: var(--primary, #2d4a43);
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  white-space: nowrap;
  line-height: 1.3;
}

.dd-finder .dietitian-spec.is-match {
  background: var(--primary, #2d4a43);
  color: #fff;
  font-weight: 600;
}

.dd-finder .dietitian-spec-more {
  flex: 0 0 auto;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-muted, #5a6e6a);
  letter-spacing: 0.02em;
  line-height: 1;
  user-select: none;
}

/*
 * Icon-only actions stacked at top-right (finder list is often <400px wide,
 * so do NOT use container queries that pull actions under the name).
 */
.dd-finder .dietitian-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.35rem;
  flex: 0 0 auto;
  width: 2.4rem;
  min-width: 2.4rem;
  max-width: 2.4rem;
  margin-left: auto;
  box-sizing: border-box;
  align-self: flex-start;
  order: 2;
}

.dd-finder .dietitian-action {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: 2.4rem;
  height: 2.4rem;
  min-height: 2.4rem;
  padding: 0;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--primary, #2d4a43);
  text-decoration: none;
  background: var(--primary-light, #e9ece9);
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  box-sizing: border-box;
  overflow: hidden;
}

.dd-finder .dietitian-action span {
  /* Desktop: icon only (label still in aria-label) */
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.dd-finder .dietitian-action .dd-icon {
  width: 16px;
  height: 16px;
  margin: 0;
}

/* Phone viewport only: labeled chips under the text */
@media (max-width: 520px) {
  .dd-finder .dietitian-top {
    flex-direction: column;
    align-items: stretch;
  }

  .dd-finder .dietitian-actions {
    order: 3;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    margin-left: 0;
    grid-template-columns: 1fr 1fr;
  }

  .dd-finder .dietitian-actions:has(> :only-child) {
    grid-template-columns: 1fr;
  }

  .dd-finder .dietitian-action {
    width: 100%;
    height: auto;
    min-height: 2.15rem;
    padding: 0.35rem 0.5rem;
  }

  .dd-finder .dietitian-action span {
    position: static;
    width: auto;
    height: auto;
    margin: 0;
    clip: auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
}

.dd-finder .dietitian-action:hover {
  background: var(--primary, #2d4a43);
  color: #fff;
}

.dd-finder .dd-icon {
  flex-shrink: 0;
  display: block;
}

.dd-finder .dd-icon--muted {
  opacity: 0.75;
  margin-top: 1px;
}

.dd-finder .map-wrapper {
  min-height: 400px;
  border-radius: var(--radius-md, 12px);
  overflow: hidden;
  border: 1px solid var(--border-color, #e8e2d9);
}

.dd-finder .map-container {
  width: 100%;
  height: 100%;
  min-height: 400px;
}

/* Map marker popup */
.dd-finder .leaflet-popup.dd-map-popup-wrap .leaflet-popup-content-wrapper {
  border-radius: 12px;
  box-shadow: 0 10px 28px rgba(30, 45, 42, 0.14);
  border: 1px solid var(--border-color, #e8e2d9);
  padding: 0;
}

.dd-finder .leaflet-popup.dd-map-popup-wrap .leaflet-popup-content {
  margin: 0;
  min-width: 200px;
}

.dd-finder .leaflet-popup.dd-map-popup-wrap .leaflet-popup-tip {
  box-shadow: none;
}

.dd-finder .dd-map-popup {
  padding: 0.85rem 0.95rem 0.9rem;
  font-family: inherit;
  color: var(--text-dark, #1e2d2a);
}

.dd-finder .dd-map-popup__clinic {
  font-weight: 600;
  font-size: 0.95rem;
  line-height: 1.3;
  color: var(--text-dark, #1e2d2a);
}

.dd-finder .dd-map-popup__person {
  margin-top: 0.15rem;
  font-size: 0.82rem;
  color: var(--text-muted, #5a6e6a);
  line-height: 1.3;
}

.dd-finder .dd-map-popup__address {
  display: flex;
  align-items: flex-start;
  gap: 0.35rem;
  margin-top: 0.45rem;
  font-size: 0.8rem;
  color: var(--text-muted, #5a6e6a);
  line-height: 1.35;
}

.dd-finder .dd-map-popup__address .dd-icon {
  margin-top: 1px;
}

.dd-finder .dd-map-popup__specs {
  margin-top: 0.4rem;
  font-size: 0.72rem;
  color: var(--primary, #2d4a43);
  line-height: 1.35;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.dd-finder .dd-map-popup__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.65rem;
}

.dd-finder .dd-map-popup__btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.55rem;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 500;
  text-decoration: none;
  color: var(--primary, #2d4a43);
  background: var(--primary-light, #e9ece9);
  transition: background 0.15s ease, color 0.15s ease;
}

.dd-finder .dd-map-popup__btn:hover {
  background: var(--primary, #2d4a43);
  color: #fff;
}

.dd-finder .dd-map-popup__btn .dd-icon {
  width: 14px;
  height: 14px;
}

.dd-finder-empty {
  font-size: 0.9rem;
  color: var(--text-muted, #5a6e6a);
  padding: 1rem 0;
}

/* Stack earlier than theme’s 2-col find-layout so tablet/mobile never squeeze side-by-side */
@media (max-width: 1100px) {
  .dd-finder.find-layout {
    grid-template-columns: 1fr;
    grid-template-areas:
      "map"
      "panel";
    gap: 1rem;
    min-height: 0;
    align-items: start;
  }

  .dd-finder .map-wrapper {
    grid-area: map;
    width: 100%;
    min-height: 280px;
    height: min(42vh, 360px);
    order: unset;
  }

  .dd-finder .map-container {
    width: 100%;
    height: 100%;
    min-height: 280px;
  }

  .dd-finder .search-panel {
    grid-area: panel;
    width: 100%;
    max-height: none;
    overflow: visible;
    padding: 1rem !important;
  }

  .dd-finder-fields {
    grid-template-columns: 1fr;
  }

  .dd-finder .filter-pills {
    flex-wrap: wrap;
  }

  .dd-finder .dietitian-card {
    max-width: 100%;
  }

  .dd-finder .dietitian-body {
    flex-wrap: wrap;
  }

  /*
   * ~3 card previews, then scroll inside #dietitians-container only.
   */
  .dd-finder .dietitians-list {
    flex: none;
    min-height: 0;
    width: 100%;
    max-height: calc(3 * 8.5rem + 2 * 1rem);
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    scrollbar-gutter: stable;
    border: 1px solid var(--border-color, #e8e2d9);
    border-radius: var(--radius-md, 12px);
    padding: 0.65rem;
    background: rgba(255, 255, 255, 0.55);
  }
}

@media (max-width: 576px) {
  .dd-finder .map-wrapper {
    height: min(38vh, 300px);
    min-height: 240px;
  }

  .dd-finder .map-container {
    min-height: 240px;
  }

  .dd-finder .search-panel h3 {
    font-size: 1.05rem;
  }

  .dd-finder .dietitian-actions {
    min-width: 0;
    width: 100%;
  }
}

/* Narrow desktop column: stack fields if the left rail is tight */
@media (min-width: 992px) and (max-width: 1100px) {
  .dd-finder-fields {
    grid-template-columns: 1fr;
  }
}
