/* Shared category filter sidebar */

.page-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 32px;
  align-items: start;
}

/* Filter Sidebar  self-contained theme (not affected by page :root) */
.filter-sidebar {
  --page-card: #ffffff;
  --page-card-border: #e5e7eb;
  --page-text: #161616;
  --page-muted: #6b7280;
  --page-accent: #337ab7;
  --filter-block-bg: #fafbfc;
  --filter-block-border: #e5e7eb;
  --filter-hover-bg: #f1f5f9;
  --filter-reset-bg: #f8fafc;
  --filter-reset-border: #e2e8f0;
  --filter-reset-hover: #f3f4f6;
  --filter-count-bg: #e8eef4;
  --filter-count-text: #64748b;
  --filter-count-hover-bg: #dce6f0;
  --filter-count-hover-text: #475569;
  --filter-checkbox-bg: #ffffff;
  --filter-checkbox-border: #d1d5db;
  --filter-accent-soft: rgba(51, 122, 183, 0.1);
  --filter-accent-border: rgba(51, 122, 183, 0.15);
  --filter-accent-block-bg: rgba(51, 122, 183, 0.04);
  --filter-accent-block-border: rgba(51, 122, 183, 0.35);
  --filter-accent-shadow: rgba(51, 122, 183, 0.08);
  --filter-tree: #94a3b8;
  --filter-tree-fade: #e2e8f0;
  --filter-focus-ring: rgba(51, 122, 183, 0.1);
  --filter-child-hover: rgba(255, 255, 255, 0.7);

  position: sticky;
  top: 24px;
  align-self: start;
  max-height: calc(100vh - 48px);
  overflow: visible;
  background: var(--page-card);
  color: var(--page-text);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  border-radius: 16px;
  border: 1px solid var(--page-card-border);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.03);
}

.filter-sidebar__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--page-card-border);
}

.filter-sidebar__toggle-mobile {
  display: none;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--page-text);
  font-family: "Montserrat", Helvetica, sans-serif;
  transition: color 0.2s ease;
}

.filter-sidebar__toggle-mobile:hover {
  color: var(--page-accent);
}

.filter-sidebar__toggle-mobile-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
}

.filter-sidebar__menu-icon {
  flex-shrink: 0;
  color: var(--page-accent);
}

.filter-sidebar__toggle-label {
  flex: 1;
  text-align: left;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.filter-sidebar__chevron {
  flex-shrink: 0;
  color: var(--page-muted);
  transition: transform 0.25s ease;
}

.filter-sidebar__toggle-mobile[aria-expanded="true"] .filter-sidebar__chevron {
  transform: rotate(180deg);
}

.filter-sidebar__body {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.filter-sidebar__title {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--page-text);
  font-family: "Montserrat", Helvetica, sans-serif;
  display: flex;
  align-items: center;
  gap: 10px;
}

.filter-sidebar__icon {
  color: var(--page-muted);
}

/* Scope dropdown (courses: featured, on sale, etc.) */
.filter-scope {
  width: 100%;
}

.filter-scope__label {
  display: block;
  margin-bottom: 8px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--page-muted);
}

.filter-scope__control {
  position: relative;
  display: block;
  width: 100%;
}

