/* ==================== APF: Bild-popup ==================== */
.wapf-popup{
  cursor:pointer; font-size:18px; color:#007bff; transition:transform .2s;
  display:block; width:100%; height:auto; margin-left:0; position:relative; z-index:2;
}
.wapf-popup img{
  display:block; width:100%; height:auto; border-radius:5px; object-fit:contain;
}
.wapf-image-popup{
  position:fixed; inset:0; width:100vw; height:100vh;
  background:rgba(0,0,0,.8);
  display:none; /* togglas till flex via JS */
  justify-content:center; align-items:center; z-index:9999;
}
.wapf-image-popup img{
  max-width:80%; max-height:80%; border-radius:8px; box-shadow:0 2px 10px rgba(0,0,0,.5);
}
.wapf-image-popup .close-popup{
  position:fixed; top:15px; right:15px; font-size:40px; color:#fff; cursor:pointer; user-select:none;
  z-index:10000;
}
.wapf-hide-label label{ display:none !important; }

@media (max-width:600px){
  .wapf-image-popup img{ max-width:95%; max-height:80%; }
  .wapf-image-popup .close-popup{ top:10px; right:10px; font-size:30px; }
}

/* =====================================================================
   BASELINE (neutral): påverka inte andra moduler/sektioner
   ===================================================================== */
:where(.single-product) :is(.wapf-add-clone, [data-wapf-action="add"]){
  display:inline-flex;
  align-items:center; justify-content:center; gap:6px;
  padding:5px 8px;
  border-radius:6px;
  background:transparent; color:inherit; border:0;
  font-size:inherit; line-height:1;
  text-decoration:none; cursor:pointer;
  transition:background .2s ease, transform .08s ease, border-color .2s ease;
}
:where(.single-product) :is(.wapf-add-clone, [data-wapf-action="add"])::before{ content:none; }

/* =====================================================================
   SCOPAD SEKTION: .apf-lagg-till-mer-sektion (DIN GRÖNA KNAPP)
   ===================================================================== */
.apf-lagg-till-mer-sektion :is(.wapf-add-clone, [data-wapf-action="add"]){
  display:inline-flex !important;
  align-items:center; justify-content:center; gap:6px;
  position:relative;
  font-size:0 !important;            /* dölj originaltexten på knappen */
  line-height:1;
  padding:5px 8px !important;
  border-radius:6px !important;
  background:#386641 !important; color:#fff !important;
  border:1px solid #2f5536 !important;
  cursor:pointer; text-decoration:none !important;
  transition:background .2s ease, transform .08s ease, border-color .2s ease;
}

/* Sätt vår egen text som pseudo – funkar även om någon annan lägger in text/svg */
.apf-lagg-till-mer-sektion :is(.wapf-add-clone, [data-wapf-action="add"])::before{
  content:"Lägg till fler";
  font-size:12px; font-weight:700; line-height:1;
}

/* Dölj ALLT inre (t.ex. ×, svg, spans) så bara ::before syns */
.apf-lagg-till-mer-sektion :is(.wapf-add-clone, [data-wapf-action="add"]) > *,
.apf-lagg-till-mer-sektion :is(.wapf-add-clone, [data-wapf-action="add"]) svg,
.apf-lagg-till-mer-sektion :is(.wapf-add-clone, [data-wapf-action="add"]) .dashicons{
  display:none !important;
}

.apf-lagg-till-mer-sektion :is(.wapf-add-clone, [data-wapf-action="add"]):hover{
  background:#2f5536 !important; border-color:#284a2e !important;
}
.apf-lagg-till-mer-sektion :is(.wapf-add-clone, [data-wapf-action="add"]):active{
  transform:translateY(1px);
}
.apf-lagg-till-mer-sektion :is(.wapf-add-clone, [data-wapf-action="add"]):focus-visible{
  outline:2px solid #2f5536; outline-offset:2px;
  box-shadow:0 0 0 2px rgba(56,102,65,.25);
}

