/* =============================================
   CSS Reset & Base
   ============================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'Helvetica Neue', Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: #333;
  background: #fff;
  -webkit-font-smoothing: antialiased;
}

#app {
  max-width: 900px;
  margin: 0 auto;
  padding: 16px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

/* =============================================
   Logo Header
   ============================================= */
.directory-header {
  padding: 8px 0 16px;
  border-bottom: 1px solid #eee;
  margin-bottom: 16px;
}

.header-logo {
  max-width: 280px;
  height: auto;
}

.directory-title {
  font-size: 20px;
  font-weight: 600;
  color: #333;
  margin-top: 8px;
}

/* =============================================
   Loading State
   ============================================= */
.loading {
  text-align: center;
  padding: 60px 20px;
  color: #666;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e0e0e0;
  border-top-color: #ff5050;
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* =============================================
   Error State
   ============================================= */
.error-message {
  text-align: center;
  padding: 40px 20px;
  color: #c0392b;
}

.error-message button {
  margin-top: 12px;
  padding: 8px 24px;
  background: #ff5050;
  color: #fff;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
}

/* =============================================
   Search Section
   ============================================= */
.search-section {
  margin-bottom: 16px;
}

.search-bar {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.search-bar input {
  flex: 1;
  max-width: 220px;
  padding: 10px 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s;
}

.search-bar input:focus {
  border-color: #ff5050;
  box-shadow: 0 0 0 2px rgba(255, 80, 80, 0.15);
}

.search-bar button {
  padding: 10px 20px;
  background: #ff5050;
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.search-bar button:hover {
  background: #e0413e;
}

.clear-btn {
  background: #e0e0e0 !important;
  color: #333 !important;
}

.clear-btn:hover {
  background: #ccc !important;
}

/* =============================================
   Filter Toggle & Panel
   ============================================= */
.filter-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 0;
  background: none;
  border: none;
  color: #ff5050;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
}

.filter-toggle .chevron {
  transition: transform 0.2s;
}

.filter-toggle.open .chevron {
  transform: rotate(180deg);
}

#active-filter-count {
  font-size: 12px;
  background: #ff5050;
  color: #fff;
  border-radius: 10px;
  padding: 1px 7px;
  display: none;
}

.filters {
  background: #f8f9fa;
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 16px;
  margin-top: 8px;
}

.filter-group {
  margin-bottom: 12px;
}

.filter-group:last-of-type {
  margin-bottom: 16px;
}

.filter-group h3 {
  font-size: 13px;
  font-weight: 600;
  color: #555;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.filter-options {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filter-options label {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid #d0d0d0;
  border-radius: 16px;
  font-size: 13px;
  color: #555;
  cursor: pointer;
  transition: all 0.15s;
  user-select: none;
}

.filter-options label:hover {
  border-color: #ff5050;
  color: #ff5050;
}

.filter-options input[type="checkbox"] {
  display: none;
}

.filter-options label.active {
  background: #fff0f0;
  border-color: #ff5050;
  color: #ff5050;
  font-weight: 500;
}

.clear-filters-btn {
  padding: 6px 14px;
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
  color: #666;
  cursor: pointer;
}

.clear-filters-btn:hover {
  border-color: #999;
  color: #333;
}

/* =============================================
   Results Summary & View Toggle
   ============================================= */
.results-summary {
  padding: 8px 0;
  font-size: 14px;
  color: #666;
  border-bottom: 1px solid #eee;
  margin-bottom: 12px;
}

.distance-note {
  font-size: 12px;
  color: #999;
  margin-top: 4px;
}

.results-summary-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.view-toggle {
  padding: 4px 12px;
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  font-size: 13px;
  color: #666;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.view-toggle:hover {
  border-color: #ff5050;
  color: #ff5050;
}

/* =============================================
   Provider Cards
   ============================================= */
.results-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  user-select: none;
  -webkit-user-select: none;
}

.results-list a {
  user-select: text;
  -webkit-user-select: text;
}

.provider-card {
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 16px;
  background: #fff;
  transition: box-shadow 0.15s;
}

.provider-card:hover {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
}

.provider-name {
  font-size: 17px;
  font-weight: 600;
  color: #222;
}

.provider-org {
  font-size: 13px;
  color: #888;
  margin-top: 2px;
}

.distance-badge {
  font-size: 13px;
  font-weight: 600;
  color: #ff5050;
  background: #fff0f0;
  padding: 3px 10px;
  border-radius: 12px;
  white-space: nowrap;
  flex-shrink: 0;
  margin-left: 12px;
}

.provider-location {
  font-size: 14px;
  color: #555;
  margin-bottom: 10px;
}

.provider-contact {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 14px;
}

.provider-contact a {
  color: #ff5050;
  text-decoration: none;
}

.provider-contact a:hover {
  text-decoration: underline;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 6px;
}

.tag-row:last-child {
  margin-bottom: 0;
}

.tag {
  display: inline-block;
  font-size: 12px;
  padding: 2px 8px;
  border-radius: 10px;
  background: #f0f0f0;
  color: #555;
}

.tag.credential {
  background: #fff0f0;
  color: #ff5050;
}

.tag.treatment {
  background: #f0f7e6;
  color: #4a7c23;
}

