/* ==========================================================================
   resources.css - Recovery Resources interactive map widget.
   Tokens, base typography, buttons, badges, spinner and state blocks now
   live in the foundation files (tokens/base/components). This file holds the
   map, resource cards, filters, table and view-toggle. Load after foundation.
   ========================================================================== */

/* Resource list scroll container (moved here from the old cards.css) */
#cards-container {
    max-height: 4224px;
    overflow: auto;
    padding-left: 50px;
    padding-right: 50px;
}

/* ============================================
   Scroll containers (cards list and table)
   Do not set scrollbar-color/scrollbar-width here: any non-auto value makes
   Chrome ignore every ::-webkit-scrollbar-* rule below.
   ============================================ */
#cards-container::-webkit-scrollbar,
.results-page .table-responsive::-webkit-scrollbar {
    width: 16px;
    height: 16px;
}

#cards-container::-webkit-scrollbar-button,
.results-page .table-responsive::-webkit-scrollbar-button {
    display: none;
}

#cards-container::-webkit-scrollbar-track,
.results-page .table-responsive::-webkit-scrollbar-track {
    border-radius: 8px;
    background-color: #e7e7e7;
    border: 1px solid #cacaca;
}

#cards-container::-webkit-scrollbar-thumb,
.results-page .table-responsive::-webkit-scrollbar-thumb {
    border-radius: 8px;
    border: 3px solid transparent;
    background-clip: content-box;
    background-color: var(--primary-purple);
    cursor: pointer;
}

/* Resource-app headings are purple (brand secondary) */
h1, h2, h3, h4, h5, h6 {
    color: var(--primary-purple);
}

/* ============================================
   Button shape (results page only)
   The site-wide .btn shape in components.css is too decorative for the
   dense map UI, so restore Bootstrap's own radius. The shared header and
   footer keep the brand shape.
   ============================================ */
.results-page .btn {
    border-radius: var(--bs-btn-border-radius, var(--bs-border-radius)) !important;
}

.results-page header .btn,
.results-page footer .btn {
    border-radius: 2px 2px 0 15px !important;
}

/* ============================================
   Resource Type Badges (reference tokens)
   ============================================ */
.badge-recovery { background-color: var(--resource-recovery); color: white !important; }
.badge-family { background-color: var(--resource-family); color: white !important; }
.badge-housing { background-color: var(--resource-housing); color: white !important; }
.badge-transportation { background-color: var(--resource-transportation); color: white !important; }

/* ============================================
   Search Section
   ============================================ */
