/* ============================================================
   FilterBand component styles
   Used by the <filter-band> custom element (filter-band.js).
   Each chip receives --chip-color and --chip-bg inline,
   computed from the `color` field passed in the filters array.
   ============================================================ */


/*
 Note: Add these lines in organization's cssStyles.css to ensure the filter band fits well within the theme colors:
   :root {
    --filterband-default-active-color: #009fdf98;
  	--filterband-default-active-bgcolor: #009fdf6b;
   }
*/

filter-band {
  /* Theme tokens — override on :root or on the element to retheme */
  --filterband-surface: #222222;
  --filterband-surface-hover: #343434;
  --filterband-border: #373737;
  --filterband-text: #e6edf3;
  --filterband-text-dim: #8b949e;

  display: flex;
  gap: 8px;
  padding: 8px;
  background: var(--filterband-surface);
  border: 1px solid var(--filterband-border);
  border-radius: 5px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  font-family: 'Manrope', -apple-system, BlinkMacSystemFont, sans-serif;
  box-sizing: border-box;
}

filter-band *,
filter-band *::before,
filter-band *::after {
  box-sizing: border-box;
}

filter-band .filter-chip {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background 160ms ease, border-color 160ms ease, transform 160ms ease;
  font-family: inherit;
  color: var(--filterband-text);
  text-align: left;
  font-weight: 400;
}

filter-band .filter-chip:hover {
  background: var(--filterband-surface-hover);
  border-color: var(--filterband-border);
}

filter-band .filter-chip:active {
  transform: translateY(1px);
}

filter-band .filter-chip:focus-visible {
  outline: 2px solid var(--chip-color);
  outline-offset: 2px;
}

filter-band .filter-chip.is-active {
  background: var(--chip-bg, rgba(255, 255, 255, 0.06));;
  border-color: var(--chip-color);
  font-weight: 600;
}

filter-band .chip-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

filter-band .status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--chip-color);
  box-shadow: 0 0 0 3px var(--chip-bg);
}

filter-band .chip-label {
  font-size: 1em;
  font-weight: inherit;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

filter-band .chip-count {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 12px;
  font-weight: 500;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgb(251 229 115 / 30%);
  color: #ffed00;
  min-width: 28px;
  text-align: center;
}

filter-band .filter-chip.is-active .chip-count {
  background: rgba(255, 255, 255, 0.08);
  color: var(--filterband-text);
}

/* ============================================================
   Warning badge
   Floats over the chip's top-right corner, half above the edge.
   Color customisable via --filterband-warning-color (default #BA0100).
   ============================================================ */

filter-band {
  --filterband-warning-color: #BA0100;
  --filterband-warning-text: #ffffff;
}

filter-band .chip-warning {
  position: absolute;
  top: -15px;
  left: 15px;
  transform: translate(35%, -50%);
  z-index: 2;
  min-width: 30px;
  height: 30px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--filterband-warning-color);
  color: var(--filterband-warning-text);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 14px;
  font-weight: 700;
  line-height: 30px;
  text-align: center;
  pointer-events: none;
  letter-spacing: 0;
}

/* Subtle pulse to draw attention without being obnoxious */
filter-band .chip-warning::before {
  content: '';
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  background: var(--filterband-warning-color);
  opacity: 0.4;
  z-index: -1;
  animation: filterband-pulse 2s ease-in-out infinite;
}

@keyframes filterband-pulse {
  0%, 100% { transform: scale(1);   opacity: 0; }
  50%      { transform: scale(1.4); opacity: 0.3; }
}

/* Disable the pulse when the user prefers reduced motion */
@media (prefers-reduced-motion: reduce) {
  filter-band .chip-warning::before { animation: none; }
}

/* Dropdown-item variant: smaller, inline (not floating), since
   dropdown rows already have a clear hit target */
filter-band .dropdown-warning {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--filterband-warning-color);
  color: var(--filterband-warning-text);
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  flex-shrink: 0;
}

/* ============================================================
   Colorless chip — when a filter has no `color` field, we render
   a neutral chip with no status dot and a lighter active state.
   ============================================================ */

filter-band .filter-chip.no-color .status-dot {
  display: none;
}

filter-band .filter-chip.no-color:focus-visible {
  outline-color: var(--filterband-text-dim);
}

