/* 💎 Premium Checkout Overhaul - Glassmorphism & Trust */

/* auth.css sets --text-main to near-white; scope checkout to light readable tokens */
body.checkout-page {
    --text-main: #0f172a;
    --text-primary: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --surface-glass: #ffffff;
    color: #0f172a;
}

:root {
    --checkout-glass-bg: rgba(255, 255, 255, 0.75);
    --checkout-glass-border: rgba(255, 255, 255, 0.6);
    --checkout-glass-shadow: 0 16px 40px rgba(31, 38, 135, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.4);
    --checkout-blur: 32px;
    --trust-green: #059669;
    --urgency-red: #ef4444;
}

body.dark-mode {
    --checkout-glass-bg: rgba(15, 23, 42, 0.65);
    --checkout-glass-border: rgba(255, 255, 255, 0.08);
    --checkout-glass-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);
}

.checkout-container {
    max-width: 1100px;
    margin: 40px auto;
    padding: 0 20px;
    position: relative;
    display: grid;
    grid-template-columns: 1fr 380px;
    gap: 32px;
    align-items: start;
}

@media (max-width: 992px) {
    .checkout-container {
        grid-template-columns: 1fr;
        display: flex;
        flex-direction: column;
        align-items: stretch;
    }
    
    .checkout-main {
        order: 2;
        width: 100%;
    }
    
    .order-summary-container {
        order: 1;
        width: 100%;
        margin-bottom: 24px;
        position: static;
        top: auto;
    }
    
    .order-summary {
        position: relative;
        top: 0;
    }
}

