/* ============================================
   assets/css/customers-filter.css
   Filtren i Kunder (AT-359). JS: modules/customers-filter.js. Återanvänder listornas filterikon och piller
   (list-tools.css: .list-filter-btn, .list-filter-count, .list-chip) och Garagets rullista/datumfält/markeringsfärg
   (archive-filters.css: "Alla …" ljust, valt värde grön ton). Inga nya knappvarianter (L-247). Bara temats tokens.
   ============================================ */

/* Filterikonen i Kunders två sökrutor: samma mått, färg och accent som listornas (list-tools.css AT-151). */
#view-customers .list-filter-btn { position: absolute; right: 36px; top: 50%; transform: translateY(-50%); width: 28px; height: 28px; display: flex; align-items: center; justify-content: center; padding: 0; border: none; background: transparent; color: var(--text-secondary); cursor: pointer; border-radius: 8px; }
#view-customers .list-filter-btn:hover,
#view-customers .list-filter-btn.is-open { color: var(--accent-primary); background: color-mix(in srgb, var(--accent-primary) 10%, transparent); }
#view-customers .list-filter-btn.is-active { color: var(--accent-primary); }

/* Mittytans sökruta: sökrensarens ram (list-tools.css .search-clear-field) bär ikonen inne till höger. */
:root body #view-customers .cf-main-field { --search-icons: 34px; }
:root body #view-customers .cf-main-field > #customer-search-main { padding-left: 40px !important; padding-right: calc(var(--search-icons) + 8px) !important; }
:root body #view-customers .cf-main-field.has-search-value > #customer-search-main { padding-right: calc(var(--search-icons) + var(--search-clear-width) + 8px) !important; }
#view-customers .cf-main-field > .list-filter-btn { right: 6px; }
:root body #view-customers .cf-main-field:has(.list-filter-btn.is-active) > #customer-search-main { border-color: var(--accent-primary) !important; }

/* Panelen under mittytans sökruta (Patrik 11-26: mindre och diskretare, utan ram, smälter in som statistikrutan
   view-stats-box.css): ingen kant eller platta, dämpad tills man pekar på den eller ett val är aktivt; valen är
   låga piller. Valda filter behåller Garagets gröna markering. */
#view-customers .cf-panel { flex: 0 0 auto; width: 460px; max-width: 100%; margin-top: 10px; padding: 0; box-sizing: border-box; border: 0; background: transparent; text-align: left; opacity: 0.72; transition: opacity 160ms ease; }
#view-customers .cf-panel:is(:hover, :focus-within, :has(.cf-set), :has(select.filter-select > option:checked:not([value="all"]))) { opacity: 1; }
#view-customers .cf-panel[hidden] { display: none; }
#view-customers .cf-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
#view-customers .cf-grid > .atlas-filter-dd { width: 100%; min-width: 0; }
#view-customers .cf-dates { grid-column: 1 / -1; display: flex; gap: 6px; align-items: center; min-width: 0; }
#view-customers .cf-dates > :is(.filter-input, .atlas-date-field) { flex: 1 1 0; min-width: 0; }
#view-customers .cf-hint { margin: 6px 4px 0; font-size: 11px; line-height: 1.35; color: var(--text-secondary); opacity: 0.8; text-align: center; }

/* Pillerform: låga, rundade, tunn kant och nästan genomskinlig ton (statistikrutans recept). */
:root body #view-customers .cf-panel select.filter-select + .atlas-filter-dd,
:root body #view-customers .cf-panel input.filter-input {
  min-height: 28px !important; height: 28px !important; padding: 0 12px !important; border-radius: 999px !important;
  font-size: 12px !important; font-weight: 500; box-shadow: none !important;
  border: 1px solid color-mix(in srgb, var(--border-color, currentColor) 45%, transparent) !important;
  background: color-mix(in srgb, var(--accent-primary) 3%, transparent) !important;
}
:root body #view-customers .cf-panel select.filter-select + .atlas-filter-dd .atlas-filter-dd-chevron { opacity: 0.6; }

/* Krysset: bara ikonen, ingen ruta; tonar upp vid hovring. */
:root body #view-customers .cf-dates > #cf-clear.icon-clear-btn {
  width: 28px !important; height: 28px !important; flex-shrink: 0; padding: 0 !important;
  border: 0 !important; background: transparent !important; box-shadow: none !important; border-radius: 999px !important;
  color: var(--text-secondary) !important; opacity: 0.75;
}
:root body #view-customers .cf-dates > #cf-clear.icon-clear-btn:hover { opacity: 1; color: var(--text-primary) !important; background: color-mix(in srgb, var(--text-primary) 6%, transparent) !important; }

/* Markeringsfärg: samma effekt som Garagets filter (archive-filters.css, ledare 81 AT-351). */
:root body #view-customers .cf-panel select.filter-select:has(> option:checked:not([value="all"])) + .atlas-filter-dd,
:root body #view-customers .cf-panel input.filter-input.cf-set {
  background: color-mix(in srgb, var(--accent-primary) 22%, transparent) !important;
  border-color: var(--accent-primary) !important; font-weight: 600;
}

/* Pillren ovanför vänsterlistan (listornas .list-chip, aktiv ton). */
#view-customers .cf-pills { flex: 0 0 auto; padding: 0 12px 8px; box-sizing: border-box; max-height: none; }
#view-customers .cf-pills[hidden] { display: none; }
#view-customers .cf-pills .list-chip { flex: 0 0 auto; cursor: pointer; max-width: 100%; }
#view-customers .cf-pills .list-chip-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

