/* ========================================
   Filter Controls
   Shared filter styling used across the tactics board,
   by_fixture page, and any filter bars throughout the app.

   Design principles:
   - Compact, small inputs (10-11px font)
   - rgba(0,0,0,0.3) dark translucent backgrounds
   - Subtle borders with rgba(255,255,255,0.06-0.15)
   - Primary green accent: var(--glow)
   - Phosphor Green accent: var(--glow) / rgba(var(--glow-rgb), ...)
   ======================================== */

/* ---- Filter Bar Container ---- */

.filter-bar {
  background: linear-gradient(135deg, rgba(var(--glow-rgb), 0.04) 0%, rgba(255,255,255,0.01) 100%);
  border: 1px solid var(--border-glow);
  border-radius: 8px;
  padding: 8px 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-bar--unified {
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
}

.filter-bar__row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-bar__row--separator {
  padding-top: 8px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* ---- Filter Groups ---- */

.filter-group {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.filter-group--grow {
  flex-grow: 1;
}

.filter-group__label {
  font-size: 11px;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.filter-divider {
  width: 1px;
  height: 20px;
  background: rgba(255,255,255,0.1);
  flex-shrink: 0;
}

/* ---- Filter Controls Container ---- */

.filter-controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ---- Toggle Buttons ---- */
/*
 * All toggles share the same base: dark translucent pill background,
 * white text when active for readability. The active background uses
 * Phosphor Green (--glow-rgb) at ~25% opacity for visual distinction.
 *
 * Badge pattern:  colored text + 8% bg  (for static labels/badges)
 * Toggle pattern: white text   + 25% bg (for interactive inputs)
 */

.filter-toggle {
  display: inline-flex;
  background: rgba(0,0,0,0.3);
  border-radius: 6px;
  padding: 2px;
  gap: 1px;
}

.filter-toggle__btn {
  padding: 4px 8px;
  font-size: 10px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s ease;
  white-space: nowrap;
  text-decoration: none;
  display: block;
}

.filter-toggle__btn:hover {
  color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.05);
}

/* Default active state - Phosphor Green bg, white text */
.filter-toggle__btn--active {
  background: rgba(var(--glow-rgb), 0.20) !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 1px rgba(var(--glow-rgb), 0.30), 0 0 8px rgba(var(--glow-rgb), 0.1);
}

/* Venue toggle - slightly smaller */
.filter-toggle--venue .filter-toggle__btn {
  padding: 4px 6px;
  min-width: 24px;
  text-align: center;
}

/* Mini toggle (e.g. strength type) */
.filter-toggle--mini {
  padding: 2px;
  gap: 1px;
}

.filter-toggle--mini .filter-toggle__btn {
  padding: 3px 5px;
  font-size: 9px;
}

/* Stat type toggle - Phosphor Green bg, white text */
.filter-toggle--stat-type .filter-toggle__btn {
  font-weight: 600;
}

.filter-toggle--stat-type .filter-toggle__btn--active {
  background: rgba(var(--glow-rgb), 0.30) !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 1px rgba(var(--glow-rgb), 0.45);
}

/* Lineup toggle active states - each type gets its own tinted bg, all white text */
.filter-toggle--lineup {
  padding: 2px;
  gap: 1px;
}

.filter-toggle__btn--predicted.filter-toggle__btn--active {
  background: rgba(251, 191, 36, 0.25) !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 1px rgba(251, 191, 36, 0.35);
}

.filter-toggle__btn--custom.filter-toggle__btn--active {
  background: rgba(var(--glow-rgb), 0.25) !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 1px rgba(var(--glow-rgb), 0.35);
}

.filter-toggle__btn--confirmed.filter-toggle__btn--active {
  background: rgba(var(--glow-rgb), 0.25) !important;
  color: #ffffff !important;
  box-shadow: 0 0 0 1px rgba(var(--glow-rgb), 0.35);
}

/* ---- Dropdown Select ---- */

.filter-select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding: 4px 24px 4px 8px;
  font-size: 10px;
  font-weight: 500;
  /* !important needed to override blanket select{} rule in _fixtures_list.css */
  background-color: rgba(0,0,0,0.3) !important;
  border: 1px solid rgba(255,255,255,0.08) !important;
  border-radius: 5px;
  color: rgba(255,255,255,0.6) !important;
  cursor: pointer;
  outline: none;
  transition: all 0.15s ease;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='10' viewBox='0 0 24 24' fill='none' stroke='rgba(255,255,255,0.4)' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
  min-width: 70px;
}

.filter-select:hover {
  border-color: rgba(255,255,255,0.15) !important;
  color: rgba(255,255,255,0.8) !important;
}

.filter-select:focus {
  border-color: rgba(var(--glow-rgb), 0.4) !important;
  box-shadow: 0 0 0 2px rgba(var(--glow-rgb), 0.1);
}

.filter-select--active {
  background-color: rgba(var(--glow-rgb), 0.1) !important;
  border-color: rgba(var(--glow-rgb), 0.3) !important;
  color: var(--glow) !important;
}

.filter-select--grow {
  flex-grow: 1;
  min-width: 150px;
}

.filter-select option {
  background: #1a1a1a;
  color: rgba(255,255,255,0.9);
  padding: 6px 10px;
}

.filter-select option:checked {
  background: rgba(var(--glow-rgb), 0.15);
  color: var(--glow);
}

.filter-select optgroup {
  background: #1a1a1a;
  color: rgba(255, 255, 255, 0.5);
  font-style: normal;
  font-size: 9px;
}

.filter-select:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  border-color: rgba(255,255,255,0.05) !important;
}

/* ---- Dropdown Filters Container ---- */

.filter-dropdowns {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.filter-dropdown {
  position: relative;
}

/* ---- Range Sliders ---- */
/*
 * Slider input pattern: white thumb, Phosphor Green fill/glow.
 * Matches the toggle pattern: white for interactive elements,
 * green accent for visual feedback.
 */

.filter-slider-group {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(0,0,0,0.3);
  border-radius: 6px;
  padding: 4px 10px;
  min-height: 30px;
}

.filter-slider-group__label {
  font-size: 9px;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  white-space: nowrap;
}

.filter-range-slider {
  display: flex;
  align-items: center;
  gap: 6px;
}

.filter-range-slider__value {
  font-size: 9px;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  min-width: 55px;
  text-align: left;
  white-space: nowrap;
}

.filter-range-slider__value--active {
  color: #ffffff;
}

.filter-range-slider__track-container {
  position: relative;
  width: 70px;
  height: 20px;
  display: flex;
  align-items: center;
}

.filter-range-slider__track-container--wide {
  width: 90px;
}

.filter-range-slider__track {
  position: absolute;
  left: 0;
  right: 0;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
}

.filter-range-slider__fill {
  position: absolute;
  left: 0;
  height: 4px;
  background: rgba(var(--glow-rgb), 0.5);
  border-radius: 2px;
  pointer-events: none;
  width: 0%;
}

.filter-range-slider__input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: transparent;
  outline: none;
  cursor: pointer;
  position: relative;
  z-index: 2;
}

.filter-range-slider__input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: #ffffff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3), 0 0 0 2px rgba(var(--glow-rgb), 0.25);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.filter-range-slider__input::-webkit-slider-thumb:hover {
  transform: scale(1.15);
  box-shadow: 0 2px 8px rgba(var(--glow-rgb), 0.4), 0 0 0 3px rgba(var(--glow-rgb), 0.3);
}

