/* ==========================================================
 * MOYAMOVA — UI Filters (PWA/TWA)
 * Visual v2: compact bar + bottom sheet + chip levels
 * Patch v25.3: smaller pills + header buttons (sheet only)
 * ========================================================== */

/* ---------- Theme tokens (fallback-safe) ---------- */
:root {
  /* Filters (sheet) uses global theme tokens */
  --mm-filters-backdrop: var(--overlay-bg, rgba(0,0,0,0.55));
  --mm-filters-surface: var(--surface-2, var(--bg, #111821));
  --mm-filters-surface-2: var(--surface-3, var(--surface-2, #141d27));
  --mm-filters-text: var(--text, #dce2e8);
  --mm-filters-border: var(--divider, var(--border, rgba(255,255,255,0.14)));
  --mm-filters-accent: var(--brand, var(--link, #1fb6ff));
  --mm-filters-shadow: var(--shadow-2, 0 -18px 44px rgba(var(--shadow-color, 0,0,0), 0.25));
  /* Bottom offset for fixed footer/tabbar (set from JS when opening filters). */
  --mm-filters-bottom-offset: var(--footer-h-actual, 76px);
}

/* Ensure filters tokens follow Light theme even when theme is applied via body classes */
html[data-theme="light"],
:root[data-theme="light"],
body[data-theme="light"],
body.theme-light {
  --mm-filters-backdrop: var(--overlay-bg, rgba(0,0,0,0.35));
  --mm-filters-surface: var(--surface-1, var(--bg, #ffffff));
  --mm-filters-surface-2: var(--surface-2, #f7fafd);
  --mm-filters-text: var(--text, #333);
  --mm-filters-border: var(--divider, var(--border, rgba(0,0,0,0.12)));
  --mm-filters-accent: var(--brand, var(--link, #1fb6ff));
  --mm-filters-shadow: var(--shadow-2, 0 -14px 34px rgba(var(--shadow-color, 17,24,39), 0.18));
}

/* ---------- Bar (between trainer card and footer) ---------- */
.home-filters {
  margin: 10px 12px 8px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  border: 1px solid var(--mm-filters-border);
  border-radius: var(--radius-lg, 14px);
  background: var(--mm-filters-surface-2);
}

.filters-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 1px solid var(--mm-filters-border);
  border-radius: var(--radius-md, 12px);
  padding: 6px 9px;
  background: var(--mm-filters-surface-2);
  color: inherit;
  font: inherit;
  font-size: 13px; /* вровень с summary */
  line-height: 1;
}

.filters-btn:active {
  transform: translateY(1px);
}

.filters-btn .ico {
  width: 16px;
  height: 16px;
  display: inline-block;
  opacity: 0.9;
}

.filters-summary {
  font-size: 13px;
  opacity: 0.82;
  text-align: right;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Overlay + Sheet ---------- */
.filters-hidden { display: none !important; }

.filters-overlay {
  position: fixed;
  inset: 0;
  background: var(--mm-filters-backdrop);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 1000;
  touch-action: none;
}

.filters-sheet {
  position: fixed;
  left: 12px;
  right: 12px;
  /* Keep the sheet above the fixed bottom tabbar/footer. */
  bottom: calc(12px + var(--mm-filters-bottom-offset, 0px));
  z-index: 1001;
  background: var(--mm-filters-surface);
  color: var(--mm-filters-text);
  border: 1px solid var(--mm-filters-border);
  border-radius: var(--radius-xl, 18px);
  box-shadow: var(--mm-filters-shadow);
  padding: 10px 14px 14px;
  /* Auto height by content; cap to viewport when content is large. */
  max-height: min(78vh, calc(100vh - 120px - var(--mm-filters-bottom-offset, 0px)));
  overflow-y: auto; /* scroll inside sheet */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
}

/* handle */
.filters-sheet::before {
  content: "";
  display: block;
  width: 44px;
  height: 4px;
  border-radius: 999px;
  background: var(--mm-filters-border);
  margin: 2px auto 10px;
}

.filters-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--mm-filters-surface);
  padding-top: 2px;
  border-bottom: none;
}

.filters-head-actions{
  display:flex;
  align-items:center;
  gap:10px;
}

.filters-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 0.2px;
}

.filters-reset,
.filters-apply,
.filters-close {
  border: 1px solid var(--mm-filters-border);
  background: var(--mm-filters-surface-2);
  color: inherit;
  border-radius: 999px;
  height: 26px;
  padding: 0 8px;
  font: inherit;
  font-size: 12px;
  line-height: 1;
}

.filters-close {
  width: 30px;
  padding: 0;
  display: grid;
  place-items: center;
}

.filters-reset{
  opacity:0.9;
}

.filters-apply{
  opacity: 0.95;
}

.filters-apply:disabled{
  opacity: 0.45;
}


/* Apply button: brand color when enabled (disabled stays muted) */
.filters-apply:not(:disabled),
#filtersApply.filters-apply:not(:disabled) {
  background: var(--mm-filters-accent);
  border-color: var(--mm-filters-accent);
  color: #fff;
  opacity: 1;
}



.filters-hint{
  margin-top: 8px;
  font-size: 12px;
  opacity: 0.8;
  text-align: center;
  display: none;
}

/* ---------- Sections ---------- */
.filters-section {
  margin-top: 12px;
}

.filters-section h4 {
  margin: 0 0 8px;
  font-size: 12px;
  opacity: 0.88;
  font-weight: 800;
}

/* chips list (centered pills) */
.filters-list {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
}


/* label as chip */
.filters-item {
  display: inline-block;
  padding: 0;
  margin: 0;
  border: 0;
  background: none;
}

.filters-item input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.filters-item span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 50px;
  height: 28px;
  text-align: center;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--mm-filters-border);
  background: transparent;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.2px;
  line-height: 1;
}


.filters-item input:checked + span {
  border-color: var(--mm-filters-accent);
  background: color-mix(in srgb, var(--mm-filters-accent) 18%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--mm-filters-accent) 12%, transparent) inset;
}

/* Body scroll lock for filters sheet */
body.mm-modal-open {
 /* position: fixed;*/
  width: 100%;
  overflow: hidden;
}

.filters-item:active span {
  transform: translateY(1px);
}

/* ---------- Actions ---------- */
.filters-actions {
  margin-top: 14px;
  display: flex;
  gap: 10px;
  position: sticky;
  bottom: 0;
  padding: 10px 0 2px;
  background: var(--mm-filters-surface);
}

.filters-actions .btn {
  flex: 1;
  border: 1px solid var(--mm-filters-border);
  border-radius: var(--radius-lg, 14px);
  padding: 9px 12px;
  background: var(--mm-filters-surface-2);
  color: inherit;
  font: inherit;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.2px;
}

.filters-actions .btn:active {
  transform: translateY(1px);
}

/* Slightly emphasize Apply */
.filters-actions #filtersApply {
  border-color: color-mix(in srgb, var(--mm-filters-accent) 32%, var(--mm-filters-border));
  background: color-mix(in srgb, var(--mm-filters-accent) 10%, var(--mm-filters-surface-2));
}

/* Light theme: avoid "dirty grey" chips — keep them crisp white with a subtle border. */
html[data-theme="light"] .filters-item span,
body[data-theme="light"] .filters-item span,
body.theme-light .filters-item span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: auto;
  min-width: 50px;
  height: 28px;
  text-align: center;
  padding: 0 10px;
  border-radius: 999px;
  border: 1px solid var(--mm-filters-border);
  background: transparent;
  font-size: 12.5px;
  font-weight: 800;
  letter-spacing: 0.2px;
  line-height: 1;
}


/* ---------- Light theme: crisp controls (sheet only) ---------- */
html[data-theme="light"] .filters-reset,
body[data-theme="light"] .filters-reset,
body.theme-light .filters-reset,
html[data-theme="light"] .filters-close,
body[data-theme="light"] .filters-close,
body.theme-light .filters-close {
  background: var(--mm-filters-surface-2);
  border-color: var(--mm-filters-text);
}

html[data-theme="light"] .filters-item span,
body[data-theme="light"] .filters-item span,
body.theme-light .filters-item span {
  background: transparent;
  border-color: var(--mm-filters-text);
  color: var(--mm-filters-text);
}

html[data-theme="light"] .filters-item input:checked + span,
body[data-theme="light"] .filters-item input:checked + span,
body.theme-light .filters-item input:checked + span {
  border-color: var(--mm-filters-accent);
  background: color-mix(in srgb, var(--mm-filters-accent) 6%, rgba(255,255,255,1));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--mm-filters-accent) 10%, transparent) inset;
}


/* Override: Apply in actions uses full brand when enabled */
.filters-actions #filtersApply:not(:disabled) {
  background: var(--mm-filters-accent);
  border-color: var(--mm-filters-accent);
  color: #fff;
}


/* MOYAMOVA: virtual decks filters info */
.filters-virtual-note{
  padding:14px;
  border-radius:12px;
  background:var(--card-bg, rgba(0,0,0,.04));
}

.filters-virtual-note .title{
  font-weight:600;
  margin-bottom:6px;
}

.filters-virtual-note .text{
  opacity:.8;
  line-height:1.4;
}
