/**
 * Character list / tier list filter bar (`.characterfilter` + `#filterSystem`).
 * Used by CharacterList.astro and shared list UIs. Depends on `public/css/base.css` tokens.
 */

/* ── Filter bar (replaces .employees-filter-bar.lost) ── */
.characterfilter {
  border-radius: var(--ty-radius, 2px);
  padding: 8px 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-bottom: 24px;
  overflow: visible;
  position: relative;
  z-index: 40;
}

.filter-bar-element {
  display: flex;
  align-items: center;
}

.filter-bar-element.search {
  position: relative;
  margin-right: 4px;
}

.filter-bar-element.search input.form-control {
  background-color: var(--ty-ink-2);
  border: 1px solid var(--ty-stroke);
  border-radius: 2px;
  padding: 0 30px 0 10px;
  font-size: 0.9rem;
  height: 38px;
  width: 200px;
  transition: border-color 150ms ease-out;
  box-sizing: border-box;
  line-height: 38px;
  color: var(--ty-text);
}

.filter-bar-element.search input.form-control:focus {
  outline: none;
  border-color: var(--ty-accent-solid);
}

.filter-bar-element.search .clear {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  cursor: pointer;
  font-size: 1.2rem;
  line-height: 1;
  display: none;
  user-select: none;
}

.filter-bar-element.search input:not(:placeholder-shown) + .clear {
  display: block;
}

.btn-group {
  display: inline-flex;
  flex-wrap: wrap;
  border-radius: 2px;
  overflow: hidden;
  border: 1px solid var(--ty-stroke);
}

.characterfilter .btn,
#filterSystem .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--uibluegray);
  border: none;
  padding: 0 16px;
  height: 38px;
  min-width: 38px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  margin: 0;
  border-radius: 0;
}

#filterSystem .rarity-filter-btn,
#filterSystem .category-filter-btn,
#filterSystem .region-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background-color: var(--uibluegray) !important;
  border: none !important;
  border-right: 1px solid #32323e !important;
  padding: 0 16px !important;
  height: 38px !important;
  min-width: 38px !important;
  font-size: 0.9rem !important;
  font-weight: 500 !important;
  cursor: pointer !important;
  transition: all 0.2s !important;
  text-decoration: none !important;
  margin: 0 !important;
  border-radius: 0 !important;
}

.characterfilter .btn:first-child,
#filterSystem .btn:first-child,
#filterSystem .rarity-filter-btn:first-child,
#filterSystem .category-filter-btn:first-child,
#filterSystem .region-btn:first-child {
  border-top-left-radius: 2px !important;
  border-bottom-left-radius: 2px !important;
}

.characterfilter .btn:last-child,
#filterSystem .btn:last-child,
#filterSystem .rarity-filter-btn:last-child,
#filterSystem .category-filter-btn:last-child,
#filterSystem .region-btn:last-child {
  border-right: none !important;
  border-top-right-radius: 2px !important;
  border-bottom-right-radius: 2px !important;
}

.characterfilter .btn:hover,
#filterSystem .btn:hover,
#filterSystem .rarity-filter-btn:hover,
#filterSystem .category-filter-btn:hover,
#filterSystem .region-btn:hover {
  background-color: var(--uibluegray) !important;
  color: #fff !important;
}

.characterfilter .btn.active,
#filterSystem .btn.active,
#filterSystem .rarity-filter-btn.active,
#filterSystem .category-filter-btn.active,
#filterSystem .region-btn.active {
  background-color: var(--ty-accent) !important;
  color: #fff !important;
  box-shadow: none !important;
  border-color: var(--ty-accent-solid) !important;
}

/* Rarity / Klasse / Element: aktiv = nur untere Kante farbig (currentColor), kein Hintergrund-Fill, keine anderen Ränder */
.characterfilter .btn.btn-secondary.rarity-filter.active,
.characterfilter .btn.btn-secondary.class-filter.active,
.characterfilter .btn.btn-secondary.element-filter.active,
#filterSystem .btn.btn-secondary.rarity-filter.active,
#filterSystem .btn.btn-secondary.class-filter.active,
#filterSystem .btn.btn-secondary.element-filter.active {
  background-color: var(--uibluegray) !important;
  box-shadow: none !important;
  border: none !important;
  border-bottom: 2px solid currentColor !important;
  color: var(--ty-text) !important;
}

