/**
 * Gadgetz Fast Checkout Engine Styling
 * Matching modern high-conversion e-commerce specifications
 */

:root {
    --eso-border-color: #9333EA;
    --eso-background-color: #F3E8FF;
    --eso-label-color: #581C87;
    --eso-radius: 7px;
    --gadgetz-accent: #00b8b1;
    --gadgetz-primary: #2563eb;
    --gadgetz-dark: #0f172a;
    --gadgetz-success: #10b981;
}

/* 1. Main Form Container */
.es-form-container {
    width: 100%;
    max-width: 650px;
    margin: 0 auto 24px auto;
    box-sizing: border-box;
    padding: 16px 18px;
    background: #ffffff !important;
    border: 1px solid #00b8b1 !important;
    border-radius: 10px !important;
    box-shadow: rgba(0, 0, 0, 0.23) 0px 2px 7px 0px !important;
    color: #000000 !important;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;
}

.es-form-container * {
    box-sizing: border-box;
}

/* Essential Flex & Layout Utilities */
.d-flex { display: flex !important; }
.flex-column { flex-direction: column !important; }
.flex-wrap { flex-wrap: wrap !important; }
.flex-fill { flex: 1 1 auto !important; }
.flex-grow-1 { flex-grow: 1 !important; }
.align-items-center { align-items: center !important; }
.align-items-baseline { align-items: baseline !important; }
.align-items-end { align-items: flex-end !important; }
.justify-content-between { justify-content: space-between !important; }
.gap-1 { gap: 4px !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 12px !important; }

.es-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* ==========================================================================
   2. QUANTITY OFFERS (MATCHING USER REFERENCE TEMPLATE)
   ========================================================================== */
.es-quantity-offers {
    margin-bottom: 6px;
}

.gadgetz-packs-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.es-qo-container {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: center;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 9px 14px !important;
    min-height: 42px !important;
    cursor: pointer;
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
    user-select: none;
    box-sizing: border-box;
}

.es-qo-container:hover {
    border-color: #a855f7;
    background-color: #faf5ff;
}

/* Active / Selected Offer Card */
.es-qo-container.es-selected-offer,
.es-qo-container[offer-selected="true"] {
    background: #f4ebff !important;
    border-color: #9333ea !important;
    box-shadow: 0 0 0 1px #9333ea !important;
}

.es-qo-row {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    width: 100% !important;
    gap: 8px !important;
    flex-wrap: nowrap !important;
}

.es-qo-left {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 8px !important;
    flex-wrap: nowrap !important;
    min-width: 0 !important;
    flex: 1 1 auto !important;
}

/* Custom Radio Indicator matching Example 2 */
.offer-radio {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    width: 18px !important;
    height: 18px !important;
    margin: 0 !important;
}

