/* =====================================================================
   Just4Specs Lens Configurator — Modal UI
   ===================================================================== */

/* ---------- trigger button ----------------------------------------- */
.jsl-select-lenses-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 14px 28px;
    font-size: 1rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    border-radius: 4px;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
    margin-bottom: 12px;
}
.jsl-select-lenses-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
}
.jsl-btn-arrow {
    font-size: 1.1em;
    transition: transform 0.2s ease;
}
.jsl-select-lenses-btn:hover .jsl-btn-arrow {
    transform: translateX(4px);
}

/* ---------- body lock ----------------------------------------- */
body.jsl-modal-open {
    overflow: hidden;
}

/* ---------- overlay ----------------------------------------- */
#jsl-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    padding: 16px;
    box-sizing: border-box;
}
#jsl-modal-overlay.jsl-visible {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* ---------- modal card ----------------------------------------- */
#jsl-modal {
    position: relative;
    background: #ffffff;
    border-radius: 12px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.22);
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    transform: scale(0.88) translateY(24px);
    transition: transform 0.32s cubic-bezier(0.34, 1.56, 0.64, 1);
    overflow: hidden;
}
#jsl-modal-overlay.jsl-visible #jsl-modal {
    transform: scale(1) translateY(0);
}

/* ---------- modal header ----------------------------------------- */
#jsl-modal-header {
    padding: 16px 20px 0;
    border-bottom: 1px solid #ebebeb;
    flex-shrink: 0;
}
#jsl-modal-header-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}
/* Back button — left side of header */
.jsl-btn-back-header {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px 8px;
    border-radius: 6px;
    font-size: 0.88rem;
    font-weight: 600;
    color: #555;
    transition: background 0.15s, color 0.15s;
    line-height: 1;
}
.jsl-btn-back-header:hover {
    background: #f2f2f2;
    color: #111;
}
.jsl-btn-back-header svg {
    flex-shrink: 0;
}
#jsl-modal-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}
#jsl-steps-indicator {
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #888;
    white-space: nowrap;
    flex-shrink: 0;
}
#jsl-modal-close {
    background: none;
    border: none;
    cursor: pointer;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    transition: background 0.15s, color 0.15s;
    flex-shrink: 0;
    padding: 0;
}
#jsl-modal-close:hover {
    background: #f2f2f2;
    color: #111;
}
#jsl-modal-title {
    margin: 0;
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.3;
}

/* ---------- progress bar ----------------------------------------- */
#jsl-progress-bar {
    height: 3px;
    background: #ebebeb;
    flex-shrink: 0;
    overflow: hidden;
}
#jsl-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2271b1, #135e96);
    transition: width 0.4s ease;
}

/* ---------- step dots ----------------------------------------- */
#jsl-step-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding: 10px 24px 0;
    flex-shrink: 0;
}
.jsl-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #ddd;
    transition: background 0.25s ease, transform 0.25s ease;
}
.jsl-dot.jsl-dot-active {
    background: #2271b1;
    transform: scale(1.3);
}
.jsl-dot.jsl-dot-done {
    background: #46b450;
}

/* ---------- modal body ----------------------------------------- */
#jsl-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}
#jsl-modal-body::-webkit-scrollbar {
    width: 6px;
}
#jsl-modal-body::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

/* ---------- TM EPO wrapper inside modal ----------------------------------------- */
#jsl-modal-body .tc-extra-product-options {
    margin: 0 !important;
    border: none !important;
    padding: 0 !important;
    background: transparent !important;
}
#jsl-modal-body .tm-extra-product-options-fields {
    padding: 0 !important;
    margin: 0 !important;
    list-style: none !important;
}

/* ---------- section show/hide (managed by syncSections) ------------ */
.cpf-section.jsl-section-inactive {
    display: none !important;
}
.cpf-section.jsl-section-active {
    display: block !important;
}

/* ---------- step show/hide (per .cpf-element) ----------------------- */
.cpf-element.jsl-step-hidden {
    display: none !important;
}
.cpf-element.jsl-step-active {
    display: block;
    animation: jslFadeSlide 0.28s ease forwards;
}

