/* =============================================================================
   DPRTE Supplier Directory — Base Stylesheet
   All rules are scoped under .sd-wrapper or .sd-single to avoid theme conflicts.
   Classes follow BEM: .sd-block__element--modifier
   ============================================================================= */

/* ── Reset / Scope ─────────────────────────────────────────────────────────── */
.sd-wrapper *,
.sd-wrapper *::before,
.sd-wrapper *::after {
  box-sizing: border-box;
}

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

/* ── Toolbar ────────────────────────────────────────────────────────────────── */
.sd-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
  margin-bottom: 24px;
}

.sd-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  flex: 1 1 auto;
  align-items: flex-end;
}

.sd-filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 160px;
}

.sd-filter-group--search {
  flex: 1 1 200px;
}

.sd-filter-group--actions {
  min-width: auto;
  justify-content: flex-end;
}

.sd-filter-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #555;
}

.sd-filter-region,
.sd-filter-category,
.sd-filter-search,
.sd-sort-select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
  background-color: #fff;
  color: #333;
  appearance: auto;
  line-height: 1.4;
}

.sd-filter-region:focus,
.sd-filter-category:focus,
.sd-filter-search:focus,
.sd-sort-select:focus {
  outline: 2px solid #0073aa;
  outline-offset: 1px;
  border-color: #0073aa;
}

/* ── Controls (sort + view toggle) ─────────────────────────────────────────── */
.sd-controls {
  display: flex;
  align-items: flex-end;
  gap: 16px;
  flex-shrink: 0;
}

.sd-sort {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sd-sort-select {
  min-width: 150px;
}

.sd-view-toggle {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sd-view-toggle__buttons {
  display: flex;
  gap: 4px;
  align-items: center;
}

.sd-view-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  color: #999;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.sd-view-btn:hover {
  background: #f5f5f5;
  color: #333;
}

.sd-view-btn.is-active {
  background: #0073aa;
  border-color: #0073aa;
  color: #fff;
}

/* ── Clear Filters Button ───────────────────────────────────────────────────── */
.sd-clear-filters {
  padding: 8px 14px;
  border: 1px solid #ddd;
  border-radius: 4px;
  background: #fff;
  font-size: 0.85rem;
  color: #555;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s, color 0.15s;
}

.sd-clear-filters:hover {
  background: #f0f0f0;
  color: #333;
}

/* ── Sidebar Contact Card ───────────────────────────────────────────────────── */
.sd-contact-card {
  border: 1px solid #e0e0e0;
  border-radius: 6px;
  padding: 16px;
  background: #fff;
  font-size: 0.9rem;
  line-height: 1.5;
  box-sizing: border-box;
}

.sd-contact-card__logo-wrap {
  border-radius: 4px;
  padding: 12px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 80px;
}

.sd-contact-card__logo {
  max-width: 100%;
  max-height: 90px;
  width: auto;
  height: auto;
  object-fit: contain;
}

.sd-contact-card__title {
  margin: 0 0 14px;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.3;
  word-break: break-word;
}

.sd-contact-card__list {
  list-style: none;
  margin: 0 0 16px;
  padding: 0;
}

.sd-contact-card__item {
  margin-bottom: 12px;
}

.sd-contact-card__item:last-child {
  margin-bottom: 0;
}

.sd-contact-card__label {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #888;
  margin-bottom: 3px;
}

.sd-contact-card__value {
  display: block;
  word-break: break-word;
}

.sd-contact-card__value address,
address.sd-contact-card__value {
  font-style: normal;
  margin: 0;
}

.sd-contact-card__btn {
  display: block !important;
  width: 100%;
  text-align: center;
}

/* ── Tags ───────────────────────────────────────────────────────────────────── */
.sd-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.sd-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1.6;
  white-space: nowrap;
}

.sd-tag--region {
  background: #e8f4fd;
  color: #0a5a8a;
}

.sd-tag--category {
  background: #f0f8f0;
  color: #2d6a2d;
}

.sd-tag--more {
  background: #f0f0f0;
  color: #666;
}

/* ── Buttons ────────────────────────────────────────────────────────────────── */
.sd-btn {
  display: inline-block;
  padding: 8px 18px;
  border-radius: 4px;
  font-size: 0.875rem;
  font-weight: 600;
  text-decoration: none;
  text-align: center;
  cursor: pointer;
  transition: background 0.15s, opacity 0.15s;
  border: none;
  line-height: 1.4;
}

.sd-btn--primary {
  background: #0073aa;
  color: #fff;
}