.characterfilter .btn.btn-secondary.rarity-filter.active:hover,
.characterfilter .btn.btn-secondary.class-filter.active:hover,
.characterfilter .btn.btn-secondary.element-filter.active:hover,
#filterSystem .btn.btn-secondary.rarity-filter.active:hover,
#filterSystem .btn.btn-secondary.class-filter.active:hover,
#filterSystem .btn.btn-secondary.element-filter.active:hover {
  background-color: var(--uibluegray) !important;
  box-shadow: none !important;
  border: none !important;
  border-bottom: 2px solid currentColor !important;
  color: var(--ty-text) !important;
}

.characterfilter .btn svg,
#filterSystem .btn svg {
  fill: currentColor;
}

.characterfilter .reset-button,
#filterSystem .reset-button,
#filterSystem .reset-all-btn {
  background-color: var(--uibluegray) !important;
  border: 1px solid #32323e !important;
  border-radius: 4px !important;
  padding: 0 16px !important;
  height: 38px !important;
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  cursor: pointer !important;
  transition: all 0.2s !important;
  font-size: 0.9rem !important;
  margin-left: 0 !important;
}

.characterfilter .reset-button:not([disabled]):hover,
#filterSystem .reset-button:not([disabled]):hover,
#filterSystem .reset-all-btn:not([disabled]):hover {
  background-color: var(--ty-accent) !important;
  border-color: var(--ty-accent) !important;
  color: white !important;
}

.characterfilter .reset-button[disabled],
#filterSystem .reset-button[disabled],
#filterSystem .reset-all-btn[disabled] {
  opacity: 0.5 !important;
  cursor: not-allowed !important;
}

.characterfilter .btn img,
#filterSystem .btn img,
#filterSystem .category-filter-btn img {
  width: 22px !important;
  height: 22px !important;
  object-fit: contain !important;
  transition: filter 0.2s !important;
  display: block !important;
  margin: 0 !important;
}

.characterfilter .btn-group .btn,
#filterSystem .btn-group .btn {
  flex: 1;
  min-width: 38px;
}

select.form-control,
#filterSystem .school-dropdown {
  background-color: var(--uibluegray) !important;
  border: 1px solid #32323e !important;
  height: 38px !important;
  border-radius: 4px !important;
  padding: 0 10px !important;
  cursor: pointer !important;
  min-width: 120px !important;
}

select.form-control:focus,
#filterSystem .school-dropdown:focus {
  outline: none !important;
  border-color: var(--ty-accent-solid) !important;
}

@media (max-width: 1080px) {
  .characterfilter {
    flex-direction: column;
    align-items: stretch;
    padding: 10px;
  }

  .filter-bar-element {
    width: 100%;
    justify-content: flex-start;
    margin-bottom: 8px;
  }

  .filter-bar-element:last-child {
    margin-bottom: 0;
  }

  .filter-bar-element.search input.form-control {
    width: 100%;
  }

  .filter-bar-element.search {
    margin-right: 0;
  }

  .btn-group {
    width: 100%;
    display: flex;
  }

  .characterfilter .btn,
  #filterSystem .btn,
  #filterSystem .rarity-filter-btn,
  #filterSystem .category-filter-btn,
  #filterSystem .region-btn {
    flex: 1;
    padding: 0 4px !important;
    font-size: 0.85rem !important;
  }

  .characterfilter .reset-button,
  #filterSystem .reset-button,
  #filterSystem .reset-all-btn {
    width: 100% !important;
    justify-content: center !important;
  }
}

@media (min-width: 1081px) {
  .characterfilter {
    padding: 10px 15px;
    gap: 15px;
    margin-bottom: 29px;
    justify-content: flex-start;
  }

  .filter-bar-element.search input.form-control {
    font-size: 1.2rem;
    height: 51px;
    width: 266px;
    padding: 0 40px 0 13px;
    line-height: 51px;
  }

  .filter-bar-element.search .clear {
    font-size: 1.7rem;
    right: 13px;
  }

  .characterfilter .btn,
  #filterSystem .btn,
  #filterSystem .rarity-filter-btn,
  #filterSystem .category-filter-btn,
  #filterSystem .region-btn {
    padding: 0 19px;
    height: 46px;
    min-width: 46px;
    font-size: 1.1rem;
  }

  .characterfilter .btn-group .btn,
  #filterSystem .btn-group .btn {
    min-width: 46px;
  }

  .characterfilter .reset-button,
  #filterSystem .reset-button,
  #filterSystem .reset-all-btn {
    padding: 0 19px;
    height: 46px;
    font-size: 1.1rem;
    gap: 7px;
  }

  .characterfilter .btn img,
  #filterSystem .btn img,
  #filterSystem .category-filter-btn img {
    width: 26px !important;
    height: 26px !important;
  }

  select.form-control,
  .characterfilter .school-dropdown,
  #filterSystem .school-dropdown {
    height: 46px;
    padding: 0 12px;
    min-width: 145px;
    font-size: 1.1rem;
  }

  .characterfilter .status-effect-dropdown-trigger {
    min-width: 200px;
    height: 46px;
    font-size: 1.05rem;
  }
}