.tag.specialty {
  background: #e8f0fe;
  color: #1a56db;
}

.tag.also-offers {
  background: #f3f0ff;
  color: #6d28d9;
}

/* =============================================
   Card Extra Fields (clinician-specific)
   ============================================= */
.card-extra {
  font-size: 13px;
  color: #555;
  margin-top: 8px;
}

.card-extra-label {
  font-weight: 600;
  color: #666;
}

.card-extra .tag-row {
  margin-top: 4px;
}

/* =============================================
   Compact View
   ============================================= */
.compact-list {
  display: grid;
  grid-template-columns: minmax(120px, 3fr) minmax(80px, 2fr) auto auto;
  row-gap: 0;
  overflow: hidden;
}

.compact-list.has-distance {
  grid-template-columns: minmax(120px, 3fr) minmax(80px, 2fr) auto auto auto;
}

.compact-list.has-type {
  grid-template-columns: minmax(120px, 3fr) auto minmax(80px, 2fr) auto auto;
}

.compact-list.has-type.has-distance {
  grid-template-columns: minmax(120px, 3fr) auto minmax(80px, 2fr) auto auto auto;
}

.compact-row {
  display: contents;
}

.compact-cell {
  display: flex;
  align-items: center;
  padding: 8px 0 8px 12px;
  border-bottom: 1px solid #eee;
  font-size: 14px;
}

.compact-name {
  padding-left: 0;
  min-width: 0;
}

.compact-name .provider-name {
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.compact-type {
  white-space: nowrap;
}

.compact-location {
  color: #555;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compact-distance .distance-badge {
  margin-left: 0;
}

.compact-row:last-child .compact-cell {
  border-bottom: none;
}

.compact-phone a {
  color: #ff5050;
  text-decoration: none;
  white-space: nowrap;
}

.compact-phone a:hover {
  text-decoration: underline;
}

.compact-website a {
  color: #ff5050;
  text-decoration: none;
  white-space: nowrap;
}

.compact-website a:hover {
  text-decoration: underline;
}

/* =============================================
   Show More Button
   ============================================= */
.show-more-btn {
  display: block;
  width: 100%;
  padding: 10px;
  margin-top: 12px;
  background: none;
  border: 1px solid #ff5050;
  border-radius: 4px;
  color: #ff5050;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.show-more-btn:hover {
  background: #fff0f0;
}

.capped-message {
  text-align: center;
  color: #595959;
  font-size: 13px;
  margin-top: 16px;
  padding: 0 12px;
  line-height: 1.5;
}

/* =============================================
   Initial Prompt (before search)
   ============================================= */
.initial-prompt {
  text-align: center;
  padding: 40px 20px;
}

.initial-prompt-text {
  font-size: 18px;
  color: #555;
  margin-bottom: 8px;
}

.initial-prompt-count {
  font-size: 14px;
  color: #999;
}

/* =============================================
   No Results
   ============================================= */
.no-results {
  text-align: center;
  padding: 40px 20px;
  color: #888;
}

.no-results p:first-child {
  font-size: 16px;
  margin-bottom: 8px;
}

/* =============================================
   Copyright Footer
   ============================================= */
.directory-footer {
  margin-top: 24px;
  padding: 16px 0;
  border-top: 1px solid #eee;
  font-size: 12px;
  color: #595959;
  text-align: center;
}

/* =============================================
   Type Toggle (unified directory)
   ============================================= */
.type-toggle {
  display: flex;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 8px;
}

.type-btn {
  flex: 1;
  padding: 8px 16px;
  background: #fff;
  border: none;
  border-right: 1px solid #d0d0d0;
  font-size: 14px;
  font-weight: 500;
  color: #555;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.type-btn:last-child {
  border-right: none;
}

.type-btn:hover {
  background: #f8f9fa;
}

.type-btn.active {
  background: #ff5050;
  color: #fff;
}

/* Type Badge (on provider cards) */
.type-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 10px;
  margin-left: 8px;
  vertical-align: middle;
}

.type-badge.type-therapist {
  background: #f0f7e6;
  color: #4a7c23;
}

.type-badge.type-clinician {
  background: #e8f0fe;
  color: #1a56db;
}

/* =============================================
   Responsive
   ============================================= */
@media (max-width: 600px) {
  #app {
    padding: 12px;
  }

  .search-bar {
    flex-wrap: wrap;
  }

  .search-bar input {
    max-width: none;
    width: 100%;
  }

  .search-bar button {
    flex: 1;
  }

  .card-header {
    flex-direction: column;
  }

  .distance-badge {
    margin-left: 0;
    margin-top: 4px;
    align-self: flex-start;
  }

  .provider-contact {
    flex-direction: column;
    gap: 4px;
  }

  .compact-list,
  .compact-list.has-distance {
    display: flex;
    flex-direction: column;
  }

  .compact-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid #eee;
  }

  .compact-row:last-child {
    border-bottom: none;
  }

  .compact-cell {
    padding: 0;
    border-bottom: none;
  }

  .compact-name {
    min-width: 0;
  }

  .compact-cell:empty {
    display: none;
  }

  .compact-website {
    flex-basis: 100%;
  }

  .header-logo {
    max-width: 220px;
  }

  .type-btn {
    padding: 8px 8px;
    font-size: 13px;
  }
}
