/* ===========================================
   LeadNest — Frontend Styles
   =========================================== */

/* ── Icon fill guard ──
   Theme CSS (e.g. `svg { fill: currentColor }`, `img,svg{max-width:100%}`)
   overrides the inline fill="white" presentation attributes — CSS rules
   beat presentation attributes — which made the WhatsApp icon render
   invisible. Force the plugin's filled icons to keep white regardless of
   theme styles. Stroke-based icons (close X) are intentionally excluded. */
#leadnest-wa-btn svg,
#leadnest-wa-btn svg path,
.ln-wa-avatar svg,
.ln-wa-avatar svg path,
.ln-bot-avatar svg,
.ln-bot-avatar svg path,
.ln-submit-btn svg,
.ln-submit-btn svg path { fill: #fff !important; }
/* Keep plugin SVGs at their intended size against theme overrides */
#leadnest-wa-btn svg,
.ln-wa-avatar svg,
.ln-bot-avatar svg,
.ln-submit-btn svg {
    display: inline-block !important;
    max-width: none !important;
    vertical-align: middle;
    flex: 0 0 auto;
}
/* Explicit sizes — themes often set `img,svg{height:auto}` which collapses
   inline-sized SVGs to 0×0, so the icon disappears entirely. */
#leadnest-wa-btn svg   { width: 30px !important; height: 30px !important; }
.ln-wa-avatar svg      { width: 20px !important; height: 20px !important; }
.ln-bot-avatar svg     { width: 14px !important; height: 14px !important; }
.ln-submit-btn svg     { width: 16px !important; height: 16px !important; }

/* ── Floating Button ── */
#leadnest-wa-wrapper {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#leadnest-wa-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.25);
    position: relative;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}

#leadnest-wa-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

#leadnest-wa-btn:focus-visible {
    outline: 3px solid #fff;
    outline-offset: 2px;
}

/* Pulse animation ring */
.leadnest-pulse {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: inherit;
    opacity: 0.5;
    animation: leadnest-pulse 2s ease-out infinite;
    pointer-events: none;
}

@keyframes leadnest-pulse {
    0%   { transform: scale(1);   opacity: 0.5; }
    70%  { transform: scale(1.5); opacity: 0;   }
    100% { transform: scale(1.5); opacity: 0;   }
}

/* ── Popup: Chat Widget ── */
#leadnest-popup {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 340px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.2);
    overflow: hidden;
    z-index: 99998;
    display: flex;
    flex-direction: column;
    max-height: 580px;
    border: 1px solid rgba(0,0,0,0.06);
    animation: leadnest-slideup 0.25s ease;
}

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

/* ── Header ── */
#leadnest-popup-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    color: #fff;
    flex-shrink: 0;
}

.ln-wa-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.ln-avatar-logo {
    width: 38px;
    height: 38px;
    object-fit: cover;
    border-radius: 50%;
}

.ln-header-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.ln-header-title {
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ln-header-sub {
    font-size: 10px;
    color: rgba(255,255,255,.75);
    margin-top: 1px;
}

/* ── In-popup Language Selector ── */
#leadnest-lang-select {
    background: rgba(255,255,255,.18);
    border: 1px solid rgba(255,255,255,.35);
    color: #fff;
    border-radius: 6px;
    padding: 3px 5px;
    font-size: 10px;
    font-weight: 700;
    cursor: pointer;
    outline: none;
    flex-shrink: 0;
    max-width: 80px;
}
#leadnest-lang-select:focus { border-color: rgba(255,255,255,.7); }
#leadnest-lang-select option { background: #1e293b; color: #fff; }

#leadnest-close-btn {
    background: rgba(255,255,255,.2);
    border: none;
    color: #fff;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s;
    flex-shrink: 0;
    padding: 0;
}

#leadnest-close-btn:hover { background: rgba(255,255,255,.35); }

/* ── Step Progress Bar ── */
#ln-step-bar {
    display: flex;
    flex-shrink: 0;
    border-bottom: 1px solid rgba(0,0,0,.07);
}

.ln-step {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 7px 4px;
    font-size: 9px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: #aaa;
    background: #f9f9f9;
    border-bottom: 2px solid transparent;
    transition: all .2s;
    cursor: default;
}

.ln-step-active {
    color: #fff;
    background: #25D366;
    border-bottom-color: #C9A84C;
}

.ln-step-done {
    color: #fff;
    background: #1aad52;
    border-bottom-color: #1aad52;
}

.ln-step-num {
    font-size: 9px;
    font-weight: 900;
    line-height: 1;
}