.search-section {
  background: linear-gradient(135deg, var(--light-purple-bg) 0%, #e8d5e6 100%);
  padding: 80px 0;
  min-height: 60vh;
  display: flex;
  align-items: center;
}

.search-section h1 {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.search-section h5 {
  color: #555;
  font-weight: 400;
  max-width: 600px;
  margin: 0 auto 2rem;
}

/* ============================================
   Hero Section
   ============================================ */
.hero-section h1 {
  font-size: 3rem;
  margin-bottom: 1rem;
}

/* ============================================
   Map control / sidenav buttons
   ============================================ */
.search-toggle-btn,
.filter-toggle-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background-color: var(--primary-purple);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.2s ease, background-color 0.2s ease;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.search-toggle-btn:hover,
.filter-toggle-btn:hover {
  transform: scale(1.05);
  background-color: #44207a;
}

.map-fly-btn {
  background-color: transparent;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.map-fly-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sidenav-button {
  color: white;
  text-decoration: none;
  transition: background-color 0.2s;
  border-radius: 0;
  font-size: 1.75rem;
  padding: 0.5rem;
}

/* ============================================
   Search Controls
   ============================================ */
.search-controls {
  background: #fff;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 4px 20px rgba(85, 41, 138, 0.15);
  max-width: 600px;
  margin: 0 auto;
}

/* Base input group styling */
.input-group {
    background-color: #E6E6FA; /* lavender */
    border: 1px solid #ced4da;
    border-radius: .375rem;
    overflow: hidden;
    transition:
        background-color .2s ease,
        border-color .2s ease,
        box-shadow .2s ease;
}

.input-group > * {
    background-color: transparent !important;
}

.input-group .form-control,
.input-group .form-select {
    border: none;
    box-shadow: none !important;
}

.input-group:hover {
    border-color: #b3b3d1;
}

.input-group:focus-within {
    background-color: #ffffff;
    border-color: #86b7fe;
    box-shadow: 0 0 0 .25rem rgba(13, 110, 253, .25);
}

/* ============================================
   County Quick Links
   ============================================ */
.county-links {
  margin-top: 2rem;
}

.county-links .btn {
  margin: 0.25rem;
  border-radius: 20px;
  padding: 0.5rem 1.25rem;
}

/* ============================================
   Resource Cards
   ============================================ */
.resourceCard {
  border: 1px solid #d5d6d8;
  border-radius: 1px;
  box-shadow: 0 4px 13px rgba(84, 41, 137, .1);
  transition: all .4s ease;

  @media (max-width: 768px) {
    .card-sidenav {
      min-height: 120px;
    }
  }
}

.resourceCard:hover {
  transform: translateY(-5px);
  box-shadow: 0 4px 13px rgba(84, 41, 137, .25);
  border: 1px solid #55298a;
}

.resourceCard[data-longitude]:hover .card-body::after {
  content: "Click map icon to view location";
  position: absolute;
  bottom: 10px;
  left: 20px;
  background: rgba(85, 41, 138, 0.9);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  pointer-events: none;
  z-index: 10;
}

.card-body {
  position: relative;
}

.card-sidenav {
  background: #55298a;
  border-radius: 1px 0 0 1px;
  min-height: 200px;
  max-width: 80px;
}

.card-sidenav a {
  color: white;
  text-decoration: none;
  transition: background-color 0.2s;
  border-radius: 0;
  font-size: 1.75rem;
  padding: 0.5rem;
}

.card-sidenav > button {
  color: white;
  text-decoration: none;
  transition: background-color 0.2s;
  border-radius: 0;
}

.card-sidenav a:hover {
  background-color: #f5ebf3;
  color: #55298a;
}

.card-sidenav a:first-child {
  border-radius: 1px 0 0 0;
}

.card-sidenav a:last-child {
  border-radius: 0 0 0 1px;
}

.cardImage {
    max-height: 100px;
    height: 100px;
    width: auto;
    max-width: 200px;
    border-radius: 4px;
    object-fit: contain;
    bottom: 0;
    right: 0;
}

/* Loading skeleton image block - matches .cardImage footprint */
.skeleton-image {
    display: inline-block;
    height: 100px;
    width: 120px;
    border-radius: 4px;
}

.card-body h3 {
  color: #55298a;
  margin-bottom: 0.5rem;
  line-height: 1em;
}

/* ============================================
   Map Container
   ============================================ */
.map-container {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  position: relative;
}

#map {
  width: 100%;
  height: 400px;
}

@media (min-width: 768px) {
  #map {
    height: 450px;
  }
}

/* Map Controls Styling - circular purple buttons */
.maplibregl-ctrl-group {
  background-color: transparent !important;
  box-shadow: none !important;
}

.maplibregl-ctrl-group button {
  flex-shrink: 0 !important;
  width: 44px !important;
  height: 44px !important;
  background: #55298a;
  color: white;
  border: none;
  border-radius: 50% !important;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.3s ease, transform 0.2s ease;
  z-index: 2;
  margin-bottom: 8px;
}

.maplibregl-ctrl-group button:last-child {
  margin-bottom: 0;
}

.maplibregl-ctrl-group button:hover {
  background: #20cb98;
  transform: scale(1.05);
}

.maplibregl-ctrl-group button:active {
  background: #20cb98;
  transform: scale(0.98);
}

.maplibregl-ctrl-group button:focus {
  border-radius: 50% !important;
}

.maplibregl-ctrl-group button i {
  color: white;
  pointer-events: none;
  font-size: 18px;
}

.maplibregl-ctrl-group button.maplibregl-ctrl-zoom-in,
.maplibregl-ctrl-group button.maplibregl-ctrl-zoom-out {
  background-image: none !important;
}

/* Search Control on Map */
.search-control {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 1000;
}

.search-control-btn {
  background: #fff;
  border: 2px solid var(--primary-purple);
  border-radius: 24px;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  color: var(--primary-purple);
  font-weight: 500;
}

.search-control-btn:hover {
  background-color: var(--primary-purple);
  color: #fff;
}

.search-control-btn i {
  font-size: 1rem;
}

/* Filter Panel Control */
.filter-panel-control {
  position: absolute;
  top: 10px;
  right: 60px;
  z-index: 1000;
}

/* Map Popup */
.map-popup-container {
  max-width: 300px;
  padding: 0.5rem;
}

.map-popup-container h6 {
  color: var(--primary-purple);
  margin-bottom: 0.5rem;
}

.map-popup-container p {
  margin-bottom: 0.25rem;
  font-size: 0.9rem;
}

.maplibregl-popup-content {
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 1rem;
}

.maplibregl-popup-close-button {
  font-size: 1.25rem;
  padding: 0.25rem 0.5rem;
  color: #666;
}

.maplibregl-popup-close-button:hover {
  color: var(--primary-purple);
  background: none;
}

/* ============================================
   Filters
   ============================================ */
.filter-dropdown-btn {
  background: #fff;
  border: 1px solid #ddd;
  border-radius: 8px;
  padding: 0.5rem 1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 120px;
  transition: border-color 0.2s ease;
}

.filter-dropdown-btn:hover,
.filter-dropdown-btn:focus {
  border-color: var(--primary-purple);
}

.filter-dropdown-btn.show {
  border-color: var(--primary-purple);
  box-shadow: 0 0 0 2px rgba(85, 41, 138, 0.2);
}

.filter-count-badge {
  background-color: var(--primary-purple);
  color: #fff;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  margin-left: 0.5rem;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  background-color: var(--light-purple-bg);
  color: var(--primary-purple);
  padding: 0.25rem 0.5rem 0.25rem 0.75rem;
  border-radius: 20px;
  font-size: 0.85rem;
  margin: 0.25rem;
  gap: 0.25rem;
}

.filter-chip button {
  background: none;
  border: none;
  color: var(--primary-purple);
  cursor: pointer;
  padding: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s ease;
}

.filter-chip button:hover {
  background-color: rgba(85, 41, 138, 0.2);
}

.filter-section {
  border-bottom: 1px solid #eee;
  padding: 1rem 0;
}

.filter-section:last-child {
  border-bottom: none;
}

.filter-option {
  padding: 0.5rem 0;
}

.filter-option label {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dropdown-item-check {
  padding: 0.5rem 1rem;
  cursor: pointer;
}

.dropdown-item-check:hover {
  background-color: var(--light-purple-bg);
}

.dropdown-item-check input[type="checkbox"] {
  accent-color: var(--primary-purple);
  width: 18px;
  height: 18px;
}

.form-check-input:checked {
  background-color: #5b2ca0;
  border-color: #5b2ca0;
}

.dropdown-menu {
  max-height: 300px;
  overflow-y: auto;
  min-width: 200px;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* ============================================
   Table
   ============================================ */
.table-container {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
  overflow: hidden;
}

.table {
  margin-bottom: 0;
}

.table thead th {
  background-color: var(--primary-purple);
  color: #fff;
  border: none;
  border-right: 1px solid #fff;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color 0.2s ease;
  position: relative;
  resize: horizontal;
  overflow: hidden;
  min-width: 100px;
  padding: 0;
  vertical-align: middle;
}

.table thead th:last-child {
  border-right: none;
}

.table thead th:hover {
  background-color: #44207a;
}

.table tbody tr {
  transition: background-color 0.2s ease;
}

.table-row-clickable {
  cursor: pointer;
}

.table-row-clickable:hover {
  background-color: var(--light-purple-bg);
}

.table tbody td {
  height: 40px;
  padding: 0px 0.5rem;
  vertical-align: middle;
  white-space: nowrap;
}

.table-responsive {
  border-radius: 12px;
}

/* Table Header Controls */
.table-th-content {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 0.25rem;
  min-width: 100%;
}

.table-th-sort {
  appearance: none;
  background: transparent;
  border: 0;
  color: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1 1 auto;
  min-width: 0;
  padding: 1rem 0.25rem 1rem 1rem;
  text-align: left;
}

.table-th-sort:hover,
.table-th-sort:focus-visible {
  outline: none;
}

.sort-indicator {
  align-items: center;
  display: inline-flex;
  flex: 0 0 1.5rem;
  height: 1.5rem;
  justify-content: center;
  width: 1.5rem;
}

.sort-indicator i {
  color: #fff;
  font-size: 1rem;
  line-height: 1;
}

.table-th-title {
  display: block;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.table-th-menu {
  align-items: center;
  display: flex;
  flex: 0 0 auto;
}

.table-th-menu-btn {
  appearance: none;
  background: transparent;
  border: 0;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  min-height: 48px;
  padding: 0 0.75rem;
  transition: background-color 0.2s ease;
}

.table-th-menu-btn:hover,
.table-th-menu-btn:focus-visible,
.table-th-menu-btn[aria-expanded="true"] {
  outline: none;
}

.table-th-menu-icon-open {
  display: none;
}

.table-th-menu-btn[aria-expanded="true"] .table-th-menu-icon-closed {
  display: none;
}

.table-th-menu-btn[aria-expanded="true"] .table-th-menu-icon-open {
  display: inline-block;
}

.table-column-menu {
  min-width: 210px;
  padding: 0.35rem;
}

.table-column-menu .dropdown-item {
  align-items: center;
  border-radius: 6px;
  display: flex;
  font-size: 0.95rem;
  gap: 0.25rem;
  padding: 0.55rem 0.75rem;
}

.table-column-menu .dropdown-item.active,
.table-column-menu .dropdown-item:active {
  background-color: var(--primary-purple);
  color: #fff;
}

/* Per-column value filter (facet columns) - two-pane menu */
.table-column-menu.filter-menu {
  width: auto;
  min-width: 280px;
  max-width: 92vw;
}

.table-column-menu.filter-menu.show {
  display: flex;
  flex-direction: column;
  max-height: 85vh;
}

.table-column-menu.filter-menu > li {
  display: flex;
  flex: 1 1 auto;
  min-height: 0;
}

.table-column-menu.filter-menu > li > .d-flex {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

/* Options pane (sort + clear) */
.table-column-filter-sortpane {
  flex-shrink: 0;
  min-width: 200px;
}

.table-column-filter-sortpane .list-group-item {
  background: transparent;
}

.table-column-filter-sortpane .dropdown-item {
  border-radius: 6px;
  white-space: nowrap;
}

.table-column-filter-sortpane .dropdown-item:hover,
.table-column-filter-sortpane .dropdown-item:focus {
  background-color: var(--light-purple-bg);
  color: var(--primary-purple);
}

/* Funnel-with-x "Clear" icon */
.clear-icon {
  width: 1em;
  height: 1em;
  font-size: 1rem;
}

.clear-icon .bi-x-circle-fill {
  right: -0.25em;
  bottom: -0.15em;
  font-size: 0.62em;
  color: var(--primary-purple);
  background: #fff;
  border-radius: 50%;
}

/* Filter pane (search + list + actions) */
.table-column-filter {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-height: 0;
  min-width: 290px;
}

@media (min-width: 768px) {
  .table-column-filter {
    max-width: 340px;
  }
}

.table-column-filter-search,
.table-column-filter-actions {
  flex-shrink: 0;
}

.table-column-filter-search .form-control:focus {
  border-color: #ced4da;
  box-shadow: none;
}

.table-column-filter-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: 230px;
}

.table-column-filter-list .check-row {
  border-radius: 6px;
  cursor: pointer;
  margin: 0;
  padding: 0.3rem 0.4rem;
}

.table-column-filter-list .check-row:hover {
  background-color: var(--light-purple-bg);
}

.table-column-filter-selectall {
  border-bottom: 1px solid #e9ecef;
  border-radius: 0 !important;
  margin-bottom: 0.25rem !important;
  padding-bottom: 0.45rem !important;
}

.table-column-filter-list .filter-label {
  font-size: 0.9rem;
  word-break: break-word;
}

.table-column-filter-list .filter-count {
  color: #6c757d;
  font-size: 0.8rem;
  white-space: nowrap;
}

/* ============================================
   View Toggle
   ============================================ */
.view-toggle {
  display: inline-flex;
  background: #fff;
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.view-toggle-btn {
  background: none;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #666;
}

.view-toggle-btn:hover {
  color: var(--primary-purple);
}

.view-toggle-btn.active {
  background-color: var(--primary-purple);
  color: #fff;
}

/* ============================================
   Pagination
   ============================================ */
.pagination .page-link {
  color: var(--bs-primary);
  border-color: #ddd;
}

.pagination .page-item.active .page-link {
  background-color: var(--primary-purple);
  border-color: var(--primary-purple);
  color: #fff;
}

.pagination .page-link:hover {
  background-color: var(--light-purple-bg);
  border-color: var(--primary-purple);
  color: var(--primary-purple);
}

.pagination .page-item.disabled .page-link {
  color: #ccc;
}

/* ============================================
   Modal
   ============================================ */
.modal-header {
  border-bottom: none;
  padding-bottom: 0;
}

.modal-title {
  color: var(--primary-purple);
}

.modal-body {
  padding-top: 0.5rem;
}

.modal-footer {
  border-top: none;
}

/* ============================================
   Back to Map Button (Mobile)
   ============================================ */
.back-to-map-btn {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 1000;
  background-color: var(--primary-purple);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  cursor: pointer;
  transition: transform 0.2s ease;
}

.back-to-map-btn:hover {
  transform: scale(1.1);
}

@media (max-width: 575px) {
  .back-to-map-btn.visible {
    display: flex;
  }
}

/* ============================================
   Keyboard Shortcut Display
   ============================================ */
.kbd-wrapper {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
}

.kbd-wrapper kbd {
  background-color: #eee;
  border-radius: 4px;
  padding: 0.15rem 0.4rem;
  font-size: 0.8rem;
  color: #666;
}

@media (max-width: 768px) {
  .kbd-wrapper {
    display: none;
  }
}

/* ============================================
   Active filter chips container
   ============================================ */
.active-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  padding: 0.5rem 0;
}

.clear-all-btn {
  background: none;
  border: none;
  color: var(--primary-purple);
  cursor: pointer;
  font-size: 0.85rem;
  padding: 0.25rem 0.5rem;
  text-decoration: underline;
}

.clear-all-btn:hover {
  color: #44207a;
}

/* ============================================
   Responsive Adjustments
   ============================================ */
@media (max-width: 768px) {
  .hero-section {
    padding: 40px 0;
    min-height: auto;
  }

  .hero-section h1 {
    font-size: 2rem;
  }

  .filter-dropdown-btn {
    min-width: 100px;
    font-size: 0.9rem;
    padding: 0.4rem 0.75rem;
  }
}

@media (max-width: 575px) {
  .search-controls {
    padding: 0.75rem;
  }

  #searchbar .form-control {
    font-size: 1rem;
    padding: 0.5rem 0.75rem;
  }

  .resourceCard .card-body {
    padding: 1rem !important;
  }

  .card-title {
    font-size: 1.1rem;
  }
}
