/* ==========================================================================
   Resource Search — Module-specific styles
   Card, button & tag styles come from the theme (_resource.scss).
   This file only covers: header, filters, offcanvas, results area, pagination.

   Theme colors:
   Purple: #5B2B6B  Teal: #08B29F  Green: #A5BA39  Yellow: #F7B519
   ========================================================================== */

:root {
  --rs-purple: #5B2B6B;
  --rs-purple-light: #845694;
  --rs-purple-dark: #321542;
  --rs-purple-bg: #f3edf5;
  --rs-teal: #08B29F;
  --rs-teal-bg: #e6f7f5;
  --rs-text: #1a1a1a;
  --rs-text-muted: #6c757d;
  --rs-border: #dee2e6;
}

/* -- Header -- */
.rs-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.rs-header__left {
  display: flex;
  align-items: baseline;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.rs-header__title {
  font-size: 1.75rem;
  font-weight: 800;
  margin: 0;
  line-height: 1.2;
  color: var(--rs-text);
}

.rs-header__count {
  color: var(--rs-text-muted);
  font-size: 0.95rem;
  font-weight: 400;
}

.rs-header__right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  position: relative;
}

.rs-header__sort-label {
  font-size: 0.9rem;
  color: var(--rs-text-muted);
}

.rs-sort-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.9rem;
  color: var(--rs-text);
  padding: 0;
}

.rs-sort-btn strong {
  font-weight: 600;
}

.rs-sort-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.35rem;
  background: #fff;
  border: 1px solid var(--rs-border);
  border-radius: 0.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  min-width: 140px;
  z-index: 100;
  padding: 0.25rem 0;
}

.rs-sort-dropdown__item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  padding: 0.5rem 1rem;
  text-align: left;
  font-size: 0.875rem;
  color: #333;
  cursor: pointer;
}

.rs-sort-dropdown__item:hover {
  background: var(--rs-purple-bg);
}

.rs-sort-dropdown__item--active {
  font-weight: 600;
  color: var(--rs-purple);
}

/* -- Keyword search banner -- */
.rs-keyword-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 1rem;
  background: var(--rs-teal-bg);
  border: 1px solid #b2e0db;
  border-radius: 0.5rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
}

.rs-keyword-banner__text {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #333;
}

.rs-keyword-banner__text svg {
  color: var(--rs-teal);
  flex-shrink: 0;
}

.rs-keyword-banner__clear {
  background: none;
  border: none;
  color: var(--rs-text-muted);
  font-size: 0.8rem;
  cursor: pointer;
  white-space: nowrap;
  padding: 0.2rem 0.5rem;
  border-radius: 0.25rem;
}

.rs-keyword-banner__clear:hover {
  color: #dc3545;
  background: rgba(220, 53, 69, 0.06);
}

/* -- Filter bar (pill row) -- */
.rs-filters {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

/* -- Pill buttons -- */
.rs-pill-wrap {
  position: relative;
}

.rs-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  height: 38px;
  padding: 0 0.9rem;
  border: 1.5px solid var(--rs-border);
  border-radius: 999px;
  background: #fff;
  font-size: 0.875rem;
  font-weight: 500;
  color: #333;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
  line-height: 1;
}

.rs-pill:hover {
  border-color: #bbb;
}

.rs-pill--active {
  background: var(--rs-purple-bg);
  border-color: #b89cc5;
  color: var(--rs-purple);
}

.rs-pill--active:hover {
  border-color: #9a78ad;
}

.rs-pill__label {
  pointer-events: none;
}

.rs-pill__clear {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(91, 43, 107, 0.15);
  color: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  margin-left: 0.1rem;
}

.rs-pill__clear:hover {
  background: rgba(91, 43, 107, 0.3);
}

.rs-pill__chevron {
  flex-shrink: 0;
  opacity: 0.5;
}

.rs-pill__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  border-radius: 999px;
  background: var(--rs-purple);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0 5px;
}

.rs-pill--all-filters {
  gap: 0.4rem;
}

.rs-pill--all-filters svg {
  flex-shrink: 0;
}

/* -- Pill dropdown -- */
.rs-pill-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 220px;
  max-height: 320px;
  background: #fff;
  border: 1px solid var(--rs-border);
  border-radius: 0.5rem;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
  z-index: 200;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.rs-pill-dropdown__search {
  padding: 0.5rem;
  border-bottom: 1px solid #eee;
}

.rs-pill-dropdown__search-input {
  width: 100%;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--rs-border);
  border-radius: 0.375rem;
  font-size: 0.8rem;
  outline: none;
}

.rs-pill-dropdown__search-input:focus {
  border-color: var(--rs-purple-light);
}

.rs-pill-dropdown__list {
  overflow-y: auto;
  max-height: 260px;
  padding: 0.25rem 0;
}

.rs-pill-dropdown__item {
  display: block;
  width: 100%;
  background: none;
  border: none;
  padding: 0.5rem 0.9rem;
  text-align: left;
  font-size: 0.85rem;
  color: #333;
  cursor: pointer;
  transition: background 0.1s;
}

.rs-pill-dropdown__item:hover {
  background: var(--rs-purple-bg);
}

.rs-pill-dropdown__item--selected {
  font-weight: 600;
  color: var(--rs-purple);
  background: var(--rs-purple-bg);
}

/* -- Offcanvas (All Filters panel) -- */
.rs-offcanvas-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.25);
  z-index: 1040;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
}

.rs-offcanvas-backdrop.show {
  opacity: 1;
  pointer-events: auto;
}

