/* ===========================================================================
   Swehealth – mobil, del 4 (2026-11-04): kompakt filterrad på kategorisidor,
   klistrad köpknapp och dragspel på produktsidan, paginering, varukorgs-
   popupen. Hör ihop med vmod swehealth_z_mobil_del4.xml (som lägger till
   filterraden, köpraden och dragspelet) och laddas efter swehealth-mobil.css.
   Dator (>= 768px) påverkas inte, utom regeln längst ner som bara döljer
   tomma stjärnrader.
   =========================================================================== */

/* Filterraden och köpraden finns bara på mobil. */
#box-filter .swh-fbar,
#swh-sticky-buy {
  display: none;
}

@media (max-width: 767px) {

  /* -------------------------------------------------------------------------
     1. Kategorisidor: en rad "Filter (n)" + "Sortera" i stället för
        6–8 staplade fält (sök, attribut, Pris, Kan levereras nu, Fri frakt,
        Sortera, vy-knappar). Panelen fälls ut under raden. Valda filter
        visas som chips (.tokens) även när panelen är stängd.
     ------------------------------------------------------------------------- */
  #box-filter .swh-fbar {
    display: flex;
    gap: 8px;
    margin: 0 0 10px;
  }
  #box-filter .swh-fbar > * {
    flex: 1 1 0;
    min-width: 0;
  }
  #box-filter .swh-fbar-filter,
  #box-filter .swh-fbar-sort {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 6px 12px;
    border: 1px solid #c8c8c8;
    border-radius: 8px;
    background: #fff;
    color: #333;
    font: inherit;
    font-weight: 600;
    line-height: 1.2;
    -webkit-tap-highlight-color: transparent;
  }
  #box-filter .swh-fbar-filter[aria-expanded="true"] {
    border-color: #2674BA;
    color: #2674BA;
    background: rgba(38, 116, 186, 0.06);
  }
  #box-filter .swh-fbar-count:empty {
    display: none;
  }
  #box-filter .swh-fbar-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 1.5em;
    height: 1.5em;
    padding: 0 .35em;
    border-radius: 1em;
    background: #2674BA;
    color: #fff;
    font-size: .8em;
  }
  /* "Sortera" är en riktig <select> – mobilen visar sin egen vällista. */
  #box-filter .swh-fbar-sort {
    position: relative;
  }
  #box-filter .swh-fbar-sort select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    font-size: 16px;
  }
  #box-filter .swh-fbar-sort .swh-fbar-sort-value {
    font-weight: 400;
    color: #555;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #box-filter .swh-fbar-sort::after {
    content: "";
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    margin: -4px 0 0 2px;
    border-right: 2px solid #555;
    border-bottom: 2px solid #555;
    transform: rotate(45deg);
  }
  /* Panelen: stängd tills man trycker på Filter. Sorteringsmenyn och
     vy-knapparna i panelen behövs inte på mobil (sortering finns i raden). */
  #box-filter .filter {
    display: none;
    margin: 0 0 10px;
    padding: 12px;
    border: 1px solid #e3e3e3;
    border-radius: 8px;
    background: #fafafa;
  }
  #box-filter.swh-fopen .filter {
    display: grid;
    grid-auto-flow: row;
    grid-template-columns: 1fr;
  }
  #box-filter .filter .swh-fsort,
  #box-filter .filter .swh-fview {
    display: none;
  }
  #box-filter .filter .form-control,
  #box-filter .filter input[type="search"] {
    min-height: 44px;
    font-size: 16px;
  }
  #box-filter .filter .dropdown-menu li {
    margin: 0;
  }
  #box-filter .filter .dropdown-menu .option {
    display: flex;
    align-items: center;
    gap: .6em;
    min-height: 44px;
    padding: 0 1em;
    white-space: normal;
  }
  #box-filter .filter label.option {
    min-height: 44px !important;
  }
  #box-filter .tokens:not(:empty) {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 10px;
  }
  #box-filter .token {
    display: inline-flex;
    align-items: center;
    min-height: 36px;
    margin: 0;
  }
  #box-filter .token .remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 32px;
    min-height: 36px;
    margin-right: -.6em;
    font-size: 1.2em;
  }

  /* -------------------------------------------------------------------------
     2. Produktsidan: klistrad rad i botten med pris + Lägg i varukorg när
        köprutan inte syns på skärmen. Döljs medan ett fält har fokus, när
        varukorgs-popupen är öppen och när varan inte kan beställas.
     ------------------------------------------------------------------------- */
  #swh-sticky-buy {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 997;
    display: none;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-top: 1px solid #ddd;
    box-shadow: 0 -4px 14px rgba(0, 0, 0, .08);
  }
  body.swh-sticky-buy-on #swh-sticky-buy {
    display: flex;
  }
  body.swh-sticky-buy-on.cart-open #swh-sticky-buy {
    display: none;
  }
  #swh-sticky-buy .swh-sb-price {
    display: flex;
    flex-direction: column;
    min-width: 0;
    line-height: 1.2;
  }
  #swh-sticky-buy .swh-sb-amount {
    font-size: 1.15em;
    font-weight: 700;
    white-space: nowrap;
  }
  #swh-sticky-buy .swh-sb-tax {
    font-size: .75em;
    color: #666;
    white-space: nowrap;
  }
  #swh-sticky-buy .swh-sb-btn {
    flex: 0 0 auto;
    padding: 12px 20px;
    font-size: 1.05em;
    font-weight: 700;
  }
  body.swh-sticky-buy-on {
    padding-bottom: 84px;
  }
  body.swh-sticky-buy-on #swa-root {
    bottom: 92px !important;
  }
  body.swh-sticky-buy-on #scroll-up {
    bottom: calc(100px + env(safe-area-inset-bottom, 0px)) !important;
  }

  /* -------------------------------------------------------------------------
     3. Produktsidan: flikarna Beskrivning / Teknisk data / Filer blir
        dragspel (Beskrivning öppen). Inline-stilen display från app.js
        övertrumfas med !important.
     ------------------------------------------------------------------------- */
  #box-product.swh-pacc .nav-tabs {
    display: none !important;
  }
  #box-product.swh-pacc .tab-content {
    border-top: 1px solid rgba(0, 0, 0, .1);
  }
  #box-product.swh-pacc .tab-content > .tab-pane {
    display: none !important;
    padding: 4px 0 16px;
  }
  #box-product.swh-pacc .tab-content > .tab-pane.swh-open {
    display: block !important;
  }
  /* app.js gömmer flikpanelernas syskon med inline display:none när den
     aktiverar första fliken – därför !important på rubrikknapparna. */
  #box-product.swh-pacc .swh-pacc-title {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    min-height: 50px;
    margin: 0;
    padding: 8px 2px;
    border: 0;
    border-bottom: 1px solid rgba(0, 0, 0, .1);
    background: transparent;
    color: #1f3b5a;
    font: inherit;
    font-size: 1.1em;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
  }
  #box-product.swh-pacc .swh-pacc-title::after {
    content: "";
    flex: 0 0 auto;
    width: 10px;
    height: 10px;
    margin-right: 6px;
    border-right: 2px solid #555;
    border-bottom: 2px solid #555;
    transform: rotate(45deg);
    transition: transform .2s;
  }
  #box-product.swh-pacc .swh-pacc-title[aria-expanded="true"]::after {
    transform: rotate(-135deg);
  }
  #box-product.swh-pacc .swh-pacc-title[aria-expanded="true"] {
    border-bottom: 0;
  }
  /* Tekniska data: tabellen får inte bli bredare än skärmen. */
  #box-product .technical-data table,
  #box-product .description table {
    width: 100%;
    table-layout: fixed;
  }
  #box-product .technical-data table td,
  #box-product .description table td {
    overflow-wrap: anywhere;
    hyphens: auto;
    vertical-align: top;
  }
  #box-product .technical-data table td:first-child {
    width: 42%;
  }

  /* -------------------------------------------------------------------------
     4. Paginering: stora Föregående/Nästa, bara aktuell sida ±1.
        Första och sista posten är alltid Föregående/Nästa (func_draw).
     ------------------------------------------------------------------------- */
  .pagination {
    display: flex;
    width: 100%;
    flex-wrap: nowrap;
  }
  .pagination > li {
    display: none;
  }
  .pagination > li:first-child,
  .pagination > li:last-child,
  .pagination > li.active,
  .pagination > li.active + li,
  .pagination > li:has(+ li.active) {
    display: block;
  }
  .pagination > li:first-child,
  .pagination > li:last-child {
    flex: 1 1 0;
  }
  .pagination > li > a,
  .pagination > li > span {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 6px 10px;
  }

  /* -------------------------------------------------------------------------
     5. Varukorgs-popupen: större träffyta på papperskorgen, luft i raderna.
     ------------------------------------------------------------------------- */
  #cart .dropdown-menu .items li .btn-danger.btn-sm {
    min-width: 40px;
    min-height: 40px;
    padding: 8px 10px;
    font-size: 1em;
  }
  #cart .dropdown-menu .items li a {
    min-height: 56px;
  }
  #cart .dropdown-menu .close {
    font-size: 2em;
    padding: 0 8px;
  }
}

/* Tomma stjärnrader i produktlistor (inga recensioner längre) tar bara plats. */
.listing .product .rating:empty {
  display: none;
}