/* Status / effect custom dropdown (CharacterList) */
.characterfilter .status-effect-dropdown-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
}

.characterfilter .status-effect-dropdown-label {
  font-size: 0.9rem;
  font-weight: 500;
  white-space: nowrap;
  color: rgba(220, 220, 225, 0.9);
}

.characterfilter .status-effect-custom-dropdown {
  position: relative;
  z-index: 50;
}

.characterfilter .status-effect-custom-dropdown[aria-expanded="true"] {
  z-index: 60;
}

.characterfilter .status-effect-dropdown-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 180px;
  height: 38px;
  padding: 0 12px;
  background-color: var(--uibluegray);
  border: 1px solid #32323e;
  border-radius: 2px;
  color: inherit;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.2s;
}

.characterfilter .status-effect-dropdown-trigger:hover {
  border-color: color-mix(in srgb, var(--ty-accent-solid, #7a5af8) 65%, #32323e);
}

.characterfilter .status-effect-dropdown-chevron {
  flex-shrink: 0;
  transition: transform 0.2s;
}

.characterfilter .status-effect-custom-dropdown[aria-expanded="true"] .status-effect-dropdown-chevron {
  transform: rotate(180deg);
}

.characterfilter .status-effect-dropdown-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  margin: 0;
  padding: 0;
  background-color: var(--uibluegray);
  border: 1px solid #32323e;
  border-radius: 2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  min-width: max(100%, 240px);
  z-index: 70;
  display: none;
  overflow: hidden;
}

.characterfilter .status-effect-custom-dropdown[aria-expanded="true"] .status-effect-dropdown-menu {
  display: flex;
  flex-direction: column;
}

.characterfilter .status-effect-dropdown-search {
  flex-shrink: 0;
  padding: 8px;
  border-bottom: 1px solid #32323e;
  background: rgba(0, 0, 0, 0.18);
}

.characterfilter .status-effect-dropdown-search-input {
  width: 100%;
  height: 34px;
  padding: 0 10px;
  border: 1px solid #32323e;
  border-radius: 2px;
  background: var(--ty-ink-2, #12121a);
  color: inherit;
  font-size: 0.9rem;
  box-sizing: border-box;
}

.characterfilter .status-effect-dropdown-search-input:focus {
  outline: none;
  border-color: var(--ty-accent-solid, #7a5af8);
}

.characterfilter .status-effect-dropdown-search-input::placeholder {
  color: rgba(180, 180, 190, 0.75);
}

.characterfilter .status-effect-dropdown-options {
  list-style: none;
  margin: 0;
  padding: 4px 0;
  max-height: 240px;
  overflow-y: auto;
}

.characterfilter .status-effect-dropdown-empty {
  padding: 10px 12px;
  color: rgba(180, 180, 190, 0.85);
  font-size: 0.85rem;
}

.characterfilter .status-effect-dropdown-option {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  cursor: pointer;
  transition: background-color 0.15s;
}

.characterfilter .status-effect-dropdown-option[hidden] {
  display: none;
}

.characterfilter .status-effect-dropdown-option:hover {
  background-color: rgba(122, 90, 248, 0.18);
}

.characterfilter .status-effect-dropdown-option[aria-selected="true"] {
  background-color: rgba(122, 90, 248, 0.28);
}

.characterfilter .status-effect-dropdown-option-icon {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
}

.characterfilter .status-effect-dropdown-option-text {
  flex: 1;
  line-height: 1.25;
}

.characterfilter .status-effect-dropdown-selected {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.characterfilter .status-effect-dropdown-selected img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  flex-shrink: 0;
}

@media (max-width: 1080px) {
  .characterfilter .status-effect-dropdown-wrapper {
    width: 100%;
    flex-wrap: wrap;
  }

  .characterfilter .status-effect-custom-dropdown,
  .characterfilter .status-effect-dropdown-trigger {
    width: 100%;
  }
}
