/**
 * Checkout Modal Styles
 * Multi-step checkout flow with cart header and OTO pages
 * Version: 1.1.0 - Compacted modal for better mobile UX
 */

/* ==========================================================================
   MODAL OVERLAY
   ========================================================================== */

.checkout-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.checkout-modal.active {
    display: flex;
}

.checkout-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

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

/* ==========================================================================
   MODAL CONTAINER
   ========================================================================== */

.checkout-modal-container {
    position: relative;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ==========================================================================
   CART HEADER
   ========================================================================== */

.checkout-cart-header {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    padding: 16px 20px;
    padding-left: 56px; /* Space for back button */
    padding-right: 50px; /* Space for close button */
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 64px;
}

.checkout-cart-info {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0; /* Allow flex child to shrink */
    flex: 1;
}

.checkout-cart-icon {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.checkout-cart-icon svg {
    width: 22px;
    height: 22px;
}

.checkout-cart-details {
    display: flex;
    flex-direction: column;
    min-width: 0; /* Allow text truncation */
}

.checkout-cart-label {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    opacity: 0.85;
    margin-bottom: 2px;
}

.checkout-cart-product {
    font-weight: 700;
    font-size: 16px;
    line-height: 1.3;
    transition: all 0.3s ease;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.checkout-cart-price {
    display: flex;
    align-items: baseline;
    gap: 4px;
    white-space: nowrap;
    flex-shrink: 0;
}

.checkout-cart-amount {
    font-size: 24px;
    font-weight: 700;
}

.checkout-cart-period {
    font-size: 13px;
    opacity: 0.85;
}

/* ==========================================================================
   BACK BUTTON
   ========================================================================== */

.checkout-back-btn {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
    opacity: 0;
    pointer-events: none;
}

.checkout-back-btn.visible {
    opacity: 1;
    pointer-events: auto;
}

.checkout-back-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateX(-2px);
}

.checkout-back-btn svg {
    width: 20px;
    height: 20px;
}


/* ==========================================================================
   MODAL CONTENT AREA
   ========================================================================== */

.checkout-modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

/* ==========================================================================
   STEP CONTAINERS
   ========================================================================== */

.checkout-step {
    display: none;
    animation: stepFadeIn 0.3s ease-out;
}

.checkout-step.active {
    display: block;
}

@keyframes stepFadeIn {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ==========================================================================
   STEP 1: INFO CAPTURE
   ========================================================================== */

.checkout-info-header {
    text-align: center;
    margin-bottom: 16px;
}

.checkout-info-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}

.checkout-info-icon svg {
    width: 24px;
    height: 24px;
    color: #fff;
}

.checkout-info-title {
    font-size: 20px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 4px;
}

.checkout-info-subtitle {
    font-size: 14px;
    color: #64748b;
    margin: 0;
}

/* Product Preview Card */
.checkout-product-preview {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 12px 14px;
    margin-bottom: 14px;
}

.checkout-preview-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 8px;
}

.checkout-preview-name {
    font-size: 15px;
    font-weight: 600;
    color: #1e293b;
}

.checkout-preview-price {
    font-size: 16px;
    font-weight: 700;
    color: #667eea;
}

.checkout-preview-features {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.checkout-preview-feature {
    font-size: 12px;
    color: #64748b;
    background: #fff;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
}

/* Info Form */
.checkout-info-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.checkout-form-input {
    width: 100%;
    padding: 12px 14px;
    font-size: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    background: #fff;
    transition: all 0.2s ease;
    outline: none;
}

.checkout-form-input:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

.checkout-form-input::placeholder {
    color: #94a3b8;
}

.checkout-form-input.error {
    border-color: #ef4444;
    background: #fef2f2;
}

/* Consent Group */
.checkout-consent-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkout-consent {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.checkout-consent:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

.checkout-consent:has(input:checked) {
    background: #f0fdf4;
    border-color: #86efac;
}

.checkout-consent.error {
    background: #fef2f2;
    border-color: #f87171;
    animation: shake 0.4s ease;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

.checkout-consent input {
    width: 18px;
    height: 18px;
    margin-top: 2px;
    accent-color: #10b981;
    cursor: pointer;
    flex-shrink: 0;
}

.checkout-consent-text {
    font-size: 12px;
    color: #475569;
    line-height: 1.4;
}

.checkout-consent-text strong {
    color: #1e293b;
}

.checkout-consent:has(input:checked) .checkout-consent-text strong {
    color: #059669;
}

.checkout-consent-optional {
    color: #94a3b8;
    font-size: 12px;
}

/* Marketing consent has slightly different styling */
.checkout-consent-marketing {
    background: #fffbeb;
    border-color: #fde68a;
}

.checkout-consent-marketing:hover {
    background: #fef3c7;
    border-color: #fcd34d;
}

.checkout-consent-marketing:has(input:checked) {
    background: #fef3c7;
    border-color: #f59e0b;
}

.checkout-consent-marketing .checkout-consent-text strong {
    color: #b45309;
}

/* Primary CTA Button */
.checkout-btn-primary {
    width: 100%;
    padding: 14px 20px;
    font-size: 16px;
    font-weight: 600;
    color: #fff;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 6px;
}

.checkout-btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.4);
}

.checkout-btn-primary:active {
    transform: translateY(0);
}

.checkout-btn-primary:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.checkout-btn-primary svg {
    width: 20px;
    height: 20px;
}

/* ==========================================================================
   STEP 2+: OTO PAGES
   ========================================================================== */

.checkout-oto-header {
    text-align: center;
    margin-bottom: 16px;
}

/* Savings Badge - Big and Bold */
.checkout-oto-savings-badge {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 20px;
    background: linear-gradient(135deg, #059669 0%, #10b981 100%);
    color: #fff;
    border-radius: 10px;
    margin-bottom: 12px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.checkout-oto-savings-amount {
    font-size: 20px;
    font-weight: 800;
    letter-spacing: 0.5px;
}

.checkout-oto-savings-detail {
    font-size: 11px;
    font-weight: 500;
    opacity: 0.9;
    margin-top: 2px;
}

/* Urgency Text */
.checkout-oto-urgency {
    display: inline-block;
    padding: 6px 14px;
    background: #fef2f2;
    color: #dc2626;
    font-size: 12px;
    font-weight: 600;
    border-radius: 20px;
    margin: 0 0 12px;
    border: 1px solid #fecaca;
}

.checkout-oto-title {
    font-size: 22px;
    font-weight: 800;
    color: #1e293b;
    margin: 0 0 6px;
    line-height: 1.2;
}

.checkout-oto-subtitle {
    font-size: 14px;
    color: #475569;
    margin: 0;
    line-height: 1.5;
}

/* OTO Offer Card */
.checkout-oto-card {
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border: 2px solid #667eea;
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 16px;
    position: relative;
    overflow: hidden;
}

.checkout-oto-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, #667eea, #764ba2);
}

.checkout-oto-offer-name {
    font-size: 18px;
    font-weight: 700;
    color: #1e293b;
    margin: 0 0 6px;
}

.checkout-oto-offer-price {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-bottom: 12px;
}

.checkout-oto-price-current {
    font-size: 30px;
    font-weight: 700;
    color: #667eea;
}

.checkout-oto-price-period {
    font-size: 15px;
    color: #64748b;
}

.checkout-oto-price-highlight {
    font-size: 12px;
    color: #b45309;
    background: #fef3c7;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 600;
}

/* Features List */
.checkout-oto-features {
    list-style: none;
    padding: 0;
    margin: 0 0 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.checkout-oto-features li {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #374151;
}

.checkout-oto-features li::before {
    content: '';
    width: 18px;
    height: 18px;
    background: #10b981;
    border-radius: 50%;
    flex-shrink: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M9 16.17L4.83 12l-1.42 1.41L9 19 21 7l-1.41-1.41z'/%3E%3C/svg%3E");
    background-size: 12px;
    background-position: center;
    background-repeat: no-repeat;
}

/* OTO Transition (between upsell steps) */
.checkout-oto-transition {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    animation: transitionPop 0.4s ease-out;
}

.checkout-oto-transition-icon {
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
    animation: checkPop 0.5s ease-out;
}

.checkout-oto-transition-icon svg {
    width: 32px;
    height: 32px;
    color: #fff;
}

.checkout-oto-transition-text {
    font-size: 20px;
    font-weight: 700;
    color: #10b981;
}

@keyframes transitionPop {
    0% { opacity: 0; transform: scale(0.9); }
    100% { opacity: 1; transform: scale(1); }
}

@keyframes checkPop {
    0% { transform: scale(0); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

/* OTO Buttons */
.checkout-oto-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.checkout-btn-yes {
    width: 100%;
    padding: 16px 20px;
    font-size: 17px;
    font-weight: 700;
    color: #fff;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 14px rgba(16, 185, 129, 0.35);
    text-transform: none;
}

.checkout-btn-yes:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px rgba(16, 185, 129, 0.45);
}

.checkout-btn-yes:active {
    transform: translateY(0);
}

.checkout-btn-yes svg {
    width: 24px;
    height: 24px;
}

.checkout-btn-no {
    width: 100%;
    padding: 10px 20px;
    font-size: 12px;
    font-weight: 500;
    color: #94a3b8;
    background: transparent;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: underline;
    text-underline-offset: 2px;
}

.checkout-btn-no:hover {
    color: #64748b;
}

/* ==========================================================================
   CLOSE BUTTON
   ========================================================================== */

.checkout-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
    font-size: 20px;
    line-height: 1;
}

.checkout-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ==========================================================================
   TRUST BADGES
   ========================================================================== */

.checkout-trust {
    display: flex;
    justify-content: center;
    gap: 14px;
    padding: 12px 16px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
}

.checkout-trust-item {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    color: #64748b;
}

.checkout-trust-item svg {
    width: 14px;
    height: 14px;
    color: #10b981;
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 540px) {
    .checkout-modal {
        padding: 0;
        align-items: flex-end;
    }

    .checkout-modal-container {
        max-width: 100%;
        max-height: 95vh;
        border-radius: 20px 20px 0 0;
    }

    .checkout-cart-header {
        padding: 14px 16px;
    }

    .checkout-cart-amount {
        font-size: 20px;
    }

    .checkout-modal-content {
        padding: 20px 16px;
    }

    .checkout-oto-price-current {
        font-size: 28px;
    }

    .checkout-trust {
        flex-wrap: wrap;
        gap: 12px;
    }
}

/* ==========================================================================
   LOADING STATE
   ========================================================================== */

.checkout-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
}

.checkout-loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #e2e8f0;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.checkout-loading-text {
    font-size: 15px;
    color: #64748b;
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */

.checkout-cart-header {
    transition: all 0.3s ease;
}

.checkout-cart-product,
.checkout-cart-amount {
    transition: all 0.3s ease;
}

/* Price change animation */
@keyframes pricePop {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}

.checkout-cart-amount.updating {
    animation: pricePop 0.3s ease-out;
}
