/* ── Stock label & trigger icon ── */
.wi-stock {
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    position: relative;
    max-width: 100%;
    vertical-align: baseline;
}

.wi-stock__name {
    display: inline;
    color: inherit;
}

.wi-stock__icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.3em;
    height: 1.3em;
    padding: 0;
    margin: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #888;
    opacity: 0.85;
    cursor: pointer;
    line-height: 1;
    font: inherit;
    flex-shrink: 0;
    transition: opacity 0.2s ease-in-out, background-color 0.2s ease-in-out, color 0.2s ease-in-out;
}

.wi-stock__icon:hover,
.wi-stock__icon:focus-visible,
.wi-stock_is-open .wi-stock__icon {
    opacity: 1;
    outline: none;
    background: #f5f5f5;
    color: #555;
}

.wi-stock__icon-char {
    font-size: 0.92em;
    line-height: 1;
}

/* ── Desktop tooltip ── */
.wi-stock__popup {
    display: none;
    position: absolute;
    z-index: 10050;
    left: 50%;
    transform: translateX(-50%);
    min-width: 260px;
    max-width: min(380px, calc(100vw - 24px));
    pointer-events: auto;
}

.wi-stock__popup_is-visible {
    display: block;
}

.wi-stock__popup_is-fixed {
    position: fixed;
    left: 0;
    top: 0;
    transform: none;
    margin: 0;
}

.wi-stock__popup-card {
    display: block;
    border-radius: 3px;
    background: #fff;
    color: #333;
    border: 1px solid #f2f2f2;
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.05);
    text-align: left;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
}

.wi-stock__popup_is-visible .wi-stock__popup-card {
    animation: wi-card-in 0.18s ease-out;
}

