/* Carrito flotante: botón abajo a la derecha y panel con el carrito.
   Usa los tokens del tema, así que toma el color de marca y el modo oscuro. */

body.theme-store .st-fcart[hidden] {
    display: none;
}

body.theme-store .st-fcart__toggle {
    position: fixed;
    right: max(18px, env(safe-area-inset-right));
    bottom: max(18px, env(safe-area-inset-bottom));
    z-index: 85;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 62px;
    height: 62px;
    padding: 0;
    border: 0;
    border-radius: 18px;
    background: var(--st-accent-bg);
    color: var(--st-accent-fg);
    box-shadow: 0 14px 30px rgba(var(--st-accent-rgb), 0.32), 0 4px 10px rgba(15, 23, 42, 0.12);
    cursor: pointer;
    transition: transform 0.18s ease, box-shadow 0.18s ease;
}

body.theme-store .st-fcart__toggle:hover {
    transform: translateY(-2px);
    box-shadow: 0 18px 36px rgba(var(--st-accent-rgb), 0.38), 0 6px 14px rgba(15, 23, 42, 0.14);
}

body.theme-store .st-fcart__toggle:focus-visible {
    outline: 3px solid rgba(var(--st-accent-rgb), 0.35);
    outline-offset: 3px;
}

body.theme-store .st-fcart__toggle > i {
    font-size: 26px;
    line-height: 1;
}

body.theme-store .st-fcart__badge {
    position: absolute;
    top: -7px;
    right: -7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 25px;
    height: 25px;
    padding: 0 6px;
    border: 2px solid var(--st-bg);
    border-radius: 999px;
    background: var(--st-fg);
    color: var(--st-bg);
    font-size: 12px;
    font-weight: 800;
    line-height: 1;
}

body.theme-store .st-fcart__toggle.is-bumping {
    animation: st-fcart-bump 0.5s ease;
}

@keyframes st-fcart-bump {
    0% { transform: scale(1); }
    30% { transform: scale(1.14) rotate(-6deg); }
    60% { transform: scale(0.96) rotate(3deg); }
    100% { transform: scale(1); }
}

/* Panel ---------------------------------------------------------- */
body.theme-store .st-fcart__panel {
    position: fixed;
    right: max(18px, env(safe-area-inset-right));
    bottom: calc(max(18px, env(safe-area-inset-bottom)) + 76px);
    z-index: 86;
    display: flex;
    flex-direction: column;
    width: min(400px, calc(100vw - 36px));
    height: min(600px, calc(100dvh - 130px));
    overflow: hidden;
    border: 1px solid var(--st-border);
    border-radius: 20px;
    background: var(--st-surface);
    color: var(--st-fg);
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
    transform-origin: bottom right;
    animation: st-fcart-in 0.2s ease;
}

body.theme-store .st-fcart__panel[hidden] {
    display: none;
}

@keyframes st-fcart-in {
    from { opacity: 0; transform: translateY(10px) scale(0.97); }
    to { opacity: 1; transform: none; }
}

body.theme-store .st-fcart__backdrop {
    position: fixed;
    inset: 0;
    z-index: 84;
    background: rgba(15, 23, 42, 0.18);
}

body.theme-store .st-fcart__backdrop[hidden] {
    display: none;
}

body.theme-store .st-fcart__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 18px 14px;
    border-bottom: 1px solid var(--st-border);
}

body.theme-store .st-fcart__title {
    display: flex;
    align-items: baseline;
    gap: 8px;
    min-width: 0;
}

body.theme-store .st-fcart__title h2 {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: -0.01em;
}

body.theme-store .st-fcart__title span {
    color: var(--st-fg-muted);
    font-size: 13px;
}

body.theme-store .st-fcart__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: var(--st-bg-alt);
    color: var(--st-fg);
    cursor: pointer;
}

body.theme-store .st-fcart__close:hover {
    background: var(--st-border);
}

body.theme-store .st-fcart__body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 6px 18px;
}

body.theme-store .st-fcart__loading {
    display: grid;
    gap: 12px;
    padding: 12px 0;
}

body.theme-store .st-fcart__loading span {
    display: block;
    height: 64px;
    border-radius: 12px;
    background: linear-gradient(90deg, var(--st-bg-alt), var(--st-border), var(--st-bg-alt));
    background-size: 200% 100%;
    animation: st-fcart-shimmer 1.2s linear infinite;
}

@keyframes st-fcart-shimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

/* Líneas --------------------------------------------------------- */
body.theme-store .st-fcart__item {
    display: grid;
    grid-template-columns: 64px minmax(0, 1fr) auto;
    gap: 12px;
    padding: 14px 0;
    border-bottom: 1px solid var(--st-border);
    transition: opacity 0.15s ease;
}

body.theme-store .st-fcart__item:last-child {
    border-bottom: 0;
}

body.theme-store .st-fcart__item.is-busy {
    opacity: 0.5;
    pointer-events: none;
}

body.theme-store .st-fcart__img {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    overflow: hidden;
    border: 1px solid var(--st-border);
    border-radius: 12px;
    background: var(--st-bg-alt);
    color: var(--st-fg-soft);
}

body.theme-store .st-fcart__img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

body.theme-store .st-fcart__info {
    display: grid;
    align-content: start;
    gap: 3px;
    min-width: 0;
}

body.theme-store .st-fcart__name {
    overflow: hidden;
    color: var(--st-fg);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.3;
    text-decoration: none;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

body.theme-store .st-fcart__name:hover {
    text-decoration: underline;
}

body.theme-store .st-fcart__meta {
    color: var(--st-fg-muted);
    font-size: 12.5px;
    line-height: 1.35;
    overflow-wrap: anywhere;
}

body.theme-store .st-fcart__meta.is-backorder {
    color: var(--st-backorder);
}

body.theme-store .st-fcart__controls {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

body.theme-store .st-fcart__stepper {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--st-border-strong);
    border-radius: 999px;
    background: var(--st-field-bg);
}

body.theme-store .st-fcart__stepper button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: var(--st-fg);
    font-size: 16px;
    cursor: pointer;
}

