/* ===== TRANSIT FILTERS — ONE FILTER BAR FOR EVERY LIST ======================================
 *
 * Every list screen in the back office used to grow its own toolbar: a bare input here, three
 * loose selects there, a row of buttons somewhere else. Same job, three shapes, and none of them
 * survived a 390px phone. This is the single vocabulary all of them now speak:
 *
 *   search  ·  quick chips  ·  a collapsible advanced panel  ·  active-filter chips  ·  a count
 *
 * Written with logical properties only, so the Arabic (RTL) and English (LTR) sides of the same
 * screen are the same code, and sized so every control clears the 44px touch target on a phone.
 */

.tf {
  background: #fff;
  border: 1px solid var(--line, #e7e9ee);
  border-radius: 16px;
  box-shadow: 0 6px 18px rgba(24, 32, 54, .06);
  padding: .8rem .85rem;
  margin-bottom: 1rem;
  display: flex;
  flex-direction: column;
  gap: .7rem;
}

/* --- row 1: search + toggle + count ------------------------------------------------------- */
.tf__top {
  display: flex;
  align-items: center;
  gap: .55rem;
  flex-wrap: wrap;
}
.tf__search {
  position: relative;
  flex: 1 1 240px;
  min-width: 0;
  display: flex;
}
.tf__search input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1.5px solid var(--line, #e7e9ee);
  border-radius: 12px;
  background: #fbfcfe;
  padding-block: .6rem;
  padding-inline: 2.45rem .9rem;
  font-family: inherit;
  font-weight: 700;
  font-size: .9rem;
  color: inherit;
  outline: none;
  transition: border-color .15s, background .15s;
}
.tf__search input:focus {
  border-color: var(--blue, #29abe2);
  background: #fff;
}
.tf__search input::placeholder { color: #9aa2b1; font-weight: 700; }
.tf__search::before {
  content: "";
  width: 1rem;
  background: currentColor;
  -webkit-mask: var(--ico-search) center / 1rem no-repeat;
  mask: var(--ico-search) center / 1rem no-repeat;
  position: absolute;
  inset-block: 0;
  inset-inline-start: .8rem;
  display: flex;
  align-items: center;
  font-size: .9rem;
  opacity: .55;
  pointer-events: none;
}
.tf__x {
  position: absolute;
  inset-block: 0;
  inset-inline-end: .35rem;
  margin-block: auto;
  width: 28px;
  height: 28px;
  border: none;
  border-radius: 50%;
  background: #eef2f7;
  color: #55606f;
  font-size: .9rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
}
.tf__x:hover { background: #e2e8f0; }

.tf__toggle {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 44px;
  padding-inline: .9rem;
  border: 1.5px solid var(--line, #e7e9ee);
  border-radius: 12px;
  background: #fff;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 800;
  color: var(--ink, #22252a);
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, background .15s;
}
.tf__toggle:hover { border-color: #cfd6e2; background: #fbfcfe; }
.tf__toggle[aria-expanded="true"] { border-color: var(--blue, #29abe2); background: #f2fbff; }
.tf__toggle-n {
  min-width: 20px;
  padding-inline: .34rem;
  border-radius: 20px;
  background: linear-gradient(135deg, #f7931e, #ffc20e);
  color: #231a08;
  font-size: .7rem;
  font-weight: 900;
  text-align: center;
}
.tf__count {
  margin-inline-start: auto;
  font-size: .82rem;
  font-weight: 800;
  color: var(--muted, #7b8494);
  white-space: nowrap;
}

/* «Excel» — the whole filtered list as a workbook. Excel's own green, so it reads as a file, not a filter. */
.tf__xlsx, .xlsx-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  min-height: 44px;
  padding-inline: .9rem;
  border: 1.5px solid #cfe6d8;
  border-radius: 12px;
  background: #f3faf6;
  font-family: inherit;
  font-size: .85rem;
  font-weight: 800;
  color: #107c41;
  cursor: pointer;
  white-space: nowrap;
  transition: border-color .15s, background .15s;
}
.tf__xlsx:hover, .xlsx-btn:hover { border-color: #107c41; background: #e8f5ee; }
.tf__xlsx:disabled, .xlsx-btn:disabled { opacity: .55; cursor: progress; }

/* The small «Excel» above any table in the back office (xlsx-export.js adds it). */
.xlsx-bar { display: flex; justify-content: flex-end; margin-block: .2rem .45rem; }
.xlsx-btn { min-height: 32px; padding-inline: .7rem; border-radius: 10px; font-size: .78rem; }
.xlsx-btn:focus-visible, .tf__xlsx:focus-visible { outline: 3px solid #f7931e; outline-offset: 2px; }
@media print { .xlsx-bar { display: none; } }

/* --- row 2: quick chips (one horizontal, scrollable strip on a phone) ---------------------- */
.tf__chips {
  display: flex;
  gap: .4rem;
  overflow-x: auto;
  scrollbar-width: none;
  padding-block-end: .15rem;
  margin-block: -.1rem;
}
.tf__chips::-webkit-scrollbar { display: none; }
.tf__chip {
  flex: 0 0 auto;
  min-height: 36px;
  padding-inline: .8rem;
  border: 1.5px solid var(--line, #e7e9ee);
  border-radius: 20px;
  background: #fff;
  font-family: inherit;
  font-size: .8rem;
  font-weight: 800;
  color: #55606f;
  cursor: pointer;
  white-space: nowrap;
  transition: .15s;
}
.tf__chip:hover { border-color: #cfd6e2; background: #fbfcfe; }
.tf__chip.is-on {
  background: linear-gradient(135deg, #f7931e, #ffc20e);
  border-color: transparent;
  color: #231a08;
  box-shadow: 0 4px 12px rgba(247, 147, 30, .28);
}

/* --- row 3: the advanced panel ------------------------------------------------------------- */
.tf__adv {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: .6rem;
  padding-block-start: .7rem;
  border-block-start: 1px dashed var(--line, #e7e9ee);
}
.tf__adv[hidden] { display: none; }
.tf__f {
  display: flex;
  flex-direction: column;
  gap: .28rem;
  min-width: 0;
}
.tf__f > span {
  font-size: .72rem;
  font-weight: 800;
  color: var(--muted, #7b8494);
}
.tf__f select,
.tf__f input {
  width: 100%;
  min-width: 0;
  min-height: 44px;
  border: 1.5px solid var(--line, #e7e9ee);
  border-radius: 10px;
  background: #fff;
  padding-block: .55rem;
  padding-inline: .7rem;
  font-family: inherit;
  font-size: .86rem;
  font-weight: 700;
  color: inherit;
  outline: none;
}
.tf__f select:focus,
.tf__f input:focus { border-color: var(--blue, #29abe2); }
.tf__f input[type="date"] { font-variant-numeric: tabular-nums; }
/* A toggle reads as a switch row, not a stray checkbox floating in a grid of dropdowns. */
.tf__f--toggle {
  flex-direction: row;
  align-items: center;
  gap: .5rem;
  align-self: end;
  min-height: 44px;
  padding-inline: .7rem;
  border: 1.5px solid var(--line, #e7e9ee);
  border-radius: 10px;
  background: #fff;
  cursor: pointer;
}
.tf__f--toggle input { width: 18px; height: 18px; min-height: 0; accent-color: var(--blue, #29abe2); flex: 0 0 auto; }
.tf__f--toggle span { font-size: .82rem; font-weight: 800; color: var(--ink, #22252a); }

/* --- row 4: what is actually filtering right now ------------------------------------------- */
.tf__active {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .4rem;
  padding-block-start: .6rem;
  border-block-start: 1px dashed var(--line, #e7e9ee);
}
.tf__active[hidden] { display: none; }
.tf__tag {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .28rem .55rem;
  border-radius: 8px;
  background: #eef4fb;
  border: 1px solid #d8e6f5;
  font-size: .76rem;
  font-weight: 800;
  color: #29597e;
  max-width: 100%;
}
.tf__tag b { font-weight: 900; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tf__tag button {
  border: none;
  background: none;
  color: #29597e;
  font-size: .9rem;
  font-weight: 900;
  line-height: 1;
  padding: 0 .1rem;
  cursor: pointer;
}
.tf__clear {
  margin-inline-start: auto;
  border: none;
  background: none;
  padding: .3rem .1rem;
  font-family: inherit;
  font-size: .78rem;
  font-weight: 900;
  color: var(--red, #dc2626);
  cursor: pointer;
  white-space: nowrap;
}

.tf :focus-visible { outline: 3px solid #f7931e; outline-offset: 2px; border-radius: 8px; }

/* --- phones -------------------------------------------------------------------------------- */
@media (max-width: 640px) {
  .tf { padding: .7rem; border-radius: 14px; gap: .6rem; }
  .tf__search { flex: 1 1 100%; }
  .tf__toggle, .tf__xlsx { flex: 1 1 auto; justify-content: center; }
  .tf__count { flex: 1 1 100%; margin-inline-start: 0; text-align: start; }
  .tf__adv { grid-template-columns: 1fr; }
  /* A date range is two halves of one thing — keep it on one line even at 390px. */
  .tf__adv .tf__f--half { grid-column: span 1; }
}
@media (min-width: 420px) and (max-width: 640px) {
  .tf__adv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .tf__adv .tf__f--wide { grid-column: 1 / -1; }
}
