/* ==========================================================================
   SWAM Upsell Popup – Modal styles
   ========================================================================== */

/* Overlay – CSS max z-index (2^31 - 1). Also set via JS for inline-style overrides. */
#swam-upsell-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
    z-index: 2147483647;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
}

/* Force known cart drawers/panels behind the overlay when it's open.
   CheckoutWC, FunnelKit, Astra side-cart, generic patterns. */
body.swam-upsell-open .fkcart-wrapper,
body.swam-upsell-open #cfw-side-cart,
body.swam-upsell-open .cfw-side-cart,
body.swam-upsell-open [class*="cart-drawer"],
body.swam-upsell-open [class*="side-cart"],
body.swam-upsell-open [class*="mini-cart"],
body.swam-upsell-open .woo-cart-panel,
body.swam-upsell-open .cart-panel,
body.swam-upsell-open #cfw-cart-flyout,
body.swam-upsell-open .cfw-cart-flyout,
body.swam-upsell-open [id*="cart-flyout"],
body.swam-upsell-open [class*="cart-flyout"] {
    z-index: 1 !important;
}

/* Prevent body scroll when modal is open */
body.swam-upsell-open {
    overflow: hidden;
}

/* Modal container */
#swam-upsell-modal {
    position: relative;
    background: #ffffff;
    border-radius: 10px;
    width: 100%;
    max-width: 680px;
    max-height: 88vh;
    overflow-y: auto;
    padding: 36px 32px 28px;
    box-sizing: border-box;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
    animation: swamFadeUp 0.22s ease-out both;
}

@keyframes swamFadeUp {
    from { opacity: 0; transform: translateY(14px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Close button */
#swam-upsell-close {
    position: absolute;
    top: 14px;
    right: 18px;
    background: none;
    border: none;
    font-size: 26px;
    line-height: 1;
    color: #666;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.15s, background 0.15s;
}
#swam-upsell-close:hover {
    color: #111;
    background: #f0f0f0;
}

/* Heading & subtitle */
#swam-upsell-title {
    margin: 0 0 6px;
    font-size: 1.35rem;
    font-weight: 700;
    color: #111;
    line-height: 1.3;
    padding-right: 32px;
}

#swam-upsell-subtitle {
    margin: 0 0 20px;
    font-size: 0.95rem;
    color: #555;
}

/* Products list */
#swam-upsell-products {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Product card */
.swam-upsell-product {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 16px 0;
    border-bottom: 1px solid #ebebeb;
    transition: background 0.15s;
}
.swam-upsell-product:last-child {
    border-bottom: none;
}
.swam-upsell-product.swam-product-added {
    opacity: 0.75;
}

/* Product image */
.swam-upsell-img {
    flex-shrink: 0;
    width: 90px;
    height: 90px;
    border-radius: 6px;
    overflow: hidden;
    background: #f5f5f5;
}
.swam-upsell-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Product info */
.swam-upsell-info {
    flex: 1;
    min-width: 0;
}

.swam-upsell-name {
    margin: 0 0 4px;
    font-size: 0.95rem;
    font-weight: 600;
    line-height: 1.35;
}
.swam-upsell-name a {
    color: #111;
    text-decoration: none;
}
.swam-upsell-name a:hover {
    color: #007cba;
    text-decoration: underline;
}

.swam-upsell-price {
    margin-bottom: 12px;
    font-size: 1rem;
    font-weight: 700;
    color: #333;
}
.swam-upsell-price .woocommerce-Price-amount {
    color: #333;
}
.swam-upsell-price del {
    color: #999;
    font-weight: 400;
    margin-right: 4px;
}
.swam-upsell-price ins {
    text-decoration: none;
}

/* Action buttons */
.swam-upsell-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* Primary button – "Añadir al pedido" */
.swam-btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 18px;
    background: #2e7d32;
    color: #fff !important;
    border: none;
    border-radius: 5px;
    font-size: 0.87rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.18s, opacity 0.18s;
    white-space: nowrap;
}
.swam-btn-primary:hover:not(:disabled) {
    background: #1b5e20;
}
.swam-btn-primary:disabled,
.swam-btn-primary.swam-added {
    background: #4caf50;
    cursor: default;
    opacity: 0.85;
}

/* Secondary button – "Ver más" */
.swam-btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    background: transparent;
    color: #333 !important;
    border: 1.5px solid #ccc;
    border-radius: 5px;
    font-size: 0.87rem;
    font-weight: 500;
    text-decoration: none !important;
    cursor: pointer;
    transition: border-color 0.18s, color 0.18s;
    white-space: nowrap;
}
.swam-btn-secondary:hover {
    border-color: #555;
    color: #111 !important;
}

/* Footer – checkout CTA */
#swam-upsell-footer {
    padding-top: 20px;
    text-align: center;
}

.swam-btn-checkout {
    display: inline-block;
    width: 100%;
    padding: 13px 24px;
    background: #111;
    color: #fff !important;
    border-radius: 6px;
    font-size: 1rem;
    font-weight: 700;
    text-decoration: none !important;
    text-align: center;
    letter-spacing: 0.3px;
    transition: background 0.18s;
    box-sizing: border-box;
}
.swam-btn-checkout:hover {
    background: #333;
    color: #fff !important;
}

/* ==========================================================================
   Responsive – mobile
   ========================================================================== */
@media ( max-width: 520px ) {
    #swam-upsell-modal {
        padding: 28px 18px 20px;
        max-height: 92vh;
    }

    #swam-upsell-title {
        font-size: 1.15rem;
    }

    .swam-upsell-product {
        flex-direction: column;
        gap: 10px;
    }

    .swam-upsell-img {
        width: 100%;
        height: 160px;
    }

    .swam-upsell-actions {
        flex-direction: column;
    }

    .swam-btn-primary,
    .swam-btn-secondary {
        width: 100%;
        text-align: center;
        justify-content: center;
    }
}