.ln-step-done .ln-step-num::before {
    content: "✓";
}
.ln-step-done .ln-step-label { display: none; }

/* ── Chat Body ── */
#ln-chat-body {
    flex: 1;
    overflow-y: auto;
    background: #ECE5DD;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 0;
}

#ln-chat-body::-webkit-scrollbar { width: 3px; }
#ln-chat-body::-webkit-scrollbar-thumb { background: #bbb; border-radius: 4px; }

/* ── Bot Bubble ── */
.ln-bot-bubble {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.ln-bot-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    margin-top: 2px;
}

.ln-bot-msg {
    background: #fff;
    border-radius: 0 12px 12px 12px;
    padding: 9px 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,.1);
    max-width: 85%;
}

.ln-bot-msg p {
    font-size: 12px;
    color: #1c1c1c;
    line-height: 1.5;
    margin: 0;
}

/* ── White Card (form, products) ── */
.ln-card {
    background: #fff;
    border-radius: 12px;
    padding: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
    margin-left: 36px;
}

/* ── Form Fields ── */
.leadnest-field {
    margin-bottom: 12px;
}

.leadnest-field label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    color: #666;
    margin-bottom: 5px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.leadnest-field .req { color: #e74c3c; }

.leadnest-field input {
    width: 100%;
    padding: 9px 11px;
    border: 2px solid #e8e8e8;
    border-radius: 8px;
    font-size: 12px;
    color: #1c1c1c;
    outline: none;
    transition: border-color 0.2s;
    box-sizing: border-box;
    background: #fff;
}

.leadnest-field input:focus {
    border-color: #25D366;
}

.leadnest-field input.leadnest-error {
    border-color: #e74c3c;
}

/* ── Field Description ── */
.leadnest-field-desc {
    margin: 3px 0 0;
    font-size: 10px;
    color: #999;
}

/* ── Form Message ── */
#leadnest-form-msg {
    font-size: 11px;
    margin-top: 8px;
    padding: 7px 10px;
    border-radius: 6px;
    display: none;
}
#leadnest-form-msg.leadnest-msg-error   { background: #fdecea; color: #c0392b; display: block; }
#leadnest-form-msg.leadnest-msg-success { background: #eafaf1; color: #1e8449; display: block; }

/* ── Products Container ── */
#ln-products-container {
    margin-left: 36px;
    background: #fff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,.08);
}

.leadnest-product-search {
    width: 100%;
    padding: 9px 12px;
    border: none;
    border-bottom: 1px solid #eee;
    font-size: 12px;
    color: #333;
    outline: none;
    box-sizing: border-box;
    background: #fafafa;
}

.leadnest-product-list {
    max-height: 200px;
    overflow-y: auto;
    padding: 4px;
}

.leadnest-product-list::-webkit-scrollbar { width: 3px; }
.leadnest-product-list::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