/* Glass Cards */
.checkout-card {
    background: var(--checkout-glass-bg);
    backdrop-filter: blur(var(--checkout-blur));
    -webkit-backdrop-filter: blur(var(--checkout-blur));
    border: 1px solid var(--checkout-glass-border);
    border-radius: 20px;
    padding: 32px;
    margin-bottom: 24px;
    box-shadow: var(--checkout-glass-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.checkout-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 20px 48px rgba(31, 38, 135, 0.15);
}

body.dark-mode .checkout-card:hover {
    box-shadow: 0 20px 48px rgba(0, 0, 0, 0.5);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 24px;
    border-bottom: 1px solid var(--checkout-glass-border);
    padding-bottom: 16px;
}

.card-header .icon {
    font-size: 1.5rem;
    color: var(--brand-primary, #ff8c00);
}

.card-header .title {
    font-family: 'Poppins', sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
    color: #0f172a;
}

/* Standard email field — avoids floating-label + i18n placeholder conflicts */
.checkout-field {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 4px;
}

.checkout-field.full-width {
    width: 100%;
}

.checkout-field-label {
    font-size: 0.9rem;
    font-weight: 600;
    color: #334155;
    line-height: 1.3;
}

.checkout-field-input {
    width: 100%;
    display: block;
    padding: 14px 16px;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    font-size: 1rem;
    color: #0f172a;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
    min-height: 52px;
}

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

.checkout-field-input:focus {
    border-color: var(--brand-primary, #ff8c00);
    box-shadow: 0 0 0 4px rgba(255, 140, 0, 0.15);
    outline: none;
}

body.dark-mode.checkout-page .checkout-field-label {
    color: #cbd5e1;
}

body.dark-mode.checkout-page .checkout-field-input {
    background: rgba(15, 23, 42, 0.9);
    border-color: rgba(255, 255, 255, 0.12);
    color: #f8fafc;
}

/* Floating Labels Form Group */
.form-floating {
    position: relative;
    margin-bottom: 16px;
}
.form-floating.full-width {
    width: 100%;
}

.checkout-card .form-floating input[type="text"],
.checkout-card .form-floating input[type="email"] {
    width: 100%;
    display: block;
    padding: 24px 16px 8px 16px;
    border-radius: 12px;
    border: 1px solid var(--border-color, #e2e8f0);
    background: rgba(255, 255, 255, 0.9);
    font-size: 1rem;
    transition: all 0.3s ease;
    box-sizing: border-box;
    height: 56px;
}
body.dark-mode .checkout-card .form-floating input {
    background: rgba(15, 23, 42, 0.9);
    border-color: rgba(255, 255, 255, 0.1);
    color: #fff;
}
.checkout-card .form-floating input:focus {
    border-color: var(--brand-primary, #ff8c00);
    box-shadow: 0 0 0 4px rgba(255, 140, 0, 0.15);
    outline: none;
}

.checkout-card .form-floating label {
    position: absolute;
    top: 16px;
    left: 16px;
    pointer-events: none;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    color: #64748b;
    transform-origin: 0 0;
    margin: 0;
}
body.dark-mode .checkout-card .form-floating label { color: #94a3b8; }

/* Float the label when focused or when placeholder is not shown (i.e. has text) */
.checkout-card .form-floating input:focus ~ label,
.checkout-card .form-floating input:not(:placeholder-shown) ~ label {
    transform: translateY(-8px) scale(0.75);
    color: var(--brand-primary, #ff8c00);
}
.checkout-card .form-floating input:not(:focus):not(:placeholder-shown) ~ label {
    color: #64748b; /* Revert label color if blurred but has text */
}

/* Payment Options - Interactive Cards */
body.checkout-page .payment-methods {
    display: flex !important;
    flex-direction: column !important;
    gap: 12px;
    grid-template-columns: unset !important;
}

.payment-methods {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.payment-option {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 20px;
    border: 2px solid #e2e8f0;
    border-radius: 16px;
    background: #ffffff;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

body.dark-mode.checkout-page .payment-option {
    background: rgba(15, 23, 42, 0.85);
    border-color: rgba(255, 255, 255, 0.1);
}

.payment-option:hover {
    background: #fffaf5;
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.06);
    border-color: rgba(255, 107, 0, 0.35);
}

.payment-option-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.payment-option strong {
    font-size: 1rem;
    font-weight: 700;
    color: #0f172a;
    line-height: 1.3;
}

body.dark-mode.checkout-page .payment-option strong {
    color: #f8fafc;
}

.payment-logos {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    margin-left: 0 !important;
}

.payment-option input[type="radio"] {
    display: none;
}

.payment-check {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: 2px solid var(--border-light, rgba(0,0,0,0.1));
    color: transparent;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    font-size: 16px;
}
body.dark-mode .payment-check { border-color: rgba(255,255,255,0.15); }

.payment-option:has(input:checked) {
    border-color: var(--accent-main, #FF6B00);
    background: linear-gradient(135deg, rgba(255, 107, 0, 0.05), transparent);
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 16px 32px -8px rgba(255, 107, 0, 0.2), 0 0 0 4px rgba(255, 107, 0, 0.1);
}

body.dark-mode .payment-option:has(input:checked) {
    background: linear-gradient(135deg, rgba(255, 107, 0, 0.1), rgba(0,0,0,0.2));
}

.payment-option:has(input:checked) .payment-check {
    background: var(--accent-main, #FF6B00);
    border-color: var(--accent-main, #FF6B00);
    color: white;
    transform: scale(1.15);
    box-shadow: 0 4px 12px rgba(255, 107, 0, 0.4);
}

.paypal-checkout-panel {
    margin-top: 18px;
    padding: 16px;
    border: 1px solid rgba(0, 69, 124, 0.16);
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.96), rgba(239, 247, 255, 0.92));
    box-shadow: 0 12px 28px rgba(0, 69, 124, 0.08);
}

.paypal-panel-header {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
}

.paypal-panel-icon {
    width: 42px;
    height: 42px;
    display: grid;
    place-items: center;
    border-radius: 14px;
    background: #ffc439;
    color: #003087;
    font-size: 1.25rem;
    box-shadow: 0 8px 18px rgba(255, 196, 57, 0.28);
}

.paypal-panel-header strong,
.paypal-panel-header span {
    display: block;
}

.paypal-panel-header strong {
    color: #0f172a;
    font-weight: 800;
    line-height: 1.2;
}

.paypal-panel-header span {
    margin-top: 3px;
    color: #64748b;
    font-size: 0.88rem;
    line-height: 1.35;
}

.paypal-panel-loader {
    height: 48px;
    border-radius: 12px;
    background: linear-gradient(90deg, rgba(0, 48, 135, 0.08), rgba(255, 196, 57, 0.22), rgba(0, 48, 135, 0.08));
    background-size: 220% 100%;
    animation: paypalPanelShimmer 1.1s ease-in-out infinite;
}

@keyframes paypalPanelShimmer {
    from { background-position: 100% 0; }
    to { background-position: -100% 0; }
}

.paypal-buttons-slot {
    min-height: 128px;
}

.paypal-checkout-panel iframe {
    border-radius: 12px !important;
}

.paypal-checkout-panel--focus {
    border-color: rgba(255, 196, 57, 0.85);
    box-shadow:
        0 0 0 4px rgba(255, 196, 57, 0.28),
        0 16px 32px rgba(0, 69, 124, 0.12);
}

@media (max-width: 992px) {
    #card-payment-method #paypal-button-container.paypal-checkout-panel--ready {
        scroll-margin-top: 96px;
        scroll-margin-bottom: 120px;
    }

    body.mobile-step-2 #card-payment-method {
        scroll-margin-top: 88px;
    }
}

/* Trust Badges */
.trust-badges-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 16px;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px dashed var(--checkout-glass-border);
}

.trust-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(5, 150, 105, 0.1);
    color: var(--trust-green);
    padding: 8px 16px;
    border-radius: 999px;
    font-size: 0.85rem;
    font-weight: 600;
}

/* Urgency Trigger */
.urgency-banner {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--urgency-red);
    padding: 12px 20px;
    border-radius: 12px;
    margin-bottom: 24px;
    font-weight: 600;
    font-size: 0.95rem;
    border: 1px solid rgba(239, 68, 68, 0.2);
    animation: pulseRed 2s infinite;
}

@keyframes pulseRed {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

.urgency-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--urgency-red);
}

/* Glowing Checkout Button */
.checkout-btn {
    width: 100%;
    padding: 18px;
    border-radius: 16px;
    border: none;
    background: linear-gradient(135deg, #ff8c00, #ff5722);
    color: white;
    font-family: 'Poppins', sans-serif;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(255, 140, 0, 0.4);
    transition: all 0.3s ease;
    margin-top: 24px;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
}

.checkout-btn:hover {
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 12px 32px rgba(255, 140, 0, 0.6);
}

.checkout-btn i {
    font-size: 1.3rem;
}

/* Sticky Frosted Glass Order Summary */
.order-summary-container {
    position: sticky;
    top: 100px;
}


.order-summary.checkout-card {
    background: var(--checkout-glass-bg);
    backdrop-filter: blur(var(--checkout-blur));
    -webkit-backdrop-filter: blur(var(--checkout-blur));
    border: 1px solid var(--checkout-glass-border);
    box-shadow: var(--checkout-glass-shadow);
}


body.checkout-page .summary-title {
    font-family: 'Poppins', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    margin: 0 0 20px;
    text-align: left;
    color: #0f172a;
}

body.checkout-page .summary-total {
    border-top: 1px solid #e2e8f0;
    padding-top: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 700;
    color: #0f172a;
}

body.checkout-page .summary-total .total-amount {
    font-size: 1.5rem;
    color: #ff6b00;
}

body.checkout-page .summary-items {
    max-height: 280px;
    overflow-y: auto;
    margin-bottom: 16px;
}

body.checkout-page .premium-list-item {
    border-bottom: 1px solid #f1f5f9 !important;
    align-items: flex-start;
}

body.checkout-page .premium-list-item:last-child {
    border-bottom: none !important;
}

body.checkout-page .summary-item-name {
    font-weight: 600;
    color: #2d3748;
    font-size: 14px;
    margin-bottom: 2px;
    line-height: 1.35;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
}

body.dark-mode .order-summary.checkout-card {
    background: var(--checkout-glass-bg);
    border-color: var(--checkout-glass-border);
    box-shadow: var(--checkout-glass-shadow);
}

/* Checkout Background Gradient */
.account-gradient {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: -1;
    background: radial-gradient(circle at 15% 50%, rgba(255, 107, 0, 0.08), transparent 25%),
                radial-gradient(circle at 85% 30%, rgba(255, 107, 0, 0.05), transparent 25%);
    background-color: var(--bg-main);
    pointer-events: none;
}
body.dark-mode .account-gradient {
    background: radial-gradient(circle at 15% 50%, rgba(255, 107, 0, 0.08), transparent 25%),
                radial-gradient(circle at 85% 30%, rgba(255, 107, 0, 0.05), transparent 25%);
    background-color: #0d1117;
}

/* --- Multi-Step Mobile Checkout --- */

/* By default, hide the mobile navigation buttons */
.mobile-step-btn {
    display: none !important;
}

@media (max-width: 992px) {
    /* Base layout fixes */
    .checkout-container {
        display: flex;
        flex-direction: column;
        gap: 0;
    }

    /* Step 1 Active */
    body.mobile-step-1 .checkout-main #card-payment-method, /* Payment Method */
    body.mobile-step-1 .checkout-main #binance-instructions,
    body.mobile-step-1 .order-summary-container .place-order-btn,
    body.mobile-step-1 .order-summary-container #paypal-button-container {
        display: none !important;
    }

    body.mobile-step-1 #btn-proceed-payment {
        display: flex !important;
    }

    /* Make Order Summary appear first in Step 1 */
    body.mobile-step-1 .order-summary-container {
        order: -1;
    }

    /* Step 2 Active */
    body.mobile-step-2 .urgency-banner,
    body.mobile-step-2 #card-your-details,
    body.mobile-step-2 .order-summary.checkout-card .summary-title,
    body.mobile-step-2 .order-summary.checkout-card .summary-items,
    body.mobile-step-2 .order-summary.checkout-card .summary-total {
        display: none !important;
    }

    body.mobile-step-2 .order-summary.checkout-card {
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin-top: 16px;
    }

    body.mobile-step-2 #btn-back-step-1 {
        display: flex !important;
    }

    /* Move Place Order button to bottom of Step 2 visually */
    body.mobile-step-2 .checkout-main {
        display: flex;
        flex-direction: column;
    }

    /* Mobile Back Button styling polish */
    .mobile-back-btn:active {
        opacity: 0.7;
    }

    /* Smooth Animations */
    @keyframes slideInUp {
        from { opacity: 0; transform: translateY(15px); }
        to { opacity: 1; transform: translateY(0); }
    }
    @keyframes fadeIn {
        from { opacity: 0; }
        to { opacity: 1; }
    }

    body.mobile-step-1 .checkout-main,
    body.mobile-step-1 .order-summary-container {
        animation: fadeIn 0.4s ease;
    }
    
    body.mobile-step-2 .checkout-main,
    body.mobile-step-2 .order-summary-container {
        animation: slideInUp 0.4s ease;
    }

    /* Make all cards consistent on mobile */
    .checkout-card {
        padding: 20px;
        border-radius: 16px;
    }

    /* Fix Order Summary sizing in Step 1 */
    body.mobile-step-1 .order-summary.checkout-card {
        margin: 0 0 24px 0 !important;
        width: 100%;
        box-sizing: border-box;
        padding: 16px 18px !important;
        border-radius: 20px !important;
    }

    .order-summary.checkout-card {
        background: var(--checkout-glass-bg) !important;
        border: 1px solid var(--checkout-glass-border) !important;
        box-shadow: var(--checkout-glass-shadow) !important;
        backdrop-filter: blur(var(--checkout-blur)) !important;
        -webkit-backdrop-filter: blur(var(--checkout-blur)) !important;
        border-radius: 16px !important;
    }
    
    /* Ensure padding for containers on mobile */
    body.checkout-page .checkout-container {
        padding: 16px 0; /* Vertical padding */
    }
    
    body.checkout-page .checkout-main,
    body.checkout-page .order-summary-container {
        padding: 0 16px !important;
        box-sizing: border-box;
    }

    body.checkout-page .order-summary-container {
        position: static !important;
        top: auto !important;
    }

    /* Extra scroll room above bottom nav + chat on checkout */
    body.checkout-page.has-bottom-nav {
        padding-bottom: calc(168px + env(safe-area-inset-bottom, 0px));
    }

    body.checkout-page .summary-items {
        max-height: 132px;
        overflow-y: auto;
        overscroll-behavior: contain;
        padding-right: 4px;
    }

    body.checkout-page .summary-total {
        align-items: flex-end;
        gap: 8px;
        flex-wrap: wrap;
        padding-top: 12px;
    }

    /* Fixed CTA bar above bottom navigation */
    body.checkout-page .checkout-mobile-cta {
        position: fixed;
        left: 16px;
        right: 16px;
        width: auto !important;
        bottom: calc(92px + env(safe-area-inset-bottom, 0px));
        z-index: 950;
        margin: 0 !important;
        display: flex;
        justify-content: center;
        align-items: center;
        gap: 8px;
        font-size: 16px;
        padding: 16px;
        box-shadow: 0 -4px 24px rgba(15, 23, 42, 0.12);
        box-sizing: border-box;
    }

    /* Reserve space so scrollable content clears the fixed CTA */
    body.checkout-page.mobile-step-1 .checkout-main::after,
    body.checkout-page.mobile-step-2 .checkout-main::after {
        content: '';
        display: block;
        height: 80px;
    }

    /* Fix Place Order button position in Step 2 */
    body.mobile-step-2 .order-summary-container {
        order: 3 !important; /* Force to bottom in step 2 */
        padding: 0 !important;
        margin: 0 !important;
        min-height: 0 !important;
        margin-bottom: 0;
        display: contents;
    }
    
    /* Hide the summary card borders entirely in step 2, leaving only the button */
    body.mobile-step-2 .order-summary.checkout-card {
        display: contents !important;
        margin: 0 !important;
    }

    body.mobile-step-2 .order-summary.checkout-card .coupon-toggle-card,
    body.mobile-step-2 .order-summary.checkout-card .coupon-auth-notice {
        display: none !important;
    }
}

@media (min-width: 993px) {
    body.checkout-page .checkout-mobile-cta {
        position: static;
        left: auto;
        right: auto;
        bottom: auto;
        z-index: auto;
        box-shadow: none;
    }

    body.checkout-page.mobile-step-1 .checkout-main::after,
    body.checkout-page.mobile-step-2 .checkout-main::after {
        content: none;
        display: none;
        height: 0;
    }
}