.custom-radio-circle {
    width: 18px !important;
    height: 18px !important;
    min-width: 18px !important;
    min-height: 18px !important;
    border-radius: 50% !important;
    border: 1.5px solid #cbd5e1 !important;
    background-color: #ffffff !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    flex-shrink: 0 !important;
    box-sizing: border-box !important;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.es-qo-container.es-selected-offer .custom-radio-circle,
.es-qo-container[offer-selected="true"] .custom-radio-circle {
    border-color: #9333ea !important;
    border-width: 2px !important;
}

.es-qo-container.es-selected-offer .custom-radio-circle::after,
.es-qo-container[offer-selected="true"] .custom-radio-circle::after {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #9333ea;
}

.es-title-container {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 6px !important;
    flex-wrap: nowrap !important;
    min-width: 0 !important;
    white-space: nowrap !important;
}

.offer-title {
    font-weight: 700 !important;
    font-size: 14px !important;
    color: #111827 !important;
    margin: 0 !important;
    white-space: nowrap !important;
    line-height: 1.2 !important;
}

/* Discount Badge Pill */
.offer-badge {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 2px 7px !important;
    border-radius: 4px !important;
    font-size: 11px !important;
    font-weight: 700 !important;
    color: #ffffff !important;
    background-color: #9333ea !important;
    line-height: 1.2 !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

.gadgetz-packs-list .es-qo-container:nth-child(1) .offer-badge {
    background-color: #a855f7 !important;
}

.gadgetz-packs-list .es-qo-container:nth-child(2) .offer-badge {
    background-color: #9333ea !important;
}

.gadgetz-packs-list .es-qo-container:nth-child(3) .offer-badge {
    background-color: #6b21a8 !important;
}

/* Top-Right Ribbon ("Le Plus Vendu") matching Example 2 */
.offer-label {
    position: absolute;
    top: -1px;
    right: 14px;
    background-color: #6b21a8 !important;
    color: #ffffff !important;
    font-size: 10px !important;
    font-weight: 700 !important;
    padding: 2px 8px !important;
    border-radius: 0 0 5px 5px !important;
    letter-spacing: 0.2px;
    z-index: 2;
    line-height: 1.3 !important;
    white-space: nowrap !important;
}

/* Subtle ribbon fold/tail on the left of "Le Plus Vendu" */
.offer-label::before {
    content: "";
    position: absolute;
    top: 0;
    left: -7px;
    width: 0;
    height: 0;
    border-top: 7px solid #4c1d95;
    border-left: 7px solid transparent;
}

/* Price Container on Right (Clean single-line look like Example 2) */
.es-price-container {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: baseline !important;
    gap: 6px !important;
    margin-left: auto !important;
    white-space: nowrap !important;
    flex-shrink: 0 !important;
}

.es-o-p {
    font-weight: 700 !important;
    font-size: 14px !important;
    color: #111827 !important;
    white-space: nowrap !important;
}

.es-o-cp {
    font-size: 11px !important;
    color: #9ca3af !important;
    text-decoration: line-through !important;
    white-space: nowrap !important;
}

/* Pack Variant Selectors */
.es-pack-variants-box {
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px dashed rgba(147, 51, 234, 0.3);
}

.es-unit-variant-row {
    background: rgba(255, 255, 255, 0.7);
    padding: 6px 10px;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.es-o-index {
    font-size: 12px;
    color: #4b5563;
    font-weight: 700;
}

.es-select {
    width: 100%;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 13px;
    background: #ffffff;
    color: #1f2937;
    outline: none;
}

.es-select:focus {
    border-color: #9333ea;
}

/* ==========================================================================
   3. SHIPPING ROW (MATCHING EXAMPLE 2 BOTTOM BAR)
   ========================================================================== */
.shipping-container {
    display: flex;
    flex-direction: column;
}

.shipping-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    padding: 12px 18px;
    background-color: #ffffff;
}

.shipping-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    margin: 0;
    font-size: 14px;
    color: #4b5563;
}

.es-radio {
    accent-color: #111827;
    width: 16px;
    height: 16px;
    cursor: pointer;
    margin: 0;
}

.shipping-name {
    color: #4b5563;
    font-weight: 500;
}

.shipping-price {
    font-weight: 700;
    font-size: 14px;
    color: #111827;
    white-space: nowrap;
}

/* 4. Inline Upsell Panel (eiups) */
.eiups-panel {
    background: #faf5ff;
    border: 1.5px dashed #c084fc;
    border-radius: 10px;
    padding: 12px 14px;
    margin: 4px 0 10px 0;
}

.eiups-heading {
    font-size: 15px !important;
    font-weight: 800 !important;
    color: #6b21a8 !important;
    margin: 0 0 10px 0 !important;
    display: flex;
    align-items: center;
    gap: 6px;
}

.eiups-heading::before {
    content: '🎁';
    font-size: 16px;
}

.eiups-products {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.eiups-product {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #ffffff;
    border: 1.5px solid #e9d5ff;
    border-radius: 8px;
    padding: 8px 12px;
    position: relative;
    transition: all 0.2s ease;
}

.eiups-product.eiups-checked {
    border-color: #9333ea;
    box-shadow: 0 2px 8px rgba(147, 51, 234, 0.12);
    background: #fdf4ff;
}

.eiups-checkbox {
    width: 18px;
    height: 18px;
    accent-color: #9333ea;
    cursor: pointer;
    flex-shrink: 0;
}

.eiups-photo {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    overflow: hidden;
    flex-shrink: 0;
    cursor: pointer;
    border: 1px solid #f3e8ff;
}

.eiups-photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.eiups-description {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.eiups-product-name {
    font-size: 13px !important;
    font-weight: 700 !important;
    color: #1e293b;
    line-height: 1.2;
    cursor: pointer;
}

.eiups-price {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.eiups-line-total {
    font-size: 14px !important;
    font-weight: 800 !important;
    color: #9333ea;
}

.eiups-qty-controls {
    display: inline-flex;
    align-items: center;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    overflow: hidden;
    background: #fff;
    height: 24px;
}

.eiups-qty-minus,
.eiups-qty-plus {
    background: #f3f4f6;
    border: none;
    width: 22px;
    height: 100%;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    color: #4b5563;
    transition: background 0.15s;
}

.eiups-qty-minus:hover,
.eiups-qty-plus:hover {
    background: #e5e7eb;
}

.eiups-qty-input {
    width: 28px;
    height: 100%;
    border: none;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: #111827;
    padding: 0;
    -moz-appearance: textfield;
}

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

.eiups-discount-badge {
    background: #dc2626;
    color: #ffffff;
    font-size: 11px;
    font-weight: 700;
    padding: 1px 6px;
    border-radius: 4px;
}

.eiups-eye-btn {
    background: transparent;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #64748b;
    transition: all 0.15s;
    flex-shrink: 0;
}

.eiups-eye-btn:hover {
    color: #9333ea;
    border-color: #9333ea;
    background: #f5f3ff;
}

.eiups-check-visual {
    position: absolute;
    top: 6px;
    right: 8px;
    color: #9333ea;
    font-weight: bold;
    font-size: 14px;
    opacity: 0;
    transition: opacity 0.2s;
}

.eiups-product.eiups-checked .eiups-check-visual {
    opacity: 1;
}

/* 5. Customer Inputs */
.es-input-column {
    width: 100%;
}

.es-input-group,
.es-input-container {
    display: flex;
    align-items: stretch;
    width: 100%;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.es-input-group:focus-within,
.es-input-container:focus-within {
    border-color: #9333ea;
    box-shadow: 0 0 0 2px rgba(147, 51, 234, 0.12);
}

.es-input-group-text {
    background: #f8fafc;
    border-right: 1px solid #e2e8f0;
    padding: 0 14px;
    color: #64748b;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.es-input {
    flex: 1;
    width: 100%;
    border: none !important;
    outline: none !important;
    padding: 12px 14px !important;
    font-size: 14px !important;
    color: #0f172a !important;
    background: transparent !important;
    box-shadow: none !important;
}

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

/* 6. CTA Order Button & Shake Animation */
.es-button.es-cta-btn {
    width: 100%;
    padding: 14px 20px;
    border: 1px solid rgb(110, 231, 183) !important;
    border-radius: 12px !important;
    background: linear-gradient(135deg, rgb(16, 185, 129) 0%, rgb(0, 136, 86) 100%) !important;
    color: #ffffff !important;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    box-shadow: rgba(0, 0, 0, 0.2) 0px 2px 7px 0px !important;
    transition: transform 0.2s, box-shadow 0.2s;
}

.es-button.es-cta-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(16, 185, 129, 0.35) !important;
}

.es-button-content {
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    width: 100%;
}

.es-animation-shakeLeftRight {
    animation: es-shake 2.5s infinite;
}

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

/* Loading Mask / Spinner */
.es-loading-mask {
    display: inline-block;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: es-spin 0.8s linear infinite;
}

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

/* 7. Popup Trigger Button on Product Page */
.gadgetz-open-popup-btn {
    width: 100%;
    padding: 16px 20px;
    background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
    color: #ffffff;
    border: none;
    border-radius: 14px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.gadgetz-open-popup-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.5);
}

.gadgetz-btn-content {
    display: flex;
    align-items: center;
    gap: 14px;
}

.gadgetz-btn-text-group {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.gadgetz-btn-main-title {
    font-size: 17px;
    font-weight: 800;
}

.gadgetz-btn-subtitle {
    font-size: 13px;
    opacity: 0.9;
    font-weight: 500;
}

/* 8. Popup Modal Overlay & Dialog */
.gadgetz-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: gadgetz-fadeIn 0.2s ease-out;
}

.gadgetz-modal-dialog {
    background: #ffffff;
    border-radius: 16px;
    width: 100%;
    max-width: 620px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: gadgetz-slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.gadgetz-modal-close {
    position: absolute;
    top: 14px;
    right: 14px;
    background: #f1f5f9;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    font-size: 16px;
    font-weight: bold;
    color: #475569;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: background 0.15s;
}

.gadgetz-modal-close:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.gadgetz-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    border-top-left-radius: 16px;
    border-top-right-radius: 16px;
}

.gadgetz-mini-thumb img {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 8px;
}

.gadgetz-modal-body {
    padding: 16px;
}

.gadgetz-modal-body .es-form-container {
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
}

/* 9. Eye Preview Gallery Modal */
.gadgetz-eye-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
    z-index: 1000000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.gadgetz-eye-modal-dialog {
    background: #ffffff;
    border-radius: 14px;
    max-width: 480px;
    width: 100%;
    overflow: hidden;
    position: relative;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
}

.gadgetz-eye-modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
}

.gadgetz-eye-main-image-wrap {
    width: 100%;
    height: 320px;
    background: #f8fafc;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gadgetz-eye-main-image-wrap img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.gadgetz-eye-thumbs-row {
    display: flex;
    gap: 8px;
    padding: 10px;
    overflow-x: auto;
    background: #f1f5f9;
}

.gadgetz-eye-thumb-item {
    width: 48px;
    height: 48px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    flex-shrink: 0;
}

.gadgetz-eye-thumb-item.active {
    border-color: #9333ea;
}

.gadgetz-eye-thumb-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Summary Row & Reassurance Bullets */
.gadgetz-form-summary-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 14px;
    padding: 10px 6px 4px;
    border-top: 1px dashed #cbd5e1;
    font-size: 14px;
    color: #475569;
}

.gadgetz-grand-total {
    font-size: 18px;
    color: #0f172a;
}

.gadgetz-reassurance-bullets {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #f1f5f9;
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
    font-size: 12px;
    color: #64748b;
}

.gadgetz-reassurance-bullets img.emoji {
    width: 14px;
    height: 14px;
    vertical-align: -2px;
    margin-right: 4px;
}

/* Animations */
@keyframes gadgetz-fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Mobile Optimizations */
@media (max-width: 640px) {
    .es-form-container {
        padding: 12px 14px;
        border-radius: 8px !important;
    }

    .offer-title {
        font-size: 14px !important;
    }

    .es-o-p {
        font-size: 15px !important;
    }

    .es-button.es-cta-btn {
        padding: 12px 16px;
    }

    .gadgetz-modal-dialog {
        border-radius: 12px;
        max-height: 95vh;
    }
}

@media (max-width: 540px) {
    .es-qo-container {
        padding: 7px 10px !important;
        min-height: 38px !important;
    }

    .es-qo-row {
        gap: 6px !important;
        flex-wrap: nowrap !important;
    }

    .es-qo-left {
        gap: 6px !important;
        flex-wrap: nowrap !important;
    }

    .offer-title {
        font-size: 13px !important;
    }

    .offer-badge {
        font-size: 10px !important;
        padding: 1px 5px !important;
    }

    .es-o-p {
        font-size: 13px !important;
    }

    .offer-label {
        right: 8px !important;
        font-size: 9px !important;
        padding: 1px 6px !important;
    }

    .es-o-cp {
        display: none !important;
    }
}
