/**
 * Upsell Popup Styles
 *
 * Matches the Craftery theme branding:
 * - Font: Geist (body), Wayfinder CF (headings)
 * - Colors: #282828 (dark), #b9ef5c (lime green), #ef7e5c (coral)
 * - Border-radius: 12px (popup), 8px (cards), 4px (buttons)
 */

/* Overlay */
.upsell-overlay {
    position: fixed;
    inset: 0;
    background: rgba(40, 40, 40, 0.55);
    z-index: 99999;
    display: flex;
    justify-content: center;
    align-items: center;
    animation: upsellFadeIn 0.2s ease;
    padding: 16px;
}

@keyframes upsellFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Popup container — single scroll for all content between sticky header/footer */
.upsell-popup {
    background: #fff;
    width: 100%;
    max-width: 940px;
    max-height: 90vh;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    animation: upsellSlideUp 0.3s ease;
    display: flex;
    flex-direction: column;
}

/* Scrollable body between sticky header and footer */
.upsell-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Header */
.upsell-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    border-bottom: 1px solid #f0f0f0;
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 2;
    border-radius: 12px 12px 0 0;
}

.upsell-title {
    font-family: "Wayfinder CF", sans-serif;
    font-size: 22px;
    font-weight: 600;
    color: #282828;
    margin: 0;
    line-height: 1.3;
}

.upsell-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #726f75;
    line-height: 1;
    padding: 4px 8px;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
}

.upsell-close:hover {
    color: #282828;
    background: #f7ede0;
}

/* Savings banner */
.upsell-savings-banner {
    background: #b9ef5c;
    color: #282828;
    padding: 10px 24px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
}

.upsell-savings-banner strong {
    font-weight: 700;
}

/* Discount slots */
.upsell-slots {
    padding: 16px 24px;
    display: flex;
    gap: 10px;
    overflow-x: auto;
}

.upsell-slot {
    flex: 0 0 145px;
    border: 2px dashed #c3c3c3;
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    min-height: 195px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: all 0.3s ease;
    position: relative;
}

.upsell-slot.filled {
    border: 2px solid #282828;
    background: #f9f9f9;
}

.upsell-slot.next-slot {
    border-color: #b9ef5c;
    background: #f8fdf0;
    animation: upsellPulse 2s infinite;
}

@keyframes upsellPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(185, 239, 92, 0.3); }
    50% { box-shadow: 0 0 0 8px rgba(185, 239, 92, 0); }
}

.upsell-slot-img {
    width: 75px;
    height: 105px;
    object-fit: cover;
    border-radius: 4px;
    margin-bottom: 8px;
}

.upsell-slot-placeholder {
    width: 75px;
    height: 105px;
    background: #f0f0f0;
    border-radius: 4px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #c3c3c3;
}

.upsell-slot-label {
    font-size: 11px;
    color: #726f75;
    margin-bottom: 4px;
}

.upsell-slot-discount {
    font-family: "Wayfinder CF", sans-serif;
    font-size: 18px;
    font-weight: 700;
    color: #282828;
}