.filter-range-slider__input::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #ffffff;
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3), 0 0 0 2px rgba(var(--glow-rgb), 0.25);
}

/* ---- Dual-Handle Range Slider ---- */

.filter-dual-slider {
  position: relative;
  width: 70px;
  display: flex;
  align-items: center;
}

.filter-dual-slider--wide {
  width: 90px;
}

.filter-dual-slider__track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 2px;
}

.filter-dual-slider__fill {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  height: 4px;
  background: rgba(var(--glow-rgb), 0.5);
  border-radius: 2px;
  pointer-events: none;
  left: 0%;
  right: 0%;
}

.filter-dual-slider__input {
  -webkit-appearance: none;
  appearance: none;
  position: absolute;
  width: 100%;
  height: 100%;
  background: transparent;
  outline: none;
  cursor: pointer;
  pointer-events: none;
  margin: 0;
  padding: 0;
}

.filter-dual-slider__input::-webkit-slider-runnable-track {
  height: 4px;
  background: transparent;
}

.filter-dual-slider__input::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 10px;
  height: 10px;
  background: #ffffff;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 0 0 1px rgba(var(--glow-rgb), 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  pointer-events: auto;
  margin-top: -3px;
}

.filter-dual-slider__input::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 2px 6px rgba(var(--glow-rgb), 0.4), 0 0 0 2px rgba(var(--glow-rgb), 0.3);
}