@media (max-width: 768px) {
  #view-customers .cf-panel { width: auto; margin: 0 12px 8px; opacity: 1; }
  /* Öppen panel = som aktiv sökning (mobile.css): listytan får full höjd och startbilden döljs, annars klipps panelen
     av listytans tak (42svh) i tomläget. */
  :root body #view-customers:not(.mobile-detail-open):has(#customers-filter-panel:not([hidden])) .template-list-container { max-height: none !important; flex: 1 1 auto !important; }
  :root body #view-customers:not(.mobile-detail-open):has(#customers-filter-panel:not([hidden])) .template-editor-container { display: none !important; }
  #view-customers .cf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #view-customers .list-filter-btn { width: 36px; height: 36px; right: 48px; }
  #view-customers .cf-main-field > .list-filter-btn { right: 4px; }
}

/* AT-361 (Patrik 11-27): filtren som kontrollpanelens nedre, utfällbara del (view-stats-box.js .vs-slot). Rutan blir
   bredare medan filtren är utfällda; valen ligger två och två, låga, och datumen på en rad. Ingen egen ram: rutans. */
/* Samma bredd öppen och stängd (Patrik 11-27: rutan ska inte ändra storlek när filtren fälls ut). */
#view-customers .atlas-viewstats:not(.is-cramped):not(.vs-corner) { width: 280px; }
/* Överkanten låst medan filtren är utfällda (customers-filter.js anchorBox): växer rakt ner. */
#view-customers .atlas-viewstats.vs-anchored { transform: none; }
/* Långa val kortas med "…", pilen stannar på samma rad. */
:root body #view-customers .cf-panel.cf-in-box .atlas-filter-dd { display: flex !important; align-items: center; gap: 4px; min-width: 0; overflow: hidden; }
#view-customers .cf-panel.cf-in-box .atlas-filter-dd-chevron { flex: 0 0 auto; }
/* Rensa överst i Filter-raden, rött som Garagets (style-tickets.css .icon-clear-btn). */
#view-customers #cf-clear[hidden] { display: none !important; }
#view-customers .vs-slot { display: grid; }
#view-customers .vs-slot > .vs-filter-toggle { grid-area: 1 / 1; align-self: stretch; margin: 0; }
#view-customers .vs-slot > .cf-panel { grid-area: 2 / 1; }
:root body #view-customers .vs-slot > #cf-clear.icon-clear-btn { grid-area: 1 / 1; align-self: center; justify-self: end; margin: 0 20px 0 0; width: 22px !important; height: 20px !important; padding: 0 !important; border: 0 !important; background: transparent !important; border-radius: 999px !important; }
:root body #view-customers .vs-slot > #cf-clear.icon-clear-btn:not([hidden]) { display: grid !important; place-items: center; }
/* Bara krysset, ingen ruta (Patrik 11-27); en svag röd ton när man pekar. */
:root body #view-customers .vs-slot > #cf-clear.icon-clear-btn:hover { background: rgba(255, 68, 68, 0.12) !important; }
#view-customers .vs-slot > #cf-clear svg { width: 12px; height: 12px; }
#view-customers .atlas-viewstats.vs-filtering { opacity: 0.95; }
#view-customers .vs-slot { margin-top: 8px; padding-top: 6px; border-top: 1px solid color-mix(in srgb, var(--border-color, currentColor) 40%, transparent); }
#view-customers .vs-filter-toggle { display: flex; align-items: center; gap: 6px; width: 100%; padding: 2px 0; border: 0; background: none; color: var(--text-secondary); font: inherit; font-size: 11px; letter-spacing: 0.04em; text-transform: uppercase; cursor: pointer; }
#view-customers .vs-filter-toggle svg { width: 12px; height: 12px; }
#view-customers .vs-filter-toggle:hover,
#view-customers .vs-filter-toggle.is-active { color: var(--accent-primary); }
#view-customers .vs-filter-toggle .vs-filter-chev { margin-left: auto; display: grid; place-items: center; line-height: 1; opacity: 0.7; }
#view-customers .vs-filter-count { min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px; background: var(--accent-primary); color: var(--bg-primary, #fff); font-size: 10px; line-height: 16px; text-align: center; letter-spacing: 0; }
#view-customers .cf-panel.cf-in-box { width: 100%; margin-top: 6px; opacity: 1; }
#view-customers .cf-panel.cf-in-box .cf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; }
:root body #view-customers .cf-panel.cf-in-box select.filter-select + .atlas-filter-dd,
:root body #view-customers .cf-panel.cf-in-box input.filter-input { min-height: 26px !important; height: 26px !important; padding: 0 10px !important; font-size: 11.5px !important; }
#view-customers .cf-panel.cf-in-box .cf-dates { gap: 5px; }
#view-customers .cf-panel.cf-in-box .cf-hint { text-align: left; margin: 5px 2px 0; font-size: 10.5px; }

/* Pillren ovanför vänsterlistan: bara så breda som texten (högst 120 px), inte tre lika breda (Patrik 11-27: rörigt). */
#view-customers .cf-pills { display: flex; flex-wrap: wrap; gap: 4px; }
#view-customers .cf-pills .list-chip { flex: 0 1 auto; width: auto; max-width: 120px; min-width: 0; }
/* Ett ensamt piller får hela radens bredd, så att t.ex. "Hörde av sig 1 nov. – 30 nov." syns helt (Patrik 11-27). */
#view-customers .cf-pills .list-chip:only-child { max-width: 100%; }
#view-customers .cf-pills .cf-chip { gap: 5px; }
