/* ========================================
   Inline Filter Controls
   Filter controls, presets, sliders, and
   dialogs that were inline in the ERB.
   Extracted from _formation_tactics_board.html.erb
   TODO: Merge/deduplicate with _filters.css
   ======================================== */

/* ---- Main Container ---- */

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

/* Unified Filter Bar */
.filter-bar {
  background: linear-gradient(135deg, rgba(255,255,255,0.03) 0%, rgba(255,255,255,0.01) 100%);
  border: 1px solid rgba(255,255,255,0.06);
  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 Groups */
.filter-group {
  flex-shrink: 0;
}

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

/* ---- Toggle Buttons ---- */

.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;
}

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

.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);
}

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

/* Mini toggle for strength type */
.filter-toggle--mini {
  padding: 2px;
  gap: 1px;
}

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

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

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

.filter-dropdown {
  position: relative;
}

.filter-select {
  appearance: none;
  -webkit-appearance: none;
  padding: 4px 20px 4px 8px;
  font-size: 10px;
  font-weight: 500;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 5px;
  color: rgba(255,255,255,0.6);
  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);
  color: rgba(255,255,255,0.8);
}

.filter-select:focus {
  border-color: rgba(34, 211, 238, 0.4);
  box-shadow: 0 0 0 2px rgba(34, 211, 238, 0.1);
}

.filter-select--active {
  background-color: rgba(34, 211, 238, 0.1);
  border-color: rgba(34, 211, 238, 0.3);
  color: var(--glow);
}

.filter-select option {
  background: #1a1a1a;
  color: white;
  padding: 8px;
}

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

/* ---- Slider Group ---- */

.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;
}

/* 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;
}

/* ---- Range Slider ---- */

.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;
}

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

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

.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 Actions Group (Reset + Presets) */
.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;
}

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

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

/* ---- Filter Presets ---- */

.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);
}

/* ---- Save Button ---- */

.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: #0a0e17;
}

.filter-preset-save-dialog__btn--save:hover {
  background: #156b1a;
}

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

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

/* ---- Legacy Reset ---- */

.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;
}

/* ---- Responsive ---- */

@media (max-width: 600px) {
  .filter-toggles-row {
    flex-wrap: wrap;
    justify-content: flex-start;
  }

  .filter-bar {
    flex-direction: column;
    align-items: flex-start;
  }

  .filter-divider {
    display: none;
  }

  .filter-spacer {
    display: none;
  }

  .filter-reset {
    margin-top: 8px;
    width: 100%;
    justify-content: center;
  }
}
