/* ══════════════════════════════════════════════════════════════════════════════
   MTG FILTER — Sidebar, Sections, Price, Toggle, Include/Exclude
   ══════════════════════════════════════════════════════════════════════════════ */

/* ── Filter sidebar ───────────────────────────────────────────────────────── */
.mtg-filter-sidebar {
  width: 0px;
  flex-shrink: 0;
  background: var(--filterBackground);
  border-right: 1px solid #e0e0e0;
  height: calc(100vh - 185px);
  position: sticky;
  top: 155px;
  overflow-y: auto;
  overflow-x: hidden;
  transition:
    width 0.25s ease,
    border-right 0.25s ease,
    opacity 0.25s ease;
  z-index: 50;
  opacity: 0;
  font-family: var(--font-sans);
}
.mtg-filter-sidebar--open {
  width: 260px;
  opacity: 1;
}

.mtg-filter-sidebar-inner {
  padding: 1rem;
}

/* ── Sticky sidebar title ─────────────────────────────────────────────────── */
.mtg-filter-sidebar-title {
  position: sticky;
  top: 0;
  background: #fff;
  z-index: 10;
  padding: 1rem 1rem 0.75rem;
  border-bottom: 1px solid #f0f0f0;
  margin: -1rem -1rem 1rem;
  height: 100;
  align-content: center;
}
.mtg-filter-sidebar-titlerow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 15px;
  font-weight: 700;
  color: #111;
  margin-bottom: 2px;
}
.mtg-filter-sidebar-subtitle {
  font-size: 12px;
  color: #aaa;
  margin: 0 0 10px;
}
.mtg-filter-active-badge {
  background: #fef3e2;
  color: #111;
  font-size: 13px;
  font-weight: 400;
  padding: 2px 8px;
  border-radius: 99px;
  min-height: 20px;
  min-width: 50px;
  text-align: center;
  align-content: center;
}

.mtg-filter-btn {
  width: 100%;
  height: 38px;
  justify-content: center;
  background: var(--darkBrown);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 400;
  margin-block: 4px;
}

.mtg-btn-reset {
  width: 100%;
  height: 38px;
  justify-content: center;
  background: #fff0f0;
  color: #c0392b;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 400;
  margin-block: 4px;
}
.mtg-btn-reset:hover {
  background: #ffe0e0;
  border-color: #e0a0a0;
}

.mtg-filter-sidebar-close {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: #aaa;
  line-height: 1;
}
.mtg-filter-sidebar-close:hover {
  color: #111;
}

/* ── Filter sections ──────────────────────────────────────────────────────── */
.mtg-filter-section {
  margin-bottom: 1.25rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid #777;
}
.mtg-filter-section:last-of-type {
  border-bottom: none;
}

.mtg-filter-label {
  font-size: 12px;
  font-weight: 700;
  font-family: var(--font-sans);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #30271d;
  margin-bottom: 8px;
}

/* ── Collapsible sections ─────────────────────────────────────────────────── */
.mtg-filter-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  padding: 6px 0;
  user-select: none;
}
.mtg-filter-section-header:hover .mtg-filter-label {
  color: #111;
}
.mtg-filter-section-header .mtg-filter-label {
  margin-bottom: 0;
}

.mtg-section-arrow {
  font-size: 16px;
  color: #111;
  display: inline-block;
  transition: transform 0.2s ease;
  transform: rotate(-90deg);
  line-height: 1;
}
.mtg-filter-section-body {
  overflow: hidden;
  transition:
    max-height 0.25s ease,
    opacity 0.2s ease;
  max-height: 600px;
  opacity: 1;
}
.mtg-section-body--collapsed {
  max-height: 0;
  opacity: 0;
  pointer-events: none;
}

/* ── Include / Exclude buttons ────────────────────────────────────────────── */
.mtg-set-include-exclude {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  background-color: var(--filterHover);
  border-radius: 6px;
  padding: 5px;
  overflow: hidden;
}
.mtg-ie-btn {
  flex: 1;
  height: 30px;
  border-radius: 6px;
  border: none;
  background: none;
  font-size: 12px;
  font-weight: 300;
  color: var(--filterTextColor);
  cursor: pointer;
  transition:
    background 0.15s,
    color 0.15s;
  font-family: var(--font-sans);
}
.mtg-ie-btn + .mtg-ie-btn {
  border-left: none;
}
.mtg-ie-btn--active {
  background: var(--white);
  color: #272727;
}