.upsell-slot-name {
    font-size: 10px;
    color: #282828;
    margin-top: 4px;
    max-width: 125px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upsell-slot-remove {
    position: absolute;
    top: 4px;
    right: 6px;
    background: #ef7e5c;
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 12px;
    cursor: pointer;
    line-height: 1;
    display: none;
    transition: background 0.2s;
}

.upsell-slot-remove:hover {
    background: #d65c3a;
}

.upsell-slot.filled .upsell-slot-remove {
    display: block;
}

/* Sections */
.upsell-section {
    padding: 0 24px 20px;
}

.upsell-section-title {
    font-family: "Wayfinder CF", sans-serif;
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 14px;
    padding-bottom: 8px;
    border-bottom: 1px solid #f0f0f0;
    color: #282828;
}

/* Suggestion cards */
.upsell-suggestions {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
}

.upsell-suggestion {
    flex: 0 0 135px;
    background: #fff;
    border: 1px solid #e8e8e8;
    border-radius: 8px;
    overflow: hidden;
    transition: box-shadow 0.2s, transform 0.2s;
    cursor: pointer;
}

.upsell-suggestion:hover {
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transform: translateY(-2px);
}

.upsell-suggestion.added {
    opacity: 0.45;
    pointer-events: none;
}

.upsell-suggestion-img {
    width: 100%;
    height: 165px;
    object-fit: cover;
    background: #f5f5f5;
}

.upsell-suggestion-info {
    padding: 8px 10px 10px;
}

.upsell-suggestion-name {
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 4px;
    line-height: 1.3;
    height: 32px;
    overflow: hidden;
    color: #282828;
}

.upsell-suggestion-price {
    font-size: 14px;
    font-weight: 700;
    color: #282828;
    margin-bottom: 8px;
}

.upsell-suggestion-btn {
    display: block;
    width: 100%;
    background: #282828;
    color: #fff;
    border: none;
    padding: 7px 8px;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    text-align: center;
    transition: background 0.2s;
    font-family: "Geist", sans-serif;
}

.upsell-suggestion-btn:hover {
    background: #3a3a3a;
}

.upsell-suggestion.added .upsell-suggestion-btn {
    background: #c3c3c3;
    cursor: default;
}

/* Bundle cards */
.upsell-bundles {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: 10px;
}

.upsell-bundle-card {
    background: #f8fdf0;
    border: 1px solid #d4eaa0;
    border-radius: 8px;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    transition: box-shadow 0.2s;
}

.upsell-bundle-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.upsell-bundle-info h5 {
    font-size: 14px;
    font-weight: 700;
    margin: 0 0 4px;
    color: #282828;
}

.upsell-bundle-meta {
    font-size: 12px;
    color: #726f75;
}

.upsell-bundle-meta .original {
    text-decoration: line-through;
    color: #c3c3c3;
}

.upsell-bundle-meta .sale {
    color: #282828;
    font-weight: 700;
    font-size: 15px;
}

.upsell-bundle-badge {
    background: #b9ef5c;
    color: #282828;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    white-space: nowrap;
}

.upsell-bundle-link {
    display: inline-block;
    margin-top: 6px;
    color: #282828;
    font-weight: 600;
    font-size: 12px;
    text-decoration: underline;
}

.upsell-bundle-link:hover {
    color: #ef7e5c;
}

/* Footer */
.upsell-footer {
    padding: 10px 24px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #fff;
    z-index: 2;
    border-radius: 0 0 12px 12px;
    flex-wrap: wrap;
    gap: 8px;
    flex-shrink: 0;
}

.upsell-total {
    font-size: 14px;
    color: #726f75;
}

.upsell-total-price {
    font-weight: 700;
    color: #282828;
    font-size: 16px;
}

.upsell-saved {
    color: #282828;
}

.upsell-saved strong {
    color: #282828;
    background: #b9ef5c;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 13px;
}

.upsell-footer-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.upsell-dismiss-label {
    font-size: 12px;
    color: #726f75;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 4px;
}

.upsell-dismiss-label input {
    margin: 0;
}

.upsell-cart-btn {
    white-space: nowrap;
}

/* Responsive */
@media (max-width: 768px) {
    .upsell-popup {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 12px 12px 0 0;
        margin-top: auto;
    }

    .upsell-overlay {
        align-items: flex-end;
        padding: 0;
    }

    .upsell-header {
        border-radius: 12px 12px 0 0;
        padding: 8px 16px;
    }

    .upsell-title {
        font-size: 15px;
    }

    .upsell-savings-banner {
        padding: 6px 16px;
        font-size: 13px;
    }

    .upsell-slots {
        padding: 8px 12px;
        gap: 6px;
    }

    .upsell-slot {
        flex: 0 0 90px;
        min-height: 125px;
        padding: 6px;
    }

    .upsell-slot-img, .upsell-slot-placeholder {
        width: 48px;
        height: 68px;
        margin-bottom: 4px;
    }

    .upsell-slot-name {
        font-size: 9px;
    }

    .upsell-slot-discount {
        font-size: 13px;
    }

    .upsell-slot-placeholder {
        font-size: 22px;
    }

    .upsell-slot-discount {
        font-size: 14px;
    }

    .upsell-slot-label {
        font-size: 10px;
    }

    .upsell-section {
        padding: 0 16px 14px;
    }

    .upsell-section-title {
        font-size: 14px;
        margin-bottom: 10px;
    }

    .upsell-suggestion {
        flex: 0 0 115px;
    }

    .upsell-suggestion-img {
        height: 140px;
    }

    .upsell-bundles {
        grid-template-columns: 1fr;
    }

    .upsell-footer {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        padding: 8px 16px;
        border-radius: 0;
    }

    .upsell-footer-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .upsell-cart-btn {
        width: 100%;
        text-align: center;
    }
}