.filter-dual-slider__input::-moz-range-track {
  height: 4px;
  background: transparent;
}

.filter-dual-slider__input::-moz-range-thumb {
  width: 10px;
  height: 10px;
  background: #ffffff;
  border-radius: 50%;
  cursor: pointer;
  border: none;
  box-shadow: 0 1px 3px rgba(0,0,0,0.3), 0 0 0 1px rgba(var(--glow-rgb), 0.35);
  pointer-events: auto;
}

.filter-dual-slider__value {
  font-size: 9px;
  font-weight: 600;
  color: rgba(255,255,255,0.6);
  min-width: 65px;
  text-align: left;
  white-space: nowrap;
}

.filter-dual-slider__value--active {
  color: #ffffff;
}

/* Fixed width for strength filter */
.filter-slider-group--strength {
  min-width: 380px;
}

/* Max width for possession filter */
.filter-slider-group[data-possession-filter] {
  max-width: 190px;
}

/* ---- Filter Actions ---- */

.filter-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.filter-actions-group {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  flex-shrink: 0;
  border-left: 1px solid rgba(255,255,255,0.1);
  padding-left: 8px;
}

/* Reset Button */
.filter-reset-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  margin-right: 10px;
  background: rgba(0,0,0,0.3);
  border: none;
  border-radius: 6px;
  color: rgba(255,255,255,0.5);
  font-size: 10px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
  margin-left: auto;
}

.filter-reset-btn:hover {
  background: rgba(0,0,0,0.4);
  color: rgba(255,255,255,0.8);
}

.filter-reset-btn:hover svg {
  transform: rotate(-45deg);
}

.filter-reset-btn svg {
  width: 12px;
  height: 12px;
  transition: transform 0.2s ease;
}

.filter-reset-btn--icon-only {
  padding: 5px 6px;
  margin-right: 0;
  margin-left: 0;
}

.filter-reset-btn--icon-only svg {
  width: 13px;
  height: 13px;
}

/* Legacy reset (icon only) */
.filter-reset {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 5px;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.filter-reset:hover {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.2);
  color: white;
}

.filter-reset:hover svg {
  transform: rotate(-45deg);
}

.filter-reset svg {
  transition: transform 0.2s ease;
}

/* ---- Preset Controls ---- */

.filter-preset-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  border-left: none;
  padding-left: 0;
  margin-left: 0;
  flex-shrink: 0;
}

.filter-preset-dropdown {
  position: relative;
}

.filter-preset-trigger {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px 8px;
  background: rgba(0,0,0,0.3);
  border: none;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 500;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  transition: all 0.15s ease;
  width: 85px;
  justify-content: space-between;
  flex-shrink: 0;
  white-space: nowrap;
  overflow: hidden;
}

