/**
 * Frontend Styles for Upsells (1-Tick and 1-Click)
 * Minimalist, Compact Design Matching COD Form Elements
 *
 * @package COD_Form_WC_DC
 */

.cod-upsell-is-hidden {
    display: none !important;
}

/* ==========================================================================
   1. ONE-TICK IN-FORM UPSELL (CAROUSEL & CHECKBOX)
   ========================================================================== */

.cod-upsell-one-tick {
    background-color: var(--upsell-bg, #f8fafc);
    border: 1.5px var(--upsell-border-style, solid) var(--upsell-border, #cbd5e1);
    border-radius: var(--upsell-radius, 8px);
    padding: 10px;
    margin: 10px 0 12px 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    overflow: hidden;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease, background-color 0.2s ease;
    position: relative;
}

.cod-upsell-one-tick.is-border-dashed {
    border-style: dashed;
}

.cod-upsell-one-tick.is-border-solid {
    border-style: solid;
}

.cod-upsell-one-tick:has(.cod-upsell-slide-checkbox:checked),
.cod-upsell-one-tick:has(#cod_upsell_one_tick_active:checked),
.cod-upsell-one-tick.is-checked {
    border-color: var(--upsell-border, #0073aa);
    box-shadow: 0 0 0 1px var(--upsell-border, #0073aa), 0 2px 6px rgba(0, 0, 0, 0.05);
}

/* Header & Custom Checkbox */
.cod-upsell-header {
    display: flex;
    align-items: center;
    margin-bottom: 7px;
}

.cod-upsell-header-clickable {
    cursor: pointer;
    user-select: none;
}

.cod-upsell-one-tick.is-minimal .cod-upsell-header {
    margin-bottom: 0;
}

.cod-upsell-minimal-headline {
    margin-bottom: 5px;
    padding-bottom: 4px;
    border-bottom: 1px dashed rgba(148, 163, 184, 0.35);
    line-height: 1.2;
}

.cod-upsell-minimal-headline .cod-upsell-title {
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    color: var(--upsell-highlight, #d63638);
}

#codFormModal .cod-upsell-checkbox-label,
.cod-upsell-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    width: 100%;
    user-select: none;
    margin: 0 !important;
    margin-bottom: 0px !important;
    padding: 0 !important;
}

#codFormModal .cod-upsell-checkbox-label.cod-upsell-slide-checkbox-label,
.cod-upsell-checkbox-label.cod-upsell-slide-checkbox-label {
    width: auto !important;
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cod-upsell-checkbox-label input[type="checkbox"] {
    display: none !important;
}

.cod-upsell-checkbox-custom {
    width: 18px;
    height: 18px;
    min-width: 18px;
    border: 1.5px solid var(--upsell-border, #0073aa);
    border-radius: 4px;
    background: #ffffff;
    position: relative;
    transition: all 0.15s ease;
    box-sizing: border-box;
    flex-shrink: 0;
}

.cod-upsell-checkbox-label input[type="checkbox"]:checked+.cod-upsell-checkbox-custom {
    background-color: var(--upsell-border, #0073aa);
}

.cod-upsell-checkbox-label input[type="checkbox"]:checked+.cod-upsell-checkbox-custom::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 4px;
    height: 9px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.cod-upsell-header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
    min-width: 0;
}

.cod-upsell-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    flex-wrap: wrap;
}

.cod-upsell-title {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.25;
    overflow-wrap: break-word;
    word-break: break-word;
}

.cod-upsell-checkbox-cta,
.cod-upsell-minimal-badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--upsell-border, #0073aa);
    background: rgba(255, 255, 255, 0.85);
    border: 1px solid rgba(0, 0, 0, 0.08);
    padding: 1px 6px;
    border-radius: 4px;
    line-height: 1.3;
    max-width: 100%;
    box-sizing: border-box;
}

.cod-upsell-checkbox-cta {
    white-space: normal;
    overflow-wrap: break-word;
    word-break: break-word;
}

.cod-upsell-minimal-badge {
    white-space: nowrap;
}

.cod-upsell-one-tick.is-minimal .cod-upsell-checkbox-cta {
    align-self: flex-start;
    font-size: 10px;
    padding: 1px 6px;
    line-height: 1.25;
    margin-bottom: 1px;
}

.cod-upsell-minimal-badge {
    color: var(--upsell-highlight, #d63638);
    font-size: 9.5px;
    padding: 1px 5px;
    line-height: 1.2;
    margin-top: 1px;
}

/* Minimalist Compact Image, Pills & Vertical Prices */
.cod-upsell-minimal-img-wrap {
    width: 36px;
    height: 36px;
    min-width: 36px;
    border-radius: 5px;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cod-upsell-minimal-img {
    width: 100%;
    height: 100%;
    object-fit: cover !important;
    display: block;
}

.cod-upsell-minimal-pills {
    display: inline-flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
}

.cod-upsell-minimal-prices.cod-upsell-prices {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    justify-content: center;
    gap: 1px;
    line-height: 1.15;
    flex-shrink: 0;
    margin-left: 4px;
}

.cod-upsell-minimal-slides {
    margin-top: 0 !important;
}

.cod-upsell-minimal-variations {
    margin-top: 6px !important;
    padding-left: 26px;
}

.cod-upsell-subtitle {
    font-size: 11.5px;
    color: #64748b;
    line-height: 1.25;
    overflow-wrap: break-word;
    word-break: break-word;
}

/* Carousel Track & Viewport */
.cod-upsell-carousel {
    position: relative;
    margin-top: 4px;
    padding: 0;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    box-sizing: border-box;
}

.cod-upsell-track-viewport {
    overflow: hidden;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    border-radius: 6px;
    box-sizing: border-box;
}

.cod-upsell-track {
    display: flex;
    width: 100%;
    transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    will-change: transform;
}

.cod-upsell-slide {
    flex: 0 0 100%;
    min-width: 100%;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    padding: 0;
}

.cod-upsell-slide-inner {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    padding: 7px 9px;
    min-width: 0;
    box-sizing: border-box;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.cod-upsell-slide.is-slide-checked .cod-upsell-slide-inner,
.cod-upsell-slide-inner:has(.cod-upsell-slide-checkbox:checked) {
    border-color: var(--upsell-border, #0073aa);
    background: #f8fafc;
}

.cod-upsell-carousel:not([data-count="1"]) .cod-upsell-slide-inner {
    margin: 0px 16px;
}

.cod-upsell-img-wrap {
    position: relative;
    width: 46px;
    height: 46px;
    min-width: 46px;
    border-radius: 5px;
    overflow: hidden;
    background: #f1f5f9;
    border: 1px solid #f1f5f9;
    flex-shrink: 0;
}

.cod-upsell-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cod-upsell-highlight-badge {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: var(--upsell-highlight, #d63638);
    color: #ffffff;
    font-size: 8.5px;
    font-weight: 700;
    text-align: center;
    padding: 1px 2px;
    text-transform: uppercase;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cod-upsell-details {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.cod-upsell-top-line {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
    flex-wrap: wrap;
}

.cod-upsell-prod-name {
    font-size: 13px;
    font-weight: 600;
    color: #1e293b;
    line-height: 1.25;
    flex: 1;
    min-width: 0;
    overflow-wrap: break-word;
    word-break: break-word;
}

.cod-upsell-prices {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 13px;
    white-space: nowrap;
    flex-shrink: 0;
}

.cod-upsell-old-price {
    text-decoration: line-through;
    color: #94a3b8;
    font-size: 11.5px;
}

.cod-upsell-disc-price {
    font-weight: 700;
    color: var(--upsell-highlight, #d63638);
    font-size: 13px;
}

.cod-upsell-variations-wrap {
    margin-top: 1px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

/* Override generic #codFormModal .cod-modal-content select rules */
#codFormModal .cod-modal-content select.cod-upsell-variation-select,
.cod-upsell-variation-select {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    height: 28px !important;
    min-height: 28px !important;
    padding: 2px 22px 2px 8px !important;
    margin: 0 !important;
    font-size: 12px !important;
    line-height: 1.2 !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 5px !important;
    background-color: #f8fafc !important;
    background-image: none;
    color: #1e293b !important;
    box-shadow: none !important;
    text-overflow: ellipsis;
}

#codFormModal .cod-modal-content select.cod-upsell-variation-select:focus,
.cod-upsell-variation-select:focus {
    border-color: var(--upsell-border, #0073aa) !important;
    background-color: #ffffff !important;
    outline: none !important;
}

/* Carousel Navigation Arrows */
.cod-upsell-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 15px;
    line-height: 1;
    color: #334155;
    z-index: 2;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    transition: all 0.15s ease;
    padding: 0;
}

.cod-upsell-arrow:hover {
    background: #f8fafc;
    color: #0f172a;
    border-color: #94a3b8;
}

.cod-upsell-prev {
    left: -4px;
}

.cod-upsell-next {
    right: -4px;
}

/* Carousel Minimalist Dots */
.cod-upsell-dots {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 5px;
    margin-top: 6px;
}

.cod-upsell-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #cbd5e1;
    cursor: pointer;
    transition: all 0.2s ease;
}

.cod-upsell-dot.active {
    width: 14px;
    border-radius: 3px;
    background: var(--upsell-border, #0073aa);
}

.cod-upsell-dot.is-checked-dot {
    background: var(--upsell-highlight, #d63638);
}


/* ==========================================================================
   2. ONE-CLICK POST-PURCHASE POPUP (#codUpsellModal)
   ========================================================================== */

#codUpsellModal.cod-upsell-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.72);
    z-index: 10000005;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 14px;
    box-sizing: border-box;
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
    animation: codUpsellFadeIn 0.2s ease-out forwards;
    overflow-y: auto;
}

@keyframes codUpsellFadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.cod-upsell-modal-content {
    background: #ffffff;
    border-radius: 12px;
    max-width: 400px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 18px 16px;
    box-sizing: border-box;
    position: relative;
    box-shadow: 0 20px 40px -12px rgba(0, 0, 0, 0.3);
    text-align: center;
    animation: codUpsellSlideUp 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes codUpsellSlideUp {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.cod-upsell-close {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 20px;
    font-weight: 400;
    line-height: 1;
    color: #94a3b8;
    cursor: pointer;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.15s ease;
}

.cod-upsell-close:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.cod-upsell-banner-title {
    margin-bottom: 12px;
    padding: 0 16px;
}

.cod-upsell-headline {
    font-size: 16.5px;
    font-weight: 600;
    color: #0f172a;
    line-height: 1.25;
    margin: 0 0 4px 0;
}

.cod-upsell-subheadline {
    font-size: 13px;
    color: #475569;
    line-height: 1.35;
    margin: 0;
}

/* Card Body in Popup */
.cod-upsell-card {
    margin-bottom: 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.cod-upsell-card-media {
    position: relative;
    width: 76px;
    border-radius: 8px;
    overflow: hidden;
    margin-bottom: 8px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    flex-shrink: 0;
}

.cod-upsell-card-media img,
.cod-upsell-main-img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    display: block !important;
}

.cod-upsell-badge {
    position: absolute;
    top: 6px;
    right: 6px;
    background-color: var(--upsell-badge-bg, #e53e3e);
    color: var(--upsell-badge-color, #ffffff);
    font-size: 10px;
    font-weight: 600;
    padding: 3px 7px;
    border-radius: 12px;
    letter-spacing: 0.3px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.cod-upsell-card-body {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.cod-upsell-card-name {
    font-size: 14.5px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 4px 0;
    line-height: 1.3;
}

.cod-upsell-card-price {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-bottom: 6px;
}

.cod-upsell-card-price .cod-upsell-old-price {
    font-size: 13.5px;
    color: #94a3b8;
    text-decoration: line-through;
}

.cod-upsell-card-price .cod-upsell-new-price {
    font-size: 17px;
    font-weight: 600;
    color: #e53e3e;
}

.cod-upsell-one-click-variations {
    width: 100%;
    margin-top: 6px;
    text-align: left;
}

.cod-upsell-one-click-variations label {
    font-size: 11.5px;
    font-weight: 600;
    color: #475569;
    margin-bottom: 3px;
    display: block;
}

.cod-upsell-one-click-variations select {
    width: 100%;
    height: 32px;
    padding: 4px 8px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 12.5px;
    background: #ffffff;
    color: #0f172a;
}

/* Quantity Controls */
.cod-upsell-qty-wrap {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
}

.cod-upsell-qty-wrap label {
    font-size: 12px;
    font-weight: 600;
    color: #475569;
    margin: 0;
}

.cod-upsell-qty-control {
    display: flex;
    align-items: center;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    overflow: hidden;
    background: #ffffff;
}

.cod-upsell-qty-btn {
    width: 28px;
    height: 28px;
    border: none;
    background: #f1f5f9;
    color: #334155;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.cod-upsell-qty-btn:hover {
    background: #e2e8f0;
}

.cod-upsell-qty-input {
    width: 36px;
    height: 28px;
    text-align: center;
    border: none;
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    padding: 0;
    margin: 0;
    -moz-appearance: textfield;
}

.cod-upsell-qty-input::-webkit-outer-spin-button,
.cod-upsell-qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Action Buttons */
.cod-upsell-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

.cod-upsell-btn-accept {
    width: 100%;
    padding: 11px 16px;
    font-size: 14px;
    font-weight: 600;
    background-color: var(--upsell-btn-yes-bg, #38a169);
    color: var(--upsell-btn-yes-color, #ffffff);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    text-transform: uppercase;
    letter-spacing: 0.4px;
}

.cod-upsell-btn-accept:hover {
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(0, 0, 0, 0.18);
}

.cod-upsell-btn-accept.pulse {
    animation: codUpsellPulse 2s infinite;
}

.cod-upsell-btn-accept.bounce {
    animation: codUpsellBounce 2.2s infinite;
}

.cod-upsell-btn-accept.shake {
    animation: codUpsellShake 2.5s infinite;
}

@keyframes codUpsellPulse {

    0%,
    100% {
        transform: scale(1);
    }

    50% {
        transform: scale(1.025);
    }
}

@keyframes codUpsellBounce {

    0%,
    20%,
    50%,
    80%,
    100% {
        transform: translateY(0);
    }

    40% {
        transform: translateY(-4px);
    }

    60% {
        transform: translateY(-2px);
    }
}

@keyframes codUpsellShake {

    0%,
    90%,
    100% {
        transform: translateX(0);
    }

    92%,
    96% {
        transform: translateX(-3px);
    }

    94%,
    98% {
        transform: translateX(3px);
    }
}

.cod-upsell-btn-decline {
    background: none;
    border: none;
    color: var(--upsell-btn-no-color, #718096);
    font-size: 12.5px;
    font-weight: 500;
    cursor: pointer;
    text-decoration: underline;
    padding: 2px 4px;
    opacity: 0.85;
    transition: opacity 0.15s ease;
}

.cod-upsell-btn-decline:hover {
    opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .cod-upsell-one-tick {
        padding: 8px 9px;
        margin: 8px 0 10px 0;
    }

    #codFormModal .cod-upsell-checkbox-label,
    .cod-upsell-checkbox-label {
        gap: 6px;
    }

    .cod-upsell-minimal-img-wrap {
        width: 32px;
        height: 32px;
        min-width: 32px;
    }

    .cod-upsell-minimal-variations {
        padding-left: 0;
    }

    .cod-upsell-slide-inner {
        gap: 8px;
        padding: 6px 8px;
    }

    .cod-upsell-carousel:not([data-count="1"]) .cod-upsell-slide-inner {
        margin: 0 14px;
    }

    .cod-upsell-img-wrap {
        width: 40px;
        height: 40px;
        min-width: 40px;
    }

    .cod-upsell-title,
    .cod-upsell-prod-name {
        font-size: 12px;
    }

    .cod-upsell-subtitle {
        font-size: 11px;
    }

    .cod-upsell-prices,
    .cod-upsell-disc-price {
        font-size: 12px;
    }

    .cod-upsell-old-price {
        font-size: 10.5px;
    }

    .cod-upsell-modal-content {
        padding: 16px 14px;
    }

    .cod-upsell-headline {
        font-size: 15.5px;
    }

    .cod-upsell-card-media {
        width: 68px;
        height: 68px;
    }
}