/* Papperskorg i scopad sektion (behåll 🗑, göm ev. andra ikoner) */
.apf-lagg-till-mer-sektion :is(.wapf-del-clone, .wapf-remove, .wapf-remove-file, .wapf-file-remove){
  font-size:0 !important;
  width:22px; height:22px; line-height:22px; text-align:center;
  border-radius:6px; border:1px solid #e6e6e6; background:#fff;
  display:inline-grid; place-items:center; cursor:pointer;
  transition:transform .08s ease, border-color .2s ease;
}
.apf-lagg-till-mer-sektion :is(.wapf-del-clone, .wapf-remove, .wapf-remove-file, .wapf-file-remove)::before{
  content:"🗑"; font-size:14px; color:#c62828; line-height:1;
}
.apf-lagg-till-mer-sektion :is(.wapf-del-clone, .wapf-remove, .wapf-remove-file, .wapf-file-remove) > *,
.apf-lagg-till-mer-sektion :is(.wapf-del-clone, .wapf-remove, .wapf-remove-file, .wapf-file-remove) svg{
  display:none !important;
}
.apf-lagg-till-mer-sektion :is(.wapf-del-clone, .wapf-remove, .wapf-remove-file, .wapf-file-remove):hover{
  border-color:#c62828; transform:scale(1.04);
}

/* Repeater-knappen i tabellen (måttbeställning) – oförändrad */
.single-product .wapf-field[data-wapf-type="repeater"] .wapf-cloner
> :is(.wapf-add-clone, [data-wapf-action="add"]){
  display:inline-flex !important;
  align-items:center; justify-content:center; gap:6px;
  font-size:0 !important; line-height:1;
  padding:5px 8px !important;
  border-radius:6px !important;
  background:#386641 !important; color:#fff !important;
  border:1px solid #2f5536 !important;
  cursor:pointer; text-decoration:none !important;
  transition:background .2s ease, transform .08s ease, border-color .2s ease;
}
.single-product .wapf-field[data-wapf-type="repeater"] .wapf-cloner
> :is(.wapf-add-clone, [data-wapf-action="add"])::before{
  content:"Lägg till fler";
  font-size:12px; font-weight:700; line-height:1;
}

/* Nollning utanför repeatrar för att undvika spökknappar */
.single-product .wapf-field:not([data-wapf-type="repeater"])
  :is(.wapf-add-clone, [data-wapf-action="add"]){
  background:transparent !important; border:0 !important; padding:0 !important;
  font-size:inherit !important; color:inherit !important;
}
.single-product .wapf-field:not([data-wapf-type="repeater"])
  :is(.wapf-add-clone, [data-wapf-action="add"])::before{ content:none !important; }

/* =====================================================================
   APF: Tabell (produktsida)
   ===================================================================== */
.single-product .apf-table{ position:relative; display:grid;
  grid-template-columns:22% 22% 16% 16% 24% 40px; grid-column-gap:10px; grid-row-gap:8px;
  align-items:center; border:1px solid #e6e6e6; border-top:0; padding:10px 14px; background:#fff; border-radius:0 0 8px 8px;
  font-variant-numeric:tabular-nums;
}
.single-product .apf-table .wapf-field-label,
.single-product .apf-table .wapf-label,
.single-product .apf-table .wapf-input-label,
.single-product .apf-table .wapf-repeater__label,
.single-product .apf-table .wapf-group__label{ display:none !important; }

.single-product .apf-table .apf-silent{ display:none !important; }

.single-product .apf-head{
  display:grid; grid-template-columns:22% 22% 16% 16% 24% 40px; grid-column-gap:10px; align-items:center;
  background:#386641; color:#fff; font-weight:700; border-radius:8px 8px 0 0; padding:12px 14px; margin-top:10px;
  font-size:14px; line-height:1.15;
}
.single-product .apf-head > div{ text-align:left; }

.single-product .apf-table .apf-col{ min-width:0; }
.single-product .apf-table .apf-length{ grid-column:1; }
.single-product .apf-table .apf-qty{ grid-column:2; }
.single-product .apf-table .apf-coverwidth{ grid-column:3; }
.single-product .apf-table .apf-covercalc{ grid-column:4; }
.single-product .apf-table .apf-kvm{ grid-column:5; }