.filter-preset-trigger:hover {
  background: rgba(0,0,0,0.4);
  color: rgba(255,255,255,0.8);
}

.filter-preset-trigger [data-preset-name] {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
}

.filter-preset-trigger--active {
  color: var(--glow);
  background: rgba(var(--glow-rgb), 0.1);
}

.filter-preset-trigger--active:hover {
  background: rgba(var(--glow-rgb), 0.15);
}

.filter-preset-trigger svg {
  width: 10px;
  height: 10px;
  flex-shrink: 0;
}

.filter-preset-menu {
  display: none;
  position: absolute;
  top: calc(100% + 4px);
  right: 0;
  min-width: 140px;
  background: #272727;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  z-index: 100;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  max-height: 240px;
  overflow-y: auto;
}

.filter-preset-menu--open {
  display: block;
}

.filter-preset-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 10px;
  font-size: 11px;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  border-bottom: 1px solid rgba(255,255,255,0.05);
  transition: background 0.1s ease;
}

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

.filter-preset-item:hover {
  background: rgba(255,255,255,0.05);
}

.filter-preset-item--active {
  background: rgba(var(--glow-rgb), 0.1);
  color: var(--glow);
}

.filter-preset-item--new {
  border-top: 1px solid rgba(255,255,255,0.1);
  color: var(--glow);
  font-weight: 500;
}

.filter-preset-delete {
  opacity: 0;
  padding: 2px;
  background: none;
  border: none;
  color: #ef4444;
  cursor: pointer;
  border-radius: 3px;
  transition: opacity 0.1s ease, background 0.1s ease;
  display: flex;
  align-items: center;
}

.filter-preset-item:hover .filter-preset-delete {
  opacity: 0.7;
}

.filter-preset-delete:hover {
  opacity: 1 !important;
  background: rgba(239, 68, 68, 0.2);
}

.filter-preset-save {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 6px;
  background: rgba(0,0,0,0.3);
  border: none;
  border-radius: 6px;
  color: rgba(255,255,255,0.4);
  cursor: pointer;
  transition: all 0.15s ease;
}

.filter-preset-save:hover {
  background: rgba(var(--glow-rgb), 0.15);
  color: var(--glow);
}

.filter-preset-save--modified {
  color: #eab308;
  animation: pulse-save 1.5s ease-in-out infinite;
}

.filter-preset-save--modified:hover {
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
}

@keyframes pulse-save {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.filter-preset-save svg {
  width: 11px;
  height: 11px;
}

/* ---- Save Dialog ---- */

.filter-preset-save-dialog {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.filter-preset-save-dialog__content {
  background: #1a1f2e;
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  padding: 16px;
  min-width: 260px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}

.filter-preset-save-dialog__title {
  font-size: 13px;
  font-weight: 600;
  color: white;
  margin-bottom: 12px;
}

.filter-preset-save-dialog__input {
  width: 100%;
  padding: 8px 10px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 5px;
  color: white;
  font-size: 12px;
  margin-bottom: 12px;
}

.filter-preset-save-dialog__input:focus {
  outline: none;
  border-color: var(--glow);
}

.filter-preset-save-dialog__buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.filter-preset-save-dialog__btn {
  padding: 6px 12px;
  border-radius: 5px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
}

.filter-preset-save-dialog__btn--cancel {
  background: rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.7);
}

.filter-preset-save-dialog__btn--cancel:hover {
  background: rgba(255,255,255,0.15);
  color: white;
}

.filter-preset-save-dialog__btn--save {
  background: var(--glow);
  color: #0a0a0a;
}

.filter-preset-save-dialog__btn--save:hover {
  background: rgba(var(--glow-rgb), 0.85);
}

.filter-preset-save-dialog__btn--overwrite {
  background: #eab308;
  color: #0a0e17;
}

.filter-preset-save-dialog__btn--overwrite:hover {
  background: #ca8a04;
}