.ln-product-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}
.ln-product-item:hover { background: #f0fdf4; }
.ln-product-item input[type="checkbox"] { width: 14px; height: 14px; flex-shrink: 0; accent-color: #25D366; cursor: pointer; }

.ln-prod-img {
    width: 34px;
    height: 34px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
}
.ln-prod-img-placeholder { display: inline-block; background: #e8e8e8; }
.ln-prod-name  { flex: 1; font-size: 12px; font-weight: 500; color: #1c1c1c; line-height: 1.3; }
.ln-prod-price { font-size: 11px; font-weight: 700; color: #25D366; flex-shrink: 0; }

/* ── Payment Options ── */
.ln-payment-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.ln-payment-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border: 2px solid #e8e8e8;
    border-radius: 8px;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.ln-payment-option:hover {
    border-color: #25D366;
    background: #f0fdf4;
}

.ln-payment-option input[type="radio"] {
    width: 15px;
    height: 15px;
    flex-shrink: 0;
    accent-color: #25D366;
    cursor: pointer;
}

.ln-payment-option:has(input:checked) {
    border-color: #25D366;
    background: #f0fdf4;
}

.ln-payment-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.ln-payment-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.ln-payment-title {
    font-size: 12px;
    font-weight: 700;
    color: #1c1c1c;
}

.ln-payment-desc {
    font-size: 10px;
    color: #888;
}

/* Inner wrapper — fills popup so overlay can cover it */
#leadnest-popup-inner {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* ── PayPal Modal Overlay ── */
#ln-paypal-modal {
    position: absolute;
    inset: 0;
    background: #fff;
    z-index: 200;
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ln-paypal-modal-header {
    background: #003087;
    padding: 13px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.ln-paypal-modal-title {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ln-paypal-modal-amount {
    font-size: 13px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 0.02em;
}

.ln-paypal-modal-close {
    background: rgba(255,255,255,.15);
    border: none;
    color: #fff;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0;
    transition: background 0.15s;
}
.ln-paypal-modal-close:hover { background: rgba(255,255,255,.3); }

.ln-paypal-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.ln-paypal-note {
    font-size: 11px;
    color: #888;
    text-align: center;
    margin: 12px 0;
}

.ln-paypal-error {
    font-size: 11px;
    color: #e74c3c;
    text-align: center;
    margin: 10px 0;
}

.ln-paypal-success {
    font-size: 13px;
    font-weight: 600;
    color: #1e8449;
    background: #eafaf1;
    border-radius: 8px;
    padding: 14px 12px;
    text-align: center;
    margin: 8px 0;
}

/* ── Footer ── */
#ln-footer {
    background: #fff;
    border-top: 1px solid #f0f0f0;
    padding: 10px 12px;
    flex-shrink: 0;
}

.ln-footer-panel { display: flex; flex-direction: column; gap: 6px; }
.ln-footer-row   { flex-direction: row !important; gap: 8px !important; }

/* Submit Button */
.ln-submit-btn {
    flex: 1;
    padding: 11px 14px;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    text-transform: uppercase;
    letter-spacing: .04em;
    transition: opacity 0.2s, transform 0.1s;
}
.ln-submit-btn:hover   { opacity: .9; }
.ln-submit-btn:active  { transform: scale(.98); }
.ln-submit-btn:disabled{ opacity: .55; cursor: not-allowed; }

/* Continue button (same style as submit) */
.ln-btn-primary {
    width: 100%;
    padding: 11px 14px;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: .04em;
    transition: opacity 0.2s;
}
.ln-btn-primary:hover { opacity: .9; }

/* Ghost / secondary button */
.ln-btn-ghost {
    padding: 10px 14px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    background: #fff;
    color: #666;
    font-size: 11px;
    font-weight: 700;
    cursor: pointer;
    transition: border-color .2s, color .2s;
}
.ln-btn-ghost:hover    { border-color: #aaa; color: #333; }
.ln-btn-full           { width: 100%; }

/* ── RTL Support ── */
#leadnest-popup[dir="rtl"] { direction: rtl; text-align: right; }
#leadnest-popup[dir="rtl"] .leadnest-field label { text-align: right; }
#leadnest-popup[dir="rtl"] .leadnest-field input { text-align: right; direction: rtl; }
#leadnest-popup[dir="rtl"] #leadnest-popup-header { flex-direction: row-reverse; }
#leadnest-popup[dir="rtl"] #leadnest-close-btn { margin-left: 0; margin-right: auto; }
#leadnest-popup[dir="rtl"] .ln-bot-bubble { flex-direction: row-reverse; }
#leadnest-popup[dir="rtl"] .ln-bot-msg { border-radius: 12px 0 12px 12px; }
#leadnest-popup[dir="rtl"] .ln-card { margin-left: 0; margin-right: 36px; }
#leadnest-popup[dir="rtl"] #ln-products-container { margin-left: 0; margin-right: 36px; }
#leadnest-popup[dir="rtl"] .ln-product-item { flex-direction: row-reverse; }
#leadnest-popup[dir="rtl"] .leadnest-product-search { text-align: right; direction: rtl; }

/* ── White Label: Brand in Header ── */
.leadnest-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
    flex: 1;
    min-width: 0;
}

.leadnest-header-brand-logo {
    max-height: 32px;
    max-width: 80px;
    object-fit: contain;
    flex-shrink: 0;
    border-radius: 3px;
}

.leadnest-header-titles {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.leadnest-header-brand-name {
    font-size: 10px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.8);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    line-height: 1.2;
}

#leadnest-popup-title {
    font-size: 14px;
    font-weight: 600;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ── White Label: Powered By Footer ── */
.leadnest-powered-by {
    text-align: center;
    padding: 8px 16px;
    font-size: 11px;
    color: #94a3b8;
    border-top: 1px solid #f1f5f9;
    margin-top: 4px;
}

.leadnest-powered-by a {
    color: #25D366;
    text-decoration: none;
}

.leadnest-powered-by a:hover {
    text-decoration: underline;
}

/* ── Responsive ── */
@media (max-width: 400px) {
    #leadnest-popup {
        width: calc(100vw - 32px);
        right: 16px;
        bottom: 88px;
    }

    #leadnest-wa-btn {
        width: 52px;
        height: 52px;
        right: 16px;
        bottom: 16px;
    }
}