/* ── Set search and list ──────────────────────────────────────────────────── */
.mtg-set-search {
  display: block;
  --has-width: 100%;
  --has-height: 32px;
  --theme-form-field-padding: 0 10px;
  --theme-form-field-border-radius: 6px;
  --theme-form-field-background-initial-color: var(--filterInputBackground);
  --theme-form-font-size: 13px;
  margin-bottom: 8px;
  box-sizing: border-box;
  --theme-form-field-border-initial-color: #ddd;
}
.mtg-set-list {
  max-height: 200px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
.mtg-hint {
  font-size: 12px;
  color: #aaa;
  padding: 4px 0;
}

/* ── Checkbox filter items ────────────────────────────────────────────────── */
.mtg-filter-check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 4px;
  font-size: 13px;
  color: var(--filterTextColor);
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.1s;
  font-family: var(--font-sans);
}
.mtg-filter-check-item:hover {
  background: var(--filterHover);
}
.mtg-filter-check-item input[type="checkbox"] {
  width: 15px;
  height: 15px;
  cursor: pointer;
  accent-color: var(--yellow);
  flex-shrink: 0;
  border-radius: 0.25rem;
  border: 2px solid var(--border);
  appearance: none;
}
.mtg-filter-check-item input[type="checkbox"]:checked {
  background: var(--yellow);
  border-color: var(--yellow);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='%23333' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M13.485 1.929L5.5 9.914 2.515 6.929 1.1 8.343l4.4 4.4 9.4-9.4z'/%3E%3C/svg%3E");
  background-size: 10px;
  background-repeat: no-repeat;
  background-position: center;
}
.mtg-chip-col {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* ── Price filter ─────────────────────────────────────────────────────────── */
.mtg-price-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  margin-bottom: 10px;
}
.mtg-price-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.mtg-price-label {
  font-size: 11px;
  color: var(--filterTextColor);
  font-weight: 500;
}
.mtg-price-input {
  --has-width: 100%;
  --has-height: 38px;
  --theme-form-field-padding: 0 10px;
  --theme-form-field-border-radius: 8px;
  --theme-form-field-border-initial-color: #e0e0e0;
  --theme-form-font-size: 14px;
  --theme-form-field-background-initial-color: #f8f5ef;
  --theme-form-text-initial-color: #111;
  box-sizing: border-box;
}
.mtg-price-input:focus {
  outline: none;
  border-color: #1a1a2e;
}
.mtg-price-sep {
  display: none;
}

/* ── Toggle ───────────────────────────────────────────────────────────────── */
.mtg-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-size: 13px;
  color: #333;
}
.mtg-toggle-row input[type="checkbox"] {
  display: inline-block;
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--yellow);
  flex-shrink: 0;

  appearance: none;
  border: 2px solid var(--border);
  border-radius: 0.25rem;
}
.mtg-toggle-row input[type="checkbox"]:checked {
  background: var(--yellow);
  border-color: var(--yellow);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 16 16' fill='%23333' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M13.485 1.929L5.5 9.914 2.515 6.929 1.1 8.343l4.4 4.4 9.4-9.4z'/%3E%3C/svg%3E");
  background-size: 10px;
  background-repeat: no-repeat;
  background-position: center;
}
.mtg-toggle-track {
  width: 34px;
  height: 18px;
  background: #ccc;
  border-radius: 99px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}
.mtg-toggle-thumb {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.mtg-toggle-row input:checked + .mtg-toggle-track {
  background: #1a1a2e;
}
.mtg-toggle-row input:checked + .mtg-toggle-track .mtg-toggle-thumb {
  transform: translateX(16px);
}
.mtg-toggle-label {
  font-size: 15px;
  color: var(--filterTextColor);
}

/* ── Foil toggle on cards ─────────────────────────────────────────────────── */
.mtg-foil-row {
  display: flex;
  align-items: center;
}
.mtg-foil-label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  color: #333;
  user-select: none;
}
.mtg-foil-label input[type="checkbox"] {
  display: none;
}
.mtg-foil-label input:checked + .mtg-toggle-track {
  background: #8a6010;
}
.mtg-foil-label input:checked + .mtg-toggle-track .mtg-toggle-thumb {
  transform: translateX(16px);
}
.mtg-foil-text {
  font-size: 12px;
  color: #8a6010;
  font-weight: 600;
}
.mtg-foil-unavailable {
  font-size: 12px;
  color: #bbb;
}

/* ── Filter actions ───────────────────────────────────────────────────────── */
.mtg-filter-actions {
  display: flex;
  gap: 8px;
  margin-top: 1rem;
}
.mtg-filter-actions .mtg-btn {
  flex: 1;
  justify-content: center;
}

@media (max-width: 600px) {
  .mtg-filter-sidebar {
    position: absolute;
    top: 100%;
    left: 0;
    height: 100vh;
  }
}