/* =====================================================
   Shipping Insurance — Toggle Switch & Item Disguise
   ===================================================== */

/* ---------- Toggle Mount Container ---------- */
.insurance-toggle-mount {
  padding: 14px 0;
  margin-bottom: 4px;
}

/* ---------- Toggle Row ---------- */
/* Layout: [Icon] [Text...] [Switch] [Price] */
.shipping-insurance-toggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 8px;
  background: rgba(44, 103, 106, 0.06);
  border: 1px solid rgba(44, 103, 106, 0.15);
  transition: background 0.25s ease, border-color 0.25s ease;
}

.shipping-insurance-toggle:hover {
  background: rgba(44, 103, 106, 0.10);
  border-color: rgba(44, 103, 106, 0.25);
}

/* ---------- Insurance Icon (40x40 image) ---------- */
.insurance-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  transition: filter 0.3s ease, opacity 0.3s ease;
}

.insurance-icon img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  display: block;
}

/* Icon OFF state: grayscale */
.insurance-icon--off {
  filter: grayscale(100%);
  opacity: 0.45;
}

/* Icon ON state: full color */
.insurance-icon--on {
  filter: grayscale(0%);
  opacity: 1;
}

/* ---------- Text Wrapper (fills available space) ---------- */
.insurance-text-wrap {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
}

/* ---------- Widget Main Text ---------- */
.insurance-widget-text {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--color-body-text, #121B17);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------- Policy Info Link ---------- */
.insurance-policy-link {
  font-size: 11px;
  font-weight: 400;
  line-height: 1.3;
  color: var(--color-primary-btn-bg, #2C676A);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  cursor: pointer;
  white-space: nowrap;
  letter-spacing: 0.01em;
}

.insurance-policy-link:hover {
  opacity: 1;
}

/* ---------- Toggle Label (switch only, no flex grow) ---------- */
.insurance-toggle-label {
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  user-select: none;
  flex-shrink: 0;
  padding: 0;
  margin: 0;
}

/* ---------- Upgraded Toggle Switch ---------- */
.insurance-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.insurance-switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.insurance-slider {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #d0d4d8 0%, #bfc4c9 100%);
  border-radius: 24px;
  transition: background 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Knob */
.insurance-slider-knob {
  position: absolute;
  height: 20px;
  width: 20px;
  left: 2px;
  top: 2px;
  background: linear-gradient(180deg, #ffffff 0%, #f5f5f5 100%);
  border-radius: 50%;
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1),
              box-shadow 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18),
              0 0 0 1px rgba(0, 0, 0, 0.04);
}

/* Checked state */
.insurance-switch input:checked + .insurance-slider {
  background: linear-gradient(135deg, var(--color-primary-btn-bg, #2C676A) 0%, #35807e 100%);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.08),
              0 0 8px rgba(44, 103, 106, 0.25);
}

.insurance-switch input:checked + .insurance-slider .insurance-slider-knob {
  transform: translateX(20px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2),
              0 0 0 1px rgba(0, 0, 0, 0.04);
}

/* Focus visible */
.insurance-switch input:focus-visible + .insurance-slider {
  outline: 2px solid var(--color-primary-btn-bg, #2C676A);
  outline-offset: 2px;
}

/* Hover knob glow */
.insurance-switch:hover .insurance-slider-knob {
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.22),
              0 0 0 1px rgba(0, 0, 0, 0.04);
}

/* ---------- Premium Amount ---------- */
.insurance-premium-amount {
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
  flex-shrink: 0;
  color: var(--color-body-text, #121B17);
  min-width: 40px;
  text-align: right;
}


/* =====================================================
   Insurance Item Disguise in Cart
   ===================================================== */

/* Completely hide the shipping insurance product row from the cart drawer and cart page */
.shipping-insurance-item {
  display: none !important;
}


/* =====================================================
   Responsive Tweaks
   ===================================================== */
@media (max-width: 959.98px) {
  .shipping-insurance-toggle {
    padding: 8px 12px;
    gap: 8px;
  }

  .insurance-icon {
    width: 32px;
    height: 32px;
  }

  .insurance-icon img {
    width: 32px;
    height: 32px;
  }

  .insurance-switch {
    width: 40px;
    height: 22px;
  }

  .insurance-slider-knob {
    width: 18px;
    height: 18px;
  }

  .insurance-switch input:checked + .insurance-slider .insurance-slider-knob {
    transform: translateX(18px);
  }

  .insurance-widget-text {
    font-size: 13px;
  }

  .insurance-premium-amount {
    font-size: 13px;
  }

  .insurance-policy-link {
    font-size: 10px;
  }
}

/* =====================================================
   Duplicate Toggle Prevention on Cart Page
   ===================================================== */
/* If on the cart page, hide the drawer's toggle switch to prevent duplicates when drawer is closed */
.template-cart:not(.drawer-is-open) #cart-drawer-modal .insurance-toggle-mount,
.template-cart:not(.drawer-is-open) .cart-drawer-summary .insurance-toggle-mount,
.template-cart:not(.drawer-is-open) .cart-drawer-summary-sticky .insurance-toggle-mount {
  display: none !important;
}

/* If the drawer is OPENED on the cart page, hide the main page's toggle switch to prevent overlaps and leaks through the semi-transparent drawer */
body.drawer-is-open .cart-summary .insurance-toggle-mount {
  display: none !important;
}
