/* ==========================================================================
   Mini-koszyk R4 - panel wysuwany z prawej
   Powłoka: template-parts/cart-modal.php, logika: helpers/minicart-r4.php
   ========================================================================== */

.sbm {
    --sbm-accent: var(--main-accent, #4804a4);
    --sbm-accent-dark: #36037c;
    --sbm-green: var(--accent-green, #00674f);
    --sbm-green-soft: #e6f2ee;
    --sbm-bg-soft: var(--tlo-background, #fff7f3);
    --sbm-text: var(--text, #22262a);
    --sbm-muted: var(--accent-gray, #767676);
    --sbm-line: #e9e6ee;
    --sbm-radius: 10px;
    --sbm-width: 420px;
    --sbm-speed: .28s;

    position: fixed;
    inset: 0;
    z-index: 100000;
    color: var(--sbm-text);
    font-family: var(--font-secondary-regular-family), sans-serif;
    font-size: 14px;
    line-height: 1.4;
    visibility: hidden;
    pointer-events: none;
}

.sbm[hidden] {
    display: none;
}

.sbm *,
.sbm *::before,
.sbm *::after {
    box-sizing: border-box;
}

.sbm.is-open {
    visibility: visible;
    pointer-events: auto;
}

.sbm-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(20, 16, 30, .45);
    opacity: 0;
    transition: opacity var(--sbm-speed) ease;
}

.sbm.is-open .sbm-backdrop {
    opacity: 1;
}

.sbm-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(var(--sbm-width), calc(100% - 32px));
    background: #fff;
    box-shadow: -8px 0 32px rgba(20, 16, 30, .18);
    transform: translateX(100%);
    transition: transform var(--sbm-speed) cubic-bezier(.2, .8, .2, 1);
    outline: none;
}

.sbm.is-open .sbm-panel {
    transform: translateX(0);
}

@media (prefers-reduced-motion: reduce) {
    .sbm-backdrop,
    .sbm-panel {
        transition: none;
    }
}

body.sbm-lock {
    overflow: hidden;
}

/* Kwoty Woo dziedziczą krój i rozmiar z kontekstu (motyw powiększa .amount) */
.sbm .woocommerce-Price-amount,
.sbm .woocommerce-Price-amount bdi,
.sbm .woocommerce-Price-currencySymbol,
.sbm del,
.sbm ins {
    font-size: inherit;
    font-family: inherit;
    font-weight: inherit;
    color: inherit;
}

.sbm del {
    color: var(--sbm-muted);
    margin-right: 4px;
    font-weight: 400;
}

.sbm ins {
    text-decoration: none;
}

.sbm a {
    color: inherit;
    text-decoration: none;
}

/* Motyw na telefonie powiększa span - w panelu rozmiar dziedziczy się z rodzica */
.sbm span {
    font-size: inherit;
}

.sbm button {
    font-family: inherit;
    cursor: pointer;
}

/* --- Układ: nagłówek / przewijana treść / stopka -------------------------- */

.sbm-inner {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.sbm-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 18px 16px 12px;
}

.sbm .sbm-title {
    margin: 0;
    font-family: var(--font-secondary-bold-family), sans-serif;
    font-weight: 700;
    font-size: 20px;
    line-height: 1.2;
    letter-spacing: 0;
    text-transform: none;
    color: var(--sbm-text);
}

.sbm-close {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    margin-right: -8px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: var(--sbm-muted);
}

.sbm-close:hover {
    background: var(--sbm-bg-soft);
    color: var(--sbm-text);
}

.sbm-scroll {
    flex: 1 1 auto;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 0 16px 16px;
}

.sbm-foot {
    flex: 0 0 auto;
    display: grid;
    gap: 10px;
    padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--sbm-line);
    background: #fff;
}

/* Ładowanie (pierwsze otwarcie i odświeżenie po akcji) */
.sbm-inner.is-placeholder .sbm-scroll {
    background:
        linear-gradient(#f3f0f6, #f3f0f6) 16px 8px / calc(100% - 32px) 36px no-repeat,
        linear-gradient(#f3f0f6, #f3f0f6) 16px 60px / calc(100% - 32px) 56px no-repeat,
        linear-gradient(#f3f0f6, #f3f0f6) 16px 128px / calc(100% - 32px) 56px no-repeat,
        linear-gradient(#f3f0f6, #f3f0f6) 16px 208px / calc(100% - 32px) 64px no-repeat;
    animation: sbm-pulse 1.2s ease-in-out infinite;
}

@keyframes sbm-pulse {
    50% { opacity: .55; }
}

.sbm.is-busy .sbm-scroll,
.sbm.is-busy .sbm-foot {
    opacity: .6;
    transition: opacity .15s;
}

/* --- 1. Komunikat "Dodano do koszyka" ------------------------------------- */

.sbm-added {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 0 12px;
    padding: 9px 12px;
    border-radius: 6px;
    background: var(--sbm-green-soft);
    color: var(--sbm-green);
    font-size: 13px;
}

.sbm-dot {
    flex: 0 0 auto;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--sbm-green);
}

.sbm-error {
    margin: 0 0 12px;
    padding: 9px 12px;
    border-radius: 6px;
    background: #fdecec;
    color: #a32722;
    font-size: 13px;
}

.sbm-empty {
    margin: 24px 0;
    text-align: center;
    color: var(--sbm-muted);
}

/* --- 2. Pozycje z +/- ------------------------------------------------------ */

.sbm-items {
    margin: 0;
    padding: 0;
    list-style: none;
}

.sbm-item {
    display: grid;
    grid-template-columns: 56px 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
}

.sbm-item + .sbm-item {
    border-top: 1px solid var(--sbm-line);
}

.sbm-thumb-link,
.sbm-item > .sbm-thumb {
    display: block;
    width: 56px;
    height: 56px;
}

.sbm .sbm-thumb {
    width: 56px;
    height: 56px;
    object-fit: contain;
    border-radius: 6px;
}

.sbm-item-info {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.sbm-item-name {
    font-size: 13px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sbm a.sbm-item-name:hover {
    color: var(--sbm-accent);
}

.sbm-item-price {
    font-family: var(--font-secondary-bold-family), sans-serif;
    font-weight: 700;
    font-size: 13px;
}

.sbm-stepper {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--sbm-line);
    border-radius: 8px;
}

.sbm-stepper button {
    width: 30px;
    height: 32px;
    padding: 0;
    border: 0;
    background: transparent;
    color: var(--sbm-text);
    font-size: 16px;
    line-height: 1;
}

.sbm-stepper button:hover:not(:disabled) {
    color: var(--sbm-accent);
}

.sbm-stepper button:disabled {
    opacity: .35;
    cursor: default;
}

.sbm-qty {
    min-width: 20px;
    text-align: center;
    font-size: 13px;
}

.sbm-remove {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 1px solid var(--sbm-line);
    border-radius: 8px;
    background: transparent;
    color: var(--sbm-muted);
}

/* --- 3. Pasek darmowej dostawy --------------------------------------------- */

.sbm-ship {
    margin: 12px 0 0;
    padding: 12px 14px 14px;
    border-radius: var(--sbm-radius);
    background: var(--sbm-bg-soft);
}

.sbm-ship-text {
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.45;
}

.sbm-ship-text strong {
    font-family: var(--font-secondary-bold-family), sans-serif;
    font-weight: 700;
}

.sbm-ship.is-done .sbm-ship-text {
    color: var(--sbm-green);
    font-family: var(--font-secondary-bold-family), sans-serif;
    font-weight: 700;
}

.sbm-ship-note {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin-left: 2px;
}

.sbm-info {
    display: inline-grid;
    place-items: center;
    width: 14px;
    height: 14px;
    border: 1px solid currentColor;
    border-radius: 50%;
    font-size: 9px;
    font-style: normal;
    line-height: 1;
}

.sbm-ship-bar {
    height: 6px;
    border-radius: 3px;
    background: #ebe3de;
    overflow: hidden;
}

.sbm-ship-bar span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: var(--sbm-green);
    transition: width .4s ease;
}

/* --- 4. Propozycje ---------------------------------------------------------- */

.sbm-upsells {
    margin-top: 16px;
}

.sbm .sbm-upsells-title {
    margin: 0 0 10px;
    font-family: var(--font-secondary-bold-family), sans-serif;
    font-weight: 700;
    font-size: 14px;
    line-height: 1.3;
    letter-spacing: 0;
    text-transform: none;
}

.sbm-upsells-list {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.sbm-upsell {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px;
    border: 1px solid var(--sbm-line);
    border-radius: var(--sbm-radius);
}

.sbm-upsell-img {
    display: grid;
    place-items: center;
    height: 72px;
    border-radius: 6px;
    background: var(--sbm-bg-soft);
}

.sbm-upsell-img img {
    max-width: 100%;
    max-height: 64px;
    width: auto;
    height: auto;
    object-fit: contain;
}

.sbm-upsell-name {
    flex: 1 1 auto;
    font-size: 12px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.sbm-upsell-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
}

.sbm-upsell-price {
    font-family: var(--font-secondary-bold-family), sans-serif;
    font-weight: 700;
    font-size: 12px;
}

.sbm-upsell-price del {
    display: block;
    font-size: 11px;
}

.sbm-upsell-add {
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    width: 26px;
    height: 26px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--sbm-accent);
    color: #fff;
    font-size: 16px;
    line-height: 1;
}

.sbm-upsell-add:hover {
    background: var(--sbm-accent-dark);
}

/* --- 5. Podsumowanie i przyciski ------------------------------------------- */

.sbm-total {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin: 0 0 2px;
    font-size: 14px;
}

.sbm-total strong {
    font-family: var(--font-secondary-bold-family), sans-serif;
    font-weight: 700;
    font-size: 16px;
}

.sbm .sbm-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 46px;
    padding: 10px 16px;
    border-radius: 8px;
    font-family: var(--font-secondary-bold-family), sans-serif;
    font-weight: 700;
    font-size: 14px;
    line-height: 1.2;
    text-align: center;
    transition: background-color .15s, border-color .15s;
}

.sbm .sbm-btn-primary {
    border: 1px solid var(--sbm-accent);
    background: var(--sbm-accent);
    color: #fff;
}

.sbm .sbm-btn-primary:hover {
    background: var(--sbm-accent-dark);
    border-color: var(--sbm-accent-dark);
}

.sbm .sbm-btn-secondary {
    width: 100%;
    border: 1px solid #d9d4e0;
    background: #fff;
    color: var(--sbm-text);
}

.sbm .sbm-btn-secondary:hover {
    border-color: var(--sbm-accent);
}

.sbm button:focus-visible,
.sbm a:focus-visible {
    outline: 2px solid var(--sbm-accent);
    outline-offset: 2px;
}