.filter-scope__select {
  display: block;
  width: 100%;
  min-height: 48px;
  padding: 12px 44px 12px 16px;
  border: 1px solid var(--page-card-border);
  border-radius: 10px;
  background-color: #f9fafb;
  color: var(--page-text);
  font-size: 15px;
  font-weight: 500;
  line-height: 1.35;
  font-family: "Montserrat", Helvetica, sans-serif;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: none;
  transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.filter-scope__select:hover {
  border-color: var(--page-accent);
  background-color: #ffffff;
}

.filter-scope__select:focus {
  outline: none;
  border-color: var(--page-accent);
  box-shadow: 0 0 0 3px var(--filter-focus-ring);
  background-color: #ffffff;
}

.filter-scope__control:focus-within .filter-scope__arrow {
  color: var(--page-accent);
}

.filter-scope__arrow {
  position: absolute;
  top: 50%;
  right: 16px;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  pointer-events: none;
  color: var(--page-muted);
  flex-shrink: 0;
}

/* Filter Groups */
.filter-group {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.filter-group__toggle {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: none;
  border: none;
  padding: 8px 0;
  cursor: pointer;
  color: var(--page-text);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.02em;
  transition: color 0.2s ease;
  font-family: "Montserrat", Helvetica, sans-serif;
}

.filter-group__toggle:hover {
  color: var(--page-accent);
}

.filter-sidebar__reset {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  background: var(--filter-reset-bg);
  border: 1px solid var(--filter-reset-border);
  color: var(--page-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 12px 16px;
  border-radius: 12px;
  transition: all 0.2s ease;
  font-family: "Montserrat", Helvetica, sans-serif;
  font-weight: 500;
}

.filter-sidebar__reset.visible {
  display: flex;
}

.filter-sidebar__reset:hover {
  background: var(--filter-reset-hover);
  border-color: var(--page-text);
  color: var(--page-text);
}

.filter-group__label {
  text-align: left;
}

.filter-group__icon {
  transition: transform 0.2s ease;
  color: var(--page-muted);
}

.filter-group__toggle[aria-expanded="false"] .filter-group__icon {
  transform: rotate(-90deg);
}

.filter-group__content {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-left: 4px;
  max-height: min(70vh, 720px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  transition: opacity 0.3s ease, padding 0.3s ease;
  opacity: 1;
}

.filter-group__content--tree {
  gap: 6px;
  padding-left: 0;
}

.filter-group__content[data-collapsed="true"] {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  padding-top: 0;
  padding-bottom: 0;
}

/* Filter Options */
.filter-category-block {
  border-radius: 12px;
  border: 1px solid transparent;
  background: var(--filter-block-bg);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.filter-category-block:hover {
  border-color: var(--filter-block-border);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

.filter-category-block:has(.filter-checkbox:checked) {
  border-color: var(--filter-accent-block-border);
  background: var(--filter-accent-block-bg);
  box-shadow: 0 2px 10px var(--filter-accent-shadow);
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: 10px;
  transition: background 0.2s ease, border-color 0.2s ease;
  position: relative;
  border: 1px solid transparent;
}

.filter-option:hover {
  background: var(--filter-hover-bg);
}

.filter-option:has(.filter-checkbox:checked) {
  background: var(--filter-accent-soft);
  border-color: var(--filter-accent-border);
}

.filter-option--checkbox {
  gap: 12px;
}

.filter-option--parent .filter-option__label {
  font-size: 14px;
  font-weight: 600;
  color: var(--page-text);
}

/* Hide native checkbox */
.filter-checkbox {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

/* Custom checkbox */
.filter-checkbox__custom {
  width: 18px;
  height: 18px;
  border: 2px solid var(--filter-checkbox-border);
  border-radius: 4px;
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
  flex-shrink: 0;
  background: var(--filter-checkbox-bg);
}

.filter-checkbox:checked + .filter-checkbox__custom {
  border-color: var(--page-accent);
  background: var(--page-accent);
}

.filter-checkbox:checked + .filter-checkbox__custom::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  height: 8px;
  border: solid white;
  border-width: 0 2px 2px 0;
  transform: translate(-50%, -60%) rotate(45deg);
}

.filter-checkbox:focus + .filter-checkbox__custom {
  box-shadow: 0 0 0 3px var(--filter-focus-ring);
}

.filter-checkbox__custom--sm {
  width: 16px;
  height: 16px;
  border-radius: 3px;
}

.filter-option__label {
  font-size: 14px;
  color: var(--page-muted);
  line-height: 1.4;
  transition: color 0.2s ease;
  font-family: "Montserrat", Helvetica, sans-serif;
  flex: 1;
  min-width: 0;
}

.filter-option__count {
  flex-shrink: 0;
  min-width: 24px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--filter-count-bg);
  color: var(--filter-count-text);
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  text-align: center;
  font-family: "Montserrat", Helvetica, sans-serif;
  transition: background 0.2s ease, color 0.2s ease;
}

.filter-option:hover .filter-option__count {
  background: var(--filter-count-hover-bg);
  color: var(--filter-count-hover-text);
}

.filter-option:has(.filter-checkbox:checked) .filter-option__count {
  background: var(--page-accent);
  color: #ffffff;
}

.filter-option__count--muted {
  opacity: 0.55;
}

.filter-category-block .filter-option--child {
  background: transparent;
  border-color: transparent;
}

.filter-category-block .filter-option--child:hover {
  background: var(--filter-child-hover);
}

.filter-option:hover .filter-option__label,
.filter-checkbox:checked ~ .filter-option__label {
  color: var(--page-text);
}

.filter-subcategories {
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 4px 10px 10px 34px;
  position: relative;
}

.filter-subcategories::before {
  content: "";
  position: absolute;
  left: 22px;
  top: 0;
  bottom: 10px;
  width: 2px;
  border-radius: 2px;
  background: linear-gradient(180deg, var(--filter-tree) 0%, var(--filter-tree-fade) 100%);
}

.filter-option--child {
  padding: 8px 10px 8px 14px;
  margin-left: 0;
}

.filter-option--child::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 50%;
  width: 10px;
  height: 2px;
  background: var(--filter-tree);
  border-radius: 1px;
  transform: translateY(-50%);
}

.filter-option--child .filter-option__label {
  font-size: 13px;
  font-weight: 500;
}

/* Filter layout  mobile */
@media (max-width: 1024px) {
  .page-layout {
    grid-template-columns: 1fr;
    gap: 24px;
  }

  .filter-sidebar {
    position: static;
    order: -1;
  }

}

@media (max-width: 768px) {
  .filter-sidebar__header {
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding-bottom: 0;
    margin-bottom: 0;
    border-bottom: none;
  }

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

  .filter-sidebar__toggle-mobile {
    display: flex;
    padding: 14px 16px;
    background: var(--filter-reset-bg);
    border: 1px solid var(--filter-reset-border);
    border-radius: 12px;
    box-shadow: 0 1px 2px rgb(15 23 42 / 0.04);
  }

  .filter-sidebar__toggle-mobile:hover {
    border-color: var(--filter-accent-block-border);
    background: var(--filter-checkbox-bg);
    color: var(--page-text);
  }

  .filter-sidebar:not(.collapsed) .filter-sidebar__header {
    margin-bottom: 14px;
    padding-bottom: 14px;
    border-bottom: 1px solid var(--filter-reset-border);
  }

  .filter-sidebar__body {
    overflow: hidden;
    max-height: 2200px;
    opacity: 1;
    transition:
      max-height 0.38s ease,
      opacity 0.28s ease,
      margin 0.28s ease;
  }

  .filter-sidebar.collapsed .filter-sidebar__body {
    max-height: 0;
    opacity: 0;
    margin-top: 0;
    pointer-events: none;
  }

  .filter-sidebar.collapsed .filter-sidebar__reset,
  .filter-sidebar.collapsed .filter-scope {
    display: none !important;
  }
}

@media (min-width: 769px) {
  .filter-sidebar.collapsed .filter-sidebar__body {
    max-height: none !important;
    opacity: 1 !important;
    margin-top: 0 !important;
    pointer-events: auto !important;
  }
}

@media (max-width: 480px) {
  .filter-sidebar {
    padding: 16px;
  }
}


/* Reusable Search Section Styles */
.search-section {
  margin-bottom: 24px;
}

.search-container {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--page-card);
  border: 1px solid var(--page-card-border);
  border-radius: 12px;
  padding: 12px 16px;
  transition: all 0.2s ease;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.search-container:focus-within {
  border-color: var(--page-accent);
  box-shadow: 0 0 0 3px rgba(51, 122, 183, 0.1);
}

.search-icon {
  color: var(--page-muted);
  flex-shrink: 0;
}

.search-input {
  flex: 1;
  border: none;
  outline: none;
  background: transparent;
  color: var(--page-text);
  font-size: 15px;
  font-family: inherit;
  padding: 0;
}

.search-input::placeholder {
  color: var(--page-muted);
}

.search-input::-webkit-search-cancel-button {
  display: none;
}

.search-clear {
  display: none;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: var(--page-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.search-clear:hover {
  background: #f3f4f6;
  color: var(--page-text);
}

.search-clear.visible {
  display: flex;
}

.search-results {
  margin-top: 12px;
  font-size: 14px;
  color: var(--page-muted);
  font-family: inherit;
}