@keyframes wi-card-in {
    from {
        opacity: 0;
        transform: translateX(4px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Arrow */
.wi-stock__popup::before,
.wi-stock__popup::after {
    content: '';
    position: absolute;
    border: 6px solid transparent;
    pointer-events: none;
}

.wi-stock__popup_pos-left::before {
    top: 50%;
    right: -11px;
    left: auto;
    transform: translateY(-50%);
    border-left-color: #fff;
    z-index: 2;
}

.wi-stock__popup_pos-left::after {
    top: 50%;
    right: -13px;
    left: auto;
    transform: translateY(-50%);
    border-left-color: #f2f2f2;
    z-index: 1;
}

.wi-stock__popup_pos-top::before,
.wi-stock__popup_pos-bottom::before {
    left: auto;
    transform: none;
    z-index: 2;
}

.wi-stock__popup_pos-top::after,
.wi-stock__popup_pos-bottom::after {
    left: auto;
    transform: none;
    z-index: 1;
}

.wi-stock__popup_pos-top::before {
    top: 100%;
    right: 20px;
    border-top-color: #fff;
}

.wi-stock__popup_pos-top::after {
    top: 100%;
    right: 19px;
    border: 7px solid transparent;
    border-top-color: #f2f2f2;
}

.wi-stock__popup_pos-bottom::before {
    bottom: 100%;
    right: 20px;
    border-bottom-color: #fff;
}

.wi-stock__popup_pos-bottom::after {
    bottom: 100%;
    right: 19px;
    border: 7px solid transparent;
    border-bottom-color: #f2f2f2;
}

.wi-stock__popup_pos-right.wi-stock__popup_pos-top::before,
.wi-stock__popup_pos-right.wi-stock__popup_pos-top::after,
.wi-stock__popup_pos-right.wi-stock__popup_pos-bottom::before,
.wi-stock__popup_pos-right.wi-stock__popup_pos-bottom::after {
    right: 10px;
}

.wi-stock__popup-title {
    display: block;
    margin: 0;
    padding: 12px 15px 10px;
    border-bottom: 1px solid #f2f2f2;
    font-weight: 500;
    font-size: 13px;
    line-height: 1.35;
    color: #1b1b1b;
    word-break: normal;
    overflow-wrap: break-word;
}

.wi-stock__popup-body {
    display: block;
    padding: 12px 15px 14px;
    font-size: 12px;
    line-height: 1.5;
    color: #555;
    word-break: normal;
    overflow-wrap: break-word;
}

.wi-stock__popup-body p {
    margin: 0 0 0.55em;
}

.wi-stock__popup-body p:last-child {
    margin-bottom: 0;
}

/* ── Field list ── */
.wi-stock-fields {
    margin: 0;
    padding: 0;
}

.wi-stock-fields__row {
    display: grid;
    grid-template-columns: minmax(80px, 34%) 1fr;
    gap: 2px 12px;
    margin: 0;
    padding: 8px 0;
    border-bottom: 1px solid #f2f2f2;
}

.wi-stock-fields__row:first-child {
    padding-top: 0;
}

.wi-stock-fields__row:last-child {
    padding-bottom: 0;
    border-bottom: 0;
}

.wi-stock-fields__title {
    margin: 0;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.45;
    color: #888;
    word-break: normal;
    overflow-wrap: break-word;
}

.wi-stock-fields__value {
    margin: 0;
    font-size: 12px;
    font-weight: 400;
    line-height: 1.45;
    color: #333;
    word-break: normal;
    overflow-wrap: anywhere;
}

.wi-stock-fields__value a {
    color: var(--link-color, var(--primary-color, #2d9cdb));
    text-decoration: underline;
    transition: color 0.2s ease-in-out;
}

.wi-stock-fields__value a:hover {
    color: var(--link-color-hover, var(--dark-color, #1b1b1b));
}

.product-stocks-available__name .wi-stock,
.product-skus-stocks__sku-stock-name .wi-stock {
    display: inline-flex;
}

/* ── Modal ── */
.wi-stock-modal.modal {
    width: 100%;
    max-width: 520px;
}

.wi-stock-modal .modal__content,
.wi-stock-modal__content {
    overflow: visible auto;
    max-height: calc(100vh - 120px);
}

.wi-stock-modal__body {
    word-break: normal;
    overflow-wrap: break-word;
}

.wi-stock-modal__body .wi-stock-fields__row {
    grid-template-columns: 1fr;
    gap: 3px;
    padding: 10px 0;
}

.wi-stock-modal__body .wi-stock-fields__title {
    font-size: 12px;
}

.wi-stock-modal__body .wi-stock-fields__value {
    font-size: 13px;
}

/* ── Fallback modal ── */
.wi-modal-fallback {
    position: fixed;
    inset: 0;
    z-index: 10060;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding: 0;
    background: rgba(0, 0, 0, 0.45);
    animation: wi-modal-fadein 0.2s ease-in-out;
}

.wi-modal-fallback__dialog {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: 85vh;
    margin: 0;
    padding: 0;
    border-radius: 5px 5px 0 0;
    background: #fff;
    overflow: hidden;
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.1);
    animation: wi-modal-slideup 0.25s ease-out;
}

.wi-modal-fallback__close {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 2;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 50%;
    background: #f5f5f5;
    color: #888;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out, color 0.2s ease-in-out;
}

.wi-modal-fallback__close:hover {
    background: #eee;
    color: #555;
}

.wi-modal-fallback__title {
    margin: 0;
    padding: 18px 48px 16px 20px;
    font-size: 18px;
    font-weight: 500;
    line-height: 1.3;
    color: #1b1b1b;
    border-bottom: 1px solid #f2f2f2;
}

.wi-modal-fallback__dialog .wi-stock-modal__body {
    padding: 16px 20px 22px;
    overflow: auto;
    max-height: calc(85vh - 60px);
}

@keyframes wi-modal-fadein {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes wi-modal-slideup {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

@media (min-width: 768px) {
    .wi-modal-fallback {
        align-items: center;
        padding: 24px;
    }

    .wi-modal-fallback__dialog {
        border-radius: var(--inputs-buttons-border-radius, 15px);
        animation: wi-modal-scalein 0.2s ease-out;
    }

    @keyframes wi-modal-scalein {
        from {
            opacity: 0;
            transform: scale(0.97);
        }
        to {
            opacity: 1;
            transform: scale(1);
        }
    }
}

@media (max-width: 767px) {
    .wi-stock__popup {
        display: none !important;
    }
}