.single-product .apf-table .apf-coverwidth,
.single-product .apf-table .apf-covercalc,
.single-product .apf-table .apf-kvm{ border-left:1px solid #e6e6e6; padding-left:10px; }

.single-product .apf-table .apf-coverwidth .wapf-calc-wrapper,
.single-product .apf-table .apf-covercalc  .wapf-calc-wrapper,
.single-product .apf-table .apf-kvm        .wapf-calc-wrapper{
  display:block; width:100%; min-height:34px; text-align:right; padding-right:6px;
}

.single-product .apf-table .wapf-field,
.single-product .apf-table .wapf-field-input{ margin:0 !important; }
.single-product .apf-table .wapf-field .wapf-input{ margin:0 !important; }

.single-product .apf-table input[type="number"],
.single-product .apf-table input[type="text"],
.single-product .apf-table select{
  width:100%; min-width:0; height:34px; padding:6px 10px; font-size:13px; border:1px solid #d8d8d8; border-radius:4px; background:#fff; box-sizing:border-box;
}

/* Knappraden under tabellen */
.single-product .apf-table .wapf-cloner{
  grid-column:1/-1; display:flex; align-items:center; gap:8px; margin-top:6px;
}
.single-product .apf-table .wapf-cloner .wapf-add-clone{
  display:inline-flex; align-items:center; justify-content:center;
  background:#386641; color:#fff; border:0; border-radius:8px; padding:8px 12px; font-size:13px; font-weight:700; line-height:1; cursor:pointer;
  transition:background .2s, transform .08s;
}
.single-product .apf-table .apf-coverwidth .wapf-calc-wrapper,
.single-product .apf-table .apf-covercalc  .wapf-calc-wrapper,
.single-product .apf-table .apf-kvm        .wapf-calc-wrapper{
  text-align:right; padding-right:6px;
}
.single-product .apf-table .wapf-cloner .wapf-add-clone:hover{ background:#2f5536; }
.single-product .apf-table .wapf-cloner .wapf-add-clone:active{ transform:translateY(1px); }

/* Papperskorg i tabellens knapprad */
.single-product .apf-table .wapf-cloner .wapf-del-clone{
  display:inline-grid; place-items:center; width:34px; height:34px; border-radius:8px; background:#fff; border:1px solid #e6e6e6; line-height:1; padding:0; margin:0; cursor:pointer; position:relative; font-size:0;
}
.single-product .apf-table .wapf-cloner .wapf-del-clone > svg{ display:none; }
.single-product .apf-table .wapf-cloner .wapf-del-clone::before{ content:"🗑"; font-size:16px; color:#c62828; }
.single-product .apf-table .wapf-cloner .wapf-del-clone:hover{ border-color:#c62828; transform:scale(1.03); }

/* ===== Mobil ≤720px ===== */
@media (max-width:720px){
  .single-product .apf-head{ display:none; }

  .single-product .apf-table .wapf-field-label{
    display:block !important; position:static !important; font-size:12px; font-weight:600; color:#2f5536;
    line-height:1.25; margin:0 0 4px; white-space:normal; overflow:visible; word-break:break-word; hyphens:auto;
  }

  .single-product .apf-table{
    display:block; padding:0; border:0; background:transparent;
  }
  .single-product .apf-table .wapf-clone{
    display:grid !important; grid-template-columns:60% 40%;
    grid-column-gap:10px; grid-row-gap:10px; padding:12px; margin:12px 0;
    border:1px solid #e6e6e6; background:#fff; border-radius:8px;
  }
  .single-product .apf-table .apf-length{ grid-column:1; }
  .single-product .apf-table .apf-qty{ grid-column:2; }
  .single-product .apf-table .apf-coverwidth{ grid-column:1; border-left:0; padding-left:0; }
  .single-product .apf-table .apf-covercalc{ grid-column:2; border-left:0; padding-left:0; }
  .single-product .apf-table .apf-kvm{ grid-column:1 / span 2; border-left:0; padding-left:0; }

  .single-product .apf-table .apf-coverwidth .wapf-calc-wrapper,
  .single-product .apf-table .apf-covercalc  .wapf-calc-wrapper,
  .single-product .apf-table .apf-kvm        .wapf-calc-wrapper{ text-align:right; padding-right:0; }

  .single-product .apf-table input[type="number"],
  .single-product .apf-table input[type="text"],
  .single-product .apf-table select{ height:38px; }

  .single-product .apf-table .wapf-cloner{ grid-column:1/-1; display:flex; gap:10px; padding:10px 0 0; margin:0; width:100%; }
}

/* ==================== Tekniskt: dolda fält/spöke ==================== */
.js-total-kvm, .js-total-kvm input{ position:absolute; left:-9999px; opacity:0; pointer-events:none; }
.apf-ghost-active{ position:absolute !important; left:-99999px !important; width:1px !important; height:1px !important; margin:0 !important; padding:0 !important; opacity:0 !important; pointer-events:none !important; }