body.theme-store .st-fcart__stepper button:hover:not(:disabled) {
    background: var(--st-bg-alt);
}

body.theme-store .st-fcart__stepper button:disabled {
    opacity: 0.35;
    cursor: default;
}

body.theme-store .st-fcart__qty {
    min-width: 26px;
    font-size: 14px;
    font-weight: 700;
    text-align: center;
}

body.theme-store .st-fcart__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: 0;
    border-radius: 10px;
    background: transparent;
    color: var(--st-fg-muted);
    font-size: 15px;
    cursor: pointer;
}

body.theme-store .st-fcart__remove:hover {
    background: rgba(220, 38, 38, 0.1);
    color: var(--st-sale);
}

body.theme-store .st-fcart__price {
    display: grid;
    justify-items: end;
    align-content: start;
    gap: 2px;
    white-space: nowrap;
}

body.theme-store .st-fcart__price strong {
    font-size: 14px;
    font-weight: 800;
}

body.theme-store .st-fcart__price s,
body.theme-store .st-fcart__price small {
    color: var(--st-fg-muted);
    font-size: 12px;
}

body.theme-store .st-fcart__gift-tag {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    color: var(--st-success);
    font-size: 12.5px;
    font-weight: 700;
}

body.theme-store .st-fcart__empty {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 40px 0;
    color: var(--st-fg-muted);
    text-align: center;
}

body.theme-store .st-fcart__empty i {
    font-size: 30px;
}

body.theme-store .st-fcart__error {
    margin: 0 18px 10px;
    padding: 10px 12px;
    border-radius: 10px;
    background: rgba(220, 38, 38, 0.1);
    color: var(--st-danger);
    font-size: 13px;
}

body.theme-store .st-fcart__error[hidden] {
    display: none;
}

body.theme-store .st-fcart__error button {
    margin-left: 6px;
    padding: 0;
    border: 0;
    background: none;
    color: inherit;
    font: inherit;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}

/* Pie: totales y botón de compra --------------------------------- */
body.theme-store .st-fcart__foot {
    display: grid;
    gap: 8px;
    padding: 14px 18px calc(16px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--st-border);
    background: var(--st-bg-soft);
}

body.theme-store .st-fcart__foot[hidden] {
    display: none;
}

body.theme-store .st-fcart__row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    color: var(--st-fg-muted);
    font-size: 13.5px;
}

body.theme-store .st-fcart__row--total {
    color: var(--st-fg);
    font-size: 16px;
}

body.theme-store .st-fcart__row--total strong {
    font-size: 19px;
    font-weight: 800;
}

body.theme-store .st-fcart__notice,
body.theme-store .st-fcart__minimum {
    margin: 0;
    color: var(--st-fg-muted);
    font-size: 12.5px;
}

body.theme-store .st-fcart__minimum {
    color: var(--st-danger);
}

body.theme-store .st-fcart__notice[hidden],
body.theme-store .st-fcart__minimum[hidden],
body.theme-store .st-fcart__row[hidden] {
    display: none;
}

body.theme-store .st-fcart__checkout {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    min-height: 50px;
    padding: 0 18px;
    border-radius: 14px;
    background: var(--st-accent-bg);
    color: var(--st-accent-fg);
    font-size: 15px;
    font-weight: 800;
    text-decoration: none;
    transition: filter 0.15s ease, transform 0.15s ease;
}

body.theme-store .st-fcart__checkout:hover {
    color: var(--st-accent-fg);
    text-decoration: none;
    filter: brightness(0.95);
    transform: translateY(-1px);
}

body.theme-store .st-fcart__checkout.is-disabled {
    opacity: 0.45;
    pointer-events: none;
}

body.theme-store .st-fcart__checkout [hidden] {
    display: none;
}

body.theme-store .st-fcart__view {
    color: var(--st-fg-muted);
    font-size: 13px;
    text-align: center;
    text-decoration: underline;
}

/* Convivencia con el resto de la tienda -------------------------- */
body.theme-store.st-drawer-open .st-fcart {
    display: none;
}

@media (min-width: 641px) {
    body.theme-store .st-fcart__backdrop {
        background: transparent;
    }
}

@media (max-width: 880px) {
    body.theme-store:has(.st-product-mobile-cta) .st-fcart__toggle {
        bottom: calc(84px + env(safe-area-inset-bottom));
    }
}

@media (max-width: 640px) {
    body.theme-store .st-fcart__toggle {
        right: max(14px, env(safe-area-inset-right));
        bottom: max(14px, env(safe-area-inset-bottom));
        width: 56px;
        height: 56px;
        border-radius: 16px;
    }

    body.theme-store .st-fcart__toggle > i {
        font-size: 23px;
    }

    body.theme-store .st-fcart__panel {
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        height: min(82dvh, 640px);
        border-right: 0;
        border-bottom: 0;
        border-left: 0;
        border-radius: 22px 22px 0 0;
        transform-origin: bottom center;
        animation-name: st-fcart-sheet-in;
    }

    body.theme-store .st-fcart.is-open .st-fcart__toggle {
        display: none;
    }
}

@keyframes st-fcart-sheet-in {
    from { transform: translateY(100%); }
    to { transform: none; }
}

@media (prefers-reduced-motion: reduce) {
    body.theme-store .st-fcart__toggle,
    body.theme-store .st-fcart__panel,
    body.theme-store .st-fcart__toggle.is-bumping {
        animation: none;
        transition: none;
    }
}