.sd-btn--primary:hover {
  background: #005a87;
  color: #fff;
}

.sd-btn--secondary {
  background: #f0f0f0;
  color: #333;
}

.sd-btn--secondary:hover {
  background: #e0e0e0;
}

.sd-btn--card {
  background: #0073aa;
  color: #fff;
  font-size: 0.8rem;
  padding: 6px 14px;
}

.sd-btn--card:hover {
  background: #005a87;
  color: #fff;
}

/* ── Sticky Section (shared) ────────────────────────────────────────────────── */
.sd-sticky-section {
  margin-bottom: 24px;
}

.sd-sticky-label {
  margin-bottom: 12px;
}

.sd-sticky-label__text {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #888;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 3px;
  padding: 3px 10px;
}

.sd-sticky-divider {
  height: 2px;
  background: #eee;
  margin-top: 24px;
  margin-bottom: 24px;
}

/* ── Sticky Grid ────────────────────────────────────────────────────────────── */
.sd-sticky-grid {
  display: grid;
  gap: 24px;
}

/* Column count — auto-matches sticky count by default, or honours
   the shortcode `featured_grid_col` attribute (1–6). */
.sd-sticky-grid--count-1 { grid-template-columns: 1fr; }
.sd-sticky-grid--count-2 { grid-template-columns: repeat(2, 1fr); }
.sd-sticky-grid--count-3 { grid-template-columns: repeat(3, 1fr); }
.sd-sticky-grid--count-4 { grid-template-columns: repeat(4, 1fr); }
.sd-sticky-grid--count-5 { grid-template-columns: repeat(5, 1fr); }
.sd-sticky-grid--count-6 { grid-template-columns: repeat(6, 1fr); }

/* ── Main Grid ──────────────────────────────────────────────────────────────── */
.sd-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 24px;
}

/* Configurable column count via shortcode `grid_col` attribute (1–6). */
.sd-grid--cols-1 { grid-template-columns: 1fr; }
.sd-grid--cols-2 { grid-template-columns: repeat(2, 1fr); }
.sd-grid--cols-3 { grid-template-columns: repeat(3, 1fr); }
.sd-grid--cols-4 { grid-template-columns: repeat(4, 1fr); }
.sd-grid--cols-5 { grid-template-columns: repeat(5, 1fr); }
.sd-grid--cols-6 { grid-template-columns: repeat(6, 1fr); }

/* ── Cards ──────────────────────────────────────────────────────────────────── */
.sd-card {
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 6px;
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
}

.sd-card:hover {
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  transform: translateY(-2px);
}

.sd-card--featured {
  border-color: #ffe082;
  box-shadow: 0 0 0 2px #ffe082;
}

.sd-card__link {
  display: block;
  text-decoration: none;
}

