/* ── Overlay base ─────────────────────────────────────────────────────────── */

.swb-modal {
  display: flex;
  width: 100%;
  position: fixed;
  inset: 0;
  z-index: 100100;

  align-items: flex-start;
  justify-content: flex-end;

  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  background: rgba(0,0,0,0);

  transition:
    opacity .25s ease,
    background .25s ease,
    visibility 0s linear .25s;
}

.swb-modal--open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  background: rgba(0,0,0,.25);

  transition:
    opacity .25s ease,
    background .25s ease,
    visibility 0s;
}

.swb-modal--open-background {
  background: transparent;
}

/* ── iframe wrapper ───────────────────────────────────────────────────────── */

.swb-modal__iframe-wrapper {
  position: relative;
  height: 100vh;
  background: transparent;
  overflow: hidden;
  transform: translateX(100%);
  transition: transform 0.4s ease-out;
  right: 0;
  min-width: 420px;
}

.swb-modal--open .swb-modal__iframe-wrapper {
    transform: translateX(0);
}

/* Higher specificity (3 classes vs. 2 above) so closing always wins,
   regardless of source order or whether --ready is set. */
.swb-modal--open .swb-modal__iframe-wrapper.close {
  transform: translate(100%);
}

.swb-modal__loader {
    position: absolute;
    inset: 0;
    z-index: 2;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    opacity: 1;
    pointer-events: none;
    transition: opacity .2s ease;
}

.swb-modal--ready .swb-modal__loader {
    opacity: 0;
}

.swb-modal--no-loader .swb-modal__loader {
    display: none;
}

.swb-modal__loader-svg {
    width: 144px;
    height: 152px;
    fill: none;
}

.swb-modal__loader-svg #box1 {
    animation: swb-box1 1.5s linear infinite;
    transform-origin: center;
}

@keyframes swb-box1 {
    0%   { opacity: 0; transform: scale(25%); }
    13%  { opacity: 1; }
    80%  { opacity: 1; }
    94%  { opacity: 0; transform: scale(100%); }
    100% { opacity: 0; transform: scale(100%); }
}

.swb-modal__loader-svg #box2 {
    animation: swb-box2 1.5s linear infinite;
    transform-origin: center;
}

@keyframes swb-box2 {
    0%   { opacity: 0; transform: scale(27%); }
    20%  { opacity: 0; transform: scale(27%); }
    31%  { opacity: 1; }
    62%  { opacity: 1; }
    76%  { opacity: 0; transform: scale(100%); }
    100% { opacity: 0; transform: scale(100%); }
}

.swb-modal__loader-svg #box3 {
    animation: swb-box3 1.5s linear infinite;
    transform-origin: center;
}

@keyframes swb-box3 {
    0%   { opacity: 0; transform: scale(29%); }
    9%   { opacity: 0; transform: scale(29%); }
    22%  { opacity: 1; }
    71%  { opacity: 1; }
    85%  { opacity: 0; transform: scale(100%); }
    100% { opacity: 0; transform: scale(100%); }
}

.swb-modal__iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

/* ── Widget 1 (cart) — 420px desktop, 100% mobile ────────────────────────── */

.swb-modal--cart .swb-modal__iframe-wrapper {
    width: 420px;
}

@media ( max-width: 768px ) {
    .swb-modal--cart .swb-modal__iframe-wrapper {
        width: 100%;
    }
}

/* ── Widget 2/3 (fullscreen) ─────────────────────────────────────────────── */

.swb-modal--fullscreen {
    align-items: stretch;
}

.swb-modal--fullscreen .swb-modal__iframe-wrapper {
    width: 100vw;
}

/* ── Widget 2: Product Button ─────────────────────────────────────────────── */

.swb-product-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    cursor: pointer;
}

/* ── Widget 3: Context Button ─────────────────────────────────────────────── */

.swb-context-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    cursor: pointer;
}

/* ── Widget 4: Domain ────────────────────────────────────────────────────── */

.swb-domain-wrapper {
    position: relative;
    display: inline-flex;
    align-items: center;
    border: 1px solid black;
}

.swb-domain-prefix {
    flex-shrink: 0;
    padding: 0 4px 0 8px;
    color: #999;
    font-size: inherit;
    line-height: 1;
    pointer-events: none;
    user-select: none;
    white-space: nowrap;
}

.swb-domain-input {
    border: none;
    outline: none;
    background: transparent;
    font-size: inherit;
}

.swb-domain-wrapper--error {
    border-color: #e00;
}

.swb-domain-error {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    color: #e00;
    font-size: 12px;
    line-height: 1.3;
}

.swb-domain-error:empty {
    display: none;
}

.swb-domain-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    cursor: pointer;
    font-size: inherit;
}

.swb-domain-ghost {
    position: absolute;
    top: 0;
    left: 0; /* aggiornato dinamicamente da JS */
    height: 100%;
    display: flex;
    align-items: center;
    color: #999;
    font-size: inherit;
    line-height: 1;
    white-space: pre;
    pointer-events: none;
    user-select: none;
}

.swb-domain-ghost:empty {
    display: none;
}

.swb-tld-dropdown {
    position: absolute;
    top: 100%;
    left: 0; /* aggiornato dinamicamente da JS */
    z-index: 1000;
    list-style: none;
    margin: 2px 0 0;
    padding: 4px 0;
    min-width: 160px;
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 4px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .12);
}

.swb-tld-dropdown__item {
    padding: 6px 12px;
    cursor: pointer;
    font-size: 14px;
    color: #333;
    white-space: nowrap;
}

.swb-tld-dropdown__item:hover,
.swb-tld-dropdown__item--active {
    background: #f0f0f0;
}

/* ── Widget 1: Cart Icon & Badge ──────────────────────────────────────────── */

.swb-cart-icon {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    min-height: 44px;
    padding: 8px;
    background: none;
    border: none;
    cursor: pointer;
}

.swb-cart-badge {
    display: none;
    position: absolute;
    top: 4px;
    right: 0px;
    width: fit-content;
    height: 18px;
    padding: 0px 6px;
    border-radius: 9px;
    background: #e00;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
}