filter-band .filter-chip.no-color.is-active {
  /*background: rgba(255, 255, 255, 0.18);
  border-color: rgba(255, 255, 255, 0.18);*/
  border-color: var(--filterband-default-active-color, rgba(255, 255, 255, 0.65));
  background: var(--filterband-default-active-bgcolor, rgba(255, 255, 255, 0.15));
}

filter-band .filter-chip.no-color.is-active .chip-count {
  background: rgb(251 229 115 / 82%);
  color: #000000;
}

filter-band .filter-chip.no-color.is-dropdown-trigger[aria-expanded="true"] .chip-caret,
filter-band .filter-chip.no-color.is-active .chip-caret {
  color: var(--filterband-text);
}

/* ============================================================
   Responsive behavior
   - Tablet (≤ 820px): tighter padding & gaps, keep horizontal
   - Narrow (≤ 600px): wrap into a 2-column grid
   - Very narrow (≤ 380px): stack into a single column
   ============================================================ */

@media (max-width: 820px) {
  filter-band {
    gap: 6px;
    padding: 6px;
  }
  filter-band .filter-chip {
    padding: 10px 12px;
    gap: 8px;
  }
  filter-band .chip-label {
    font-size: 12px;
  }
}

@media (max-width: 600px) {
  filter-band {
    flex-wrap: wrap;
  }
  filter-band .filter-chip {
    /* Two per row, accounting for the 6px gap */
    flex: 1 1 calc(50% - 3px);
    min-width: 0;
  }
  filter-band .chip-label {
    white-space: normal;       /* allow wrapping if a label is long */
    line-height: 1.2;
  }
}

@media (max-width: 380px) {
  filter-band .filter-chip {
    flex: 1 1 100%;            /* one per row on very small screens */
  }
}

/* Touch devices: kill hover-state flicker on tap */
@media (hover: none) {
  filter-band .filter-chip:hover {
    background: transparent;
    border-color: transparent;
  }
}

/* ============================================================
   Dropdown chip
   A chip whose data has an `options` array becomes a trigger
   that opens a menu of sub-options beneath it.
   ============================================================ */

filter-band .chip-wrap {
  flex: 1;
  position: relative;
  display: flex;
  /*min-width: 0;*/
}

filter-band .chip-wrap .filter-chip {
  flex: 1;
  width: 100%;
}

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

filter-band .chip-caret {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  color: var(--filterband-text);
  transition: transform 160ms ease, color 160ms ease;
  line-height: 1;
  flex-shrink: 0;
}

filter-band .chip-caret svg {
  width: 14px;
  height: 14px;
  display: block;
}

filter-band .filter-chip.is-dropdown-trigger[aria-expanded="true"] .chip-caret {
  transform: rotate(180deg);
  color: var(--chip-color);
}

filter-band .filter-chip.is-active .chip-caret {
  color: var(--chip-color);
}

filter-band .filter-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 180px;
  z-index: 100;
  display: none;
  flex-direction: column;
  gap: 2px;
  padding: 6px;
  background: var(--filterband-surface);
  border: 1px solid var(--filterband-border);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.4);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 140ms ease, transform 140ms ease;
}

filter-band .filter-dropdown[data-open="true"] {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

filter-band .dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--filterband-text);
  text-align: left;
  white-space: nowrap;
  transition: background 120ms ease;
}

filter-band .dropdown-item-label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

filter-band .dropdown-item:hover,
filter-band .dropdown-item:focus-visible {
  background: var(--filterband-surface-hover);
  outline: none;
}

filter-band .dropdown-item.is-active {
  background: var(--chip-bg, rgba(255, 255, 255, 0.06));
  color: var(--chip-color, var(--filterband-text));
}

filter-band .dropdown-item.is-active::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chip-color);
  flex-shrink: 0;
}

filter-band .dropdown-count {
  font-family: 'JetBrains Mono', ui-monospace, monospace;
  font-size: 11px;
  font-weight: 500;
  color: var(--filterband-text-dim);
  padding: 1px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

/* On narrow screens the dropdown should span its row, not just its column */
@media (max-width: 600px) {
  filter-band .filter-dropdown {
    left: 0;
    right: 0;
  }
}