.sd-card__logo-wrap {
  height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.sd-card__logo {
  max-width: 100%;
  max-height: 88px;
  object-fit: contain;
  display: block;
}

.sd-card__logo-placeholder {
  width: 100%;
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sd-card__logo-placeholder svg {
  width: 100%;
  height: 100%;
}

.sd-card__body {
  padding: 16px;
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.sd-card__title {
  font-size: 1rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.3;
}

.sd-card__title-link {
  color: inherit;
  text-decoration: none;
}

.sd-card__title-link:hover {
  text-decoration: underline;
}

.sd-card__excerpt {
  font-size: 0.875rem;
  color: #555;
  margin: 0;
  line-height: 1.55;
  flex: 1 1 auto;
}

.sd-card__meta {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: auto;
}

.sd-card__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.sd-card__footer {
  padding: 12px 16px;
  border-top: 1px solid #f0f0f0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* ── Table Header ───────────────────────────────────────────────────────────── */
.sd-table-header {
  display: grid;
  grid-template-columns: 90px 1fr 1fr 1fr 40px;
  gap: 0 16px;
  padding: 8px 16px;
  background: #f8f8f8;
  border: 1px solid #e5e5e5;
  border-bottom: 2px solid #ddd;
  border-radius: 6px 6px 0 0;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #666;
}

/* ── Table Rows ─────────────────────────────────────────────────────────────── */
.sd-table {
  border: 1px solid #e5e5e5;
  border-top: none;
  border-radius: 0 0 6px 6px;
  overflow: hidden;
}

.sd-table--sticky {
  border: 1px solid #ffe082;
  border-radius: 6px;
}

.sd-row {
  border-bottom: 1px solid #f0f0f0;
}

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

.sd-row--featured {
  background: #fffef5;
}

.sd-row__header {
  display: grid;
  grid-template-columns: 90px 1fr 1fr 1fr 40px;
  gap: 0 16px;
  padding: 12px 16px;
  align-items: center;
  cursor: pointer;
  transition: background 0.15s;
  user-select: none;
}

.sd-row__header:hover {
  background: #f8f8f8;
}

.sd-row__header[aria-expanded="true"] {
  background: #f0f7fc;
  border-bottom: 1px solid #e0edf5;
}

.sd-row__logo-wrap {
  width: 80px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sd-row__logo {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  box-sizing: border-box;
}

.sd-row__logo-placeholder {
  width: 80px;
  height: 60px;
  background: #f0f0f0;
}

.sd-row__name {
  font-weight: 600;
  font-size: 0.925rem;
  color: #222;
}

.sd-row__cats,
.sd-row__region {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.sd-row__toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  color: #999;
}

.sd-row__toggle-icon {
  display: block;
  transition: transform 0.2s;
}

.sd-row__header[aria-expanded="true"] .sd-row__toggle-icon {
  transform: rotate(180deg);
}

/* Accordion panel */
.sd-row__panel {
  padding: 0 16px;
  overflow: hidden;
  transition: max-height 0.3s ease;
}

.sd-row__panel[hidden] {
  display: none;
}

.sd-row__panel-inner {
  padding: 16px 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.sd-row__excerpt {
  font-size: 0.875rem;
  color: #555;
  margin: 0;
  line-height: 1.55;
}

.sd-row__read-more {
  margin-left: 6px;
  font-size: 0.875rem;
  font-weight: 600;
  white-space: nowrap;
  text-decoration: underline;
}

.sd-row__taxonomy {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 32px;
}

.sd-row__taxonomy-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.sd-row__tag-list {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.sd-row__contact {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 32px;
}

.sd-row__contact-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.sd-row__contact-label {
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #888;
}

.sd-row__contact-item a {
  font-size: 0.875rem;
  color: #0073aa;
}

.sd-row__contact-item address {
  font-size: 0.875rem;
  font-style: normal;
  color: #444;
  line-height: 1.55;
}

.sd-row__actions {
  display: flex;
  gap: 10px;
}

/* ── No Results ─────────────────────────────────────────────────────────────── */
.sd-no-results {
  grid-column: 1 / -1;
  padding: 40px;
  text-align: center;
  color: #888;
  font-size: 1rem;
}

/* ── Load More ──────────────────────────────────────────────────────────────── */
.sd-load-more-wrap {
  margin-top: 32px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.sd-load-more {
  padding: 12px 32px;
  border: 2px solid #0073aa;
  border-radius: 4px;
  background: #fff;
  color: #0073aa;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.sd-load-more:hover {
  background: #0073aa;
  color: #fff;
}

.sd-load-more:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sd-load-more-status {
  font-size: 0.8rem;
  color: #888;
  min-height: 1em;
}

/* ── Loading Spinner (shown during AJAX) ────────────────────────────────────── */
.sd-results-wrap.is-loading {
  position: relative;
  min-height: 100px;
}

.sd-results-wrap.is-loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.sd-spinner {
  display: none;
  width: 32px;
  height: 32px;
  border: 3px solid #e0e0e0;
  border-top-color: #0073aa;
  border-radius: 50%;
  animation: sd-spin 0.7s linear infinite;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 11;
}

.sd-results-wrap.is-loading .sd-spinner {
  display: block;
}

@keyframes sd-spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  /* Grid: any configured column count → 1 col */
  .sd-grid,
  .sd-grid--cols-1,
  .sd-grid--cols-2,
  .sd-grid--cols-3,
  .sd-grid--cols-4,
  .sd-grid--cols-5,
  .sd-grid--cols-6 {
    grid-template-columns: 1fr;
  }

  /* Sticky grid collapses to 1 col on mobile too */
  .sd-sticky-grid--count-2,
  .sd-sticky-grid--count-3,
  .sd-sticky-grid--count-4,
  .sd-sticky-grid--count-5,
  .sd-sticky-grid--count-6 {
    grid-template-columns: 1fr;
  }

  /* Toolbar stacks */
  .sd-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .sd-controls {
    justify-content: space-between;
  }

  /* Table: hide category column on mobile, collapse layout */
  .sd-table-header {
    grid-template-columns: 60px 1fr 40px;
  }

  .sd-table-header__cats,
  .sd-table-header__region {
    display: none;
  }

  .sd-row__header {
    grid-template-columns: 60px 1fr 40px;
  }

  .sd-row__cats,
  .sd-row__region {
    display: none;
  }

}