@keyframes jslFadeSlide {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}
.cpf-element.jsl-slide-back.jsl-step-active {
    animation: jslFadeSlideBack 0.28s ease forwards;
}
@keyframes jslFadeSlideBack {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ---------- validation error highlight ----------------------------------------- */
.jsl-field-error {
    border-color: #cc1818 !important;
    box-shadow: 0 0 0 2px rgba(204, 24, 24, 0.15) !important;
}
#jsl-validation-msg {
    display: none;
    background: #fdf3f3;
    color: #cc1818;
    border: 1px solid #f5c6c6;
    border-radius: 6px;
    padding: 10px 14px;
    font-size: 0.88rem;
    margin-bottom: 16px;
}
#jsl-validation-msg.jsl-shown {
    display: block;
}

/* ---------- previous-selections recap (shown on last step) --------- */
.jsl-step-recap {
    background: #f8f9fb;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 12px 14px;
    margin-bottom: 18px;
    animation: jslFadeSlide 0.22s ease forwards;
}
.jsl-recap-heading {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: #888;
    margin-bottom: 8px;
}
.jsl-recap-row {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 12px;
    padding: 5px 0;
    font-size: 0.875rem;
    border-bottom: 1px solid #eef0f4;
}
.jsl-recap-row:last-child { border-bottom: none; }
.jsl-recap-label { color: #6b7280; flex-shrink: 0; }
.jsl-recap-value { font-weight: 600; color: #1c1c1c; text-align: right; word-break: break-word; }

/* ---------- summary screen — receipt style ----------------------------------------- */
#jsl-summary-screen {
    animation: jslFadeSlide 0.3s ease forwards;
}
.jsl-receipt-list {
    list-style: none;
    margin: 0;
    padding: 0;
    border: 1px solid #ebebeb;
    border-radius: 10px;
    overflow: hidden;
}
.jsl-receipt-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 13px 16px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 0.95rem;
}
.jsl-receipt-item:last-child {
    border-bottom: none;
}
.jsl-receipt-product {
    background: #f8f9fb;
    font-weight: 700;
}
.jsl-receipt-product .jsl-receipt-name {
    font-weight: 700;
    color: #111;
}
.jsl-receipt-name {
    font-weight: 500;
    color: #1c1c1c;
}
.jsl-receipt-price {
    font-weight: 600;
    color: #333;
    white-space: nowrap;
    margin-left: 12px;
}
.jsl-receipt-empty {
    color: #888;
    font-style: italic;
}
.jsl-receipt-subtotal {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 10px;
    padding: 14px 16px;
    background: #f0f6ff;
    border: 1px solid #cce0f5;
    border-radius: 8px;
}
.jsl-receipt-subtotal-label {
    font-size: 0.95rem;
    font-weight: 700;
    color: #333;
}
.jsl-receipt-subtotal-value {
    font-size: 1.2rem;
    font-weight: 700;
    color: #2271b1;
}

/* ---------- modal footer ----------------------------------------- */
#jsl-modal-footer {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid #ebebeb;
    flex-shrink: 0;
    background: #fff;
}
#jsl-footer-price {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}
.jsl-footer-price-label {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #999;
    line-height: 1;
}
#jsl-footer-price-val {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2271b1;
    line-height: 1.2;
}
#jsl-btn-confirm {
    flex-shrink: 0;
    min-width: 160px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 22px;
    background: #2271b1;
    border-color: #2271b1;
    color: #fff;
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.4;
}
#jsl-btn-confirm:hover {
    background: #135e96;
    border-color: #135e96;
}

.jsl-hidden {
    display: none !important;
}

/* ---------- responsive ----------------------------------------- */
@media (max-width: 600px) {
    #jsl-modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
    #jsl-modal {
        max-width: 100%;
        border-radius: 16px 16px 0 0;
        max-height: 92vh;
        transform: translateY(100%);
    }
    #jsl-modal-overlay.jsl-visible #jsl-modal {
        transform: translateY(0);
    }
    #jsl-modal-header {
        padding: 16px 16px 12px;
    }
    #jsl-modal-body {
        padding: 16px;
    }
    #jsl-modal-footer {
        padding: 12px 16px;
    }
    #jsl-footer-price-val {
        font-size: 0.95rem;
    }
    #jsl-btn-confirm {
        min-width: 110px;
        font-size: 0.82rem;
    }
}
