/*
 * Shared slide-out panel (partials/filter_panel.html).
 *
 * These rules used to be duplicated across the inline <style> blocks of
 * ai_predictions, list_view, database, statistics, betslip_archive and
 * simulation. They live here so the panel looks identical on every page.
 */

/* ------------------------------------------------------------------ chips */

.chip-toggle {
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
}

.chip-toggle:focus {
  outline: none;
}

.chip-toggle:focus-visible .chip-toggle__body {
  box-shadow: 0 0 0 3px rgba(104, 255, 189, 0.16);
}

.chip-toggle__body {
  min-height: 40px;
}

/* /matches/archive and /statistics keep real checkbox inputs inside a GET form
 * so their filters still work without JS; these drive the chip's icon swap. */
.chip-toggle__icon-minus {
  display: none;
}

.chip-toggle input:checked ~ * .chip-toggle__icon-plus {
  display: none;
}

.chip-toggle input:checked ~ * .chip-toggle__icon-minus {
  display: inline-flex;
}

/* Active-filter chips (shared by every page's filter row). */
.filter-panel__chip-label {
  max-width: 18rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 767px) {
  .filter-panel__chip-label {
    max-width: 11rem;
  }
}

/* Active-filter count inside the Filters trigger. */
.filter-panel__badge {
  display: inline-flex;
  min-width: 20px;
  height: 20px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: rgba(104, 255, 189, 0.16);
  box-shadow: inset 0 0 0 1px rgba(104, 255, 189, 0.4);
  padding: 0 6px;
  color: #68ffbd;
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

/* Subtle text action, used for "Clear all" in the panel header and in the
 * filtered empty states. */
.filter-panel__clear {
  border: 0;
  background: transparent;
  padding: 4px 8px;
  border-radius: 9999px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  font-weight: 500;
  text-underline-offset: 3px;
  transition: color 0.15s ease;
  cursor: pointer;
}

.filter-panel__clear:hover {
  color: #fff;
  text-decoration: underline;
}

.filter-panel__clear:focus-visible {
  outline: 2px solid rgba(125, 211, 252, 0.9);
  outline-offset: 1px;
}

/* ------------------------------------------------------------------ panel */

.filter-panel {
  width: min(100vw, 30rem);
}

/* x-if has no transition support, so the team list animates itself in. */
.filter-panel__teams {
  animation: filter-panel-reveal 160ms ease-out;
}

@keyframes filter-panel-reveal {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .filter-panel__teams {
    animation: none;
  }
}

/* Sticky Apply/Reset footer. Opaque at the very bottom so the page gradient
 * cannot tint through and make it look detached from the panel edge, while the
 * top stays translucent so content visibly scrolls underneath. */
.filter-panel__footer {
  position: sticky;
  bottom: 0;
  z-index: 10;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  background: linear-gradient(
    to top,
    rgb(11, 10, 25) 0%,
    rgba(11, 10, 25, 0.96) 55%,
    rgba(11, 10, 25, 0.78) 100%
  );
  box-shadow: 0 -20px 40px rgba(3, 2, 10, 0.45);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  padding: 20px 24px calc(20px + env(safe-area-inset-bottom));
}

.filter-panel__search-input {
  /* iOS Safari zooms the viewport when a focused input renders below 16px. */
  font-size: 16px;
}

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

.filter-panel__chip .chip-toggle__body {
  min-height: 44px;
}

/* Country flag next to a competition name, in the same bordered square the
 * match cards use for their competition icon. */
.filter-panel__flag-box {
  display: inline-flex;
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.filter-panel__flag {
  width: 14px;
  height: 14px;
  object-fit: contain;
}

/* Chip-sized crest, matching .sim-crest but without depending on it. */
.filter-panel__crest {
  display: inline-flex;
  width: 24px;
  height: 24px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.72);
  font-size: 10px;
  font-weight: 800;
}

.filter-panel__crest img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

@media (max-width: 640px) {
  /* Keep the title and the close button reachable while scrolling a long tree. */
  .filter-panel__header {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(12, 12, 24, 0.94);
    box-shadow: 0 12px 28px rgba(0, 0, 0, 0.22);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
  }

  .filter-panel__close {
    display: inline-flex;
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    align-items: center;
    justify-content: center;
  }
}