.rs-offcanvas {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 460px;
  max-width: 90vw;
  background: #fff;
  z-index: 1045;
  transform: translateX(100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.08);
}

.rs-offcanvas.show {
  transform: translateX(0);
}

.rs-offcanvas__header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid #eee;
}

.rs-offcanvas__title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--rs-purple);
}

.rs-offcanvas__close {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: #666;
  cursor: pointer;
  padding: 0;
  line-height: 1;
}

.rs-offcanvas__body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1.5rem;
}

.rs-offcanvas__group {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid #eee;
}

.rs-offcanvas__group:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.rs-offcanvas__label {
  display: block;
  font-size: 0.7rem;
  font-weight: 600;
  color: #9ca3af;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.4rem;
}

.rs-offcanvas__select {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1.5px solid var(--rs-border);
  border-radius: 0.5rem;
  font-size: 0.875rem;
  background: #fff;
  outline: none;
  transition: border-color 0.15s;
  appearance: auto;
}

.rs-offcanvas__select:focus {
  border-color: var(--rs-purple-light);
}

/* -- FilterPill inside offcanvas — full width -- */
.rs-offcanvas__pill-wrap {
  display: block;
}

.rs-offcanvas__pill-wrap .rs-pill {
  width: 100%;
  border-radius: 0.5rem;
  height: auto;
  padding: 0.5rem 0.75rem;
}

.rs-offcanvas__pill-wrap .rs-pill__chevron {
  margin-left: auto;
}

.rs-offcanvas__pill-wrap .rs-pill-dropdown {
  min-width: 100%;
}

.rs-offcanvas__footer {
  display: flex;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-top: 1px solid #eee;
  gap: 0.75rem;
}

/* Offcanvas footer buttons — use rs-btn since they're outside the card context */
.rs-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  border: none;
  transition: filter 0.12s ease, transform 0.12s ease;
  white-space: nowrap;
}

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

.rs-btn--primary:hover {
  filter: brightness(1.15);
  color: #fff;
}

.rs-btn--ghost {
  background: transparent;
  color: var(--rs-purple);
  border: 1.5px solid var(--rs-purple);
}

.rs-btn--ghost:hover {
  background: rgba(91, 43, 107, 0.06);
  color: var(--rs-purple);
}

/* -- Curriculum cascading dropdowns -- */
.rs-curriculum {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid #eee;
}

.rs-curriculum__selected {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.4rem 0.7rem;
  background: var(--rs-purple-bg);
  border: 1px solid #b89cc5;
  border-radius: 0.375rem;
  margin-bottom: 0.5rem;
  font-size: 0.8rem;
  color: var(--rs-purple);
  font-weight: 500;
}

.rs-curriculum__selected-clear {
  background: none;
  border: none;
  color: var(--rs-purple);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
}

.rs-curriculum__selected-clear:hover {
  color: #dc3545;
}

.rs-curriculum__dropdowns {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.rs-curriculum__expectations {
  display: flex;
  flex-direction: column;
  gap: 0;
  border: 1px solid var(--rs-border);
  border-radius: 0.5rem;
  overflow: hidden;
  max-height: 200px;
  overflow-y: auto;
}

.rs-curriculum__exp-item {
  display: block;
  width: 100%;
  background: #fff;
  border: none;
  border-bottom: 1px solid #f0f0f0;
  padding: 0.5rem 0.75rem;
  text-align: left;
  font-size: 0.85rem;
  color: #333;
  cursor: pointer;
  transition: background 0.1s;
}

.rs-curriculum__exp-item:last-child {
  border-bottom: none;
}

.rs-curriculum__exp-item:hover {
  background: var(--rs-purple-bg);
}

.rs-curriculum__exp-item--selected {
  font-weight: 600;
  color: var(--rs-purple);
  background: var(--rs-purple-bg);
}

/* -- Card additions (supplement theme styles, don't override) -- */

/* Placeholder for missing thumbnails */
.resource-card__thumb-placeholder {
  width: 100%;
  max-width: 300px;
  height: 200px;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #d1d5db;
}

/* Vue renders <span> items inside meta-value; style them like the li items in _resource.scss */
.resource-card__meta-value > span {
  display: inline-block;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  font-size: 0.8rem;
  font-weight: 600;
  color: #374151;
}

/* Vue renders subject tags as <span> instead of li; match the theme styles */
.resource-tag.resource-tag--english {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(91, 43, 107, 0.1);
  color: #321542;
}

/* -- Results area -- */
.rs-results {
  min-height: 200px;
}

.rs-loading {
  display: flex;
  justify-content: center;
  padding: 3rem 0;
}

.rs-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid #e5e7eb;
  border-top-color: var(--rs-purple);
  border-radius: 50%;
  animation: rs-spin 0.7s linear infinite;
}

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

.rs-empty {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--rs-text-muted);
}

.rs-empty h3 {
  margin: 1rem 0 0.5rem;
  color: #495057;
  font-weight: 600;
}

.rs-empty p {
  color: #999;
}

/* -- Pagination -- */
.rs-pagination {
  margin: 2rem 0;
}

/* -- Responsive -- */
@media (max-width: 767.98px) {
  .rs-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .rs-filters {
    gap: 0.4rem;
  }

  .rs-pill-dropdown {
    position: fixed;
    left: 0.5rem;
    right: 0.5rem;
    top: auto;
    bottom: 0;
    min-width: auto;
    max-height: 50vh;
    border-radius: 0.75rem 0.75rem 0 0;
  }
}
