/* BioCode Smart Chat Widget Styles */
:root {
    --biocode-primary: #00A99D;
    --biocode-primary-dark: #008f85;
    --biocode-secondary: #1e293b;
    --biocode-light: #f8fafc;
    --biocode-white: #ffffff;
    --biocode-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --biocode-pulse: rgba(0, 169, 157, 0.2);
    
    /* Dynamic Overrides (Injected via PHP) */
    --biocode-theme: var(--biocode-primary);
    --biocode-btn: var(--biocode-primary);
    --biocode-btn-radius: 10px;
}

#biocode-chat-widget-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* Floating Icon */
.biocode-chat-trigger {
    width: 60px;
    height: 60px;
    background: var(--biocode-theme);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--biocode-shadow);
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
}

.biocode-chat-trigger:hover {
    transform: scale(1.1);
    background: var(--biocode-primary-dark);
}

.biocode-chat-trigger svg {
    width: 30px;
    height: 30px;
    fill: var(--biocode-white);
}

/* Pulse Animation */
.biocode-chat-trigger::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background: var(--biocode-primary);
    z-index: -1;
    animation: biocode-pulse 2s infinite;
}

@keyframes biocode-pulse {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* Chat Window */
.biocode-chat-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 600px;
    max-height: calc(100vh - 120px);
    background: var(--biocode-white);
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.biocode-chat-window.active {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

/* Minimized state REMOVED - window is either fully open or fully hidden */

/* Header */
.biocode-chat-header {
    background: var(--biocode-theme);
    padding: 20px;
    color: var(--biocode-white);
    display: flex;
    align-items: center;
    gap: 12px;
}

.biocode-chat-header img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--biocode-white);
    padding: 5px;
}

.biocode-chat-header-info h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.biocode-chat-header-info span {
    font-size: 12px;
    opacity: 0.9;
}

/* Forms & Inputs */
.biocode-chat-body {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: var(--biocode-light);
}

.biocode-lead-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.biocode-lead-form h3 {
    margin: 0 0 5px 0;
    color: var(--biocode-secondary);
    font-size: 18px;
}

.biocode-lead-form p {
    margin: 0;
    font-size: 14px;
    color: #64748b;
    line-height: 1.5;
}

.biocode-input-group {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.biocode-input-group label {
    font-size: 12px;
    font-weight: 600;
    color: var(--biocode-secondary);
}

.biocode-input-group input, 
.biocode-input-group select,
.biocode-input-group textarea {
    padding: 12px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.biocode-input-group input:focus,
.biocode-input-group select:focus,
.biocode-input-group textarea:focus {
    border-color: var(--biocode-primary);
}

/* intl-tel-input integration - High Specificity for Version 24+ */
#biocode-chat-widget-container .iti { width: 100%; margin-top: 5px; }
#biocode-chat-widget-container .iti__country-list { 
    border-radius: 12px; 
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1); 
    border: 1px solid #e2e8f0;
    max-width: 280px !important;
    z-index: 999999;
    background: #fff;
}
#biocode-chat-widget-container .iti__search-input {
    width: 100% !important;
    padding: 10px !important;
    border: 1px solid #e2e8f0 !important;
    border-radius: 6px !important;
    font-size: 13px !important;
}
#biocode-chat-widget-container .iti__a11y-text {
    display: none !important;
}
#biocode-chat-widget-container .iti__selected-flag { 
    background: #f8fafc !important; 
    border-radius: 8px 0 0 8px;
    padding: 0 10px !important;
}
#biocode-chat-widget-container .iti__dial-code { font-size: 13px; color: #64748b; }

/* ── PERMANENT PIXEL-PERFECT FIX: intl-tel-input (v24.5.0) ── */
#biocode-chat-widget-container .iti {
    width: 100% !important;
    display: block !important;
    margin-top: 5px;
    position: relative !important;
}

/* Fix: Flag Bleed (Match 16px width of v24.5.0 sprite) */
#biocode-chat-widget-container .iti__flag {
    background-image: url("flags.png") !important;
    background-repeat: no-repeat !important;
    background-size: 3904px 12px !important;
    width: 16px !important; /* PRECISION MATCH for 3904/244 flags */
    height: 12px !important;
    display: inline-block !important;
    
    /* Secondary Safety: Mask the right-side bleed */
    clip-path: inset(0 0 0 0) !important;
    -webkit-clip-path: inset(0 0 0 0) !important;
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    #biocode-chat-widget-container .iti__flag {
        background-image: url("flags@2x.png") !important;
        background-size: 3904px 12px !important;
    }
}

/* Fix: Separate Dial Code Overlap & Layout */
#biocode-chat-widget-container .iti--separate-dial-code .iti__selected-flag {
    background-color: #f8fafc !important;
    border-right: 1px solid #e2e8f0 !important;
    border-radius: 8px 0 0 8px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 4px !important;
    width: 85px !important; /* Fixed width for flag + code area */
    height: 100% !important;
}

#biocode-chat-widget-container .iti--separate-dial-code input {
    padding-left: 95px !important; /* CRITICAL: Must be > selected-flag width to prevent overlap */
    width: 100% !important;
}

/* Dropdown & Search Polish */
#biocode-chat-widget-container .iti__country-list {
    z-index: 100 !important;
    max-width: 320px !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1) !important;
}

#biocode-chat-widget-container .iti__search-input {
    width: 100% !important;
    padding: 10px !important;
    border: none !important;
    border-bottom: 1px solid #e2e8f0 !important;
    outline: none !important;
}

#biocode-chat-widget-container .iti__country-name {
    font-size: 13px !important;
}

@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    #biocode-chat-widget-container .iti__flag {
        background-image: url("https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/24.2.0/img/flags@2x.png") !important;
    }
}

.biocode-start-chat-btn {
    background: var(--biocode-btn);
    color: var(--biocode-white);
    border: none;
    padding: 14px;
    border-radius: var(--biocode-btn-radius);
    font-weight: 600;
    cursor: pointer;
    margin-top: 10px;
    transition: background 0.2s;
}

/* Messages Container */
.biocode-messages-container {
    display: flex;
    flex-direction: column;
    height: 440px;
    padding-bottom: 20px;
}

.biocode-msg-bubble {
    width: 100%;
}

/* Animations */
@keyframes biocode-slide-in {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.biocode-msg-bubble > div {
    animation: biocode-slide-in 0.3s ease-out forwards;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    background: #cbd5e1;
    border-radius: 50%;
    animation: typing 1s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 100% { transform: scale(0.6); opacity: 0.4; }
    50% { transform: scale(1.1); opacity: 1; }
}

.biocode-typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
    height: 14px;
}

.biocode-typing-dots span {
    width: 6px;
    height: 6px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typing 1s infinite ease-in-out;
}

.biocode-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.biocode-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

/* ── Payment Modal (Premium Redesign) ────────────────────────── */
.biocode-pay-modal {
    position: fixed;
    top: 0; left: 0; 
    width: 100vw; height: 100vh;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center; 
    justify-content: center;
    z-index: 1000000;
    animation: biocodeFadeIn 0.3s ease;
}

.biocode-pay-modal-content {
    background: #fff;
    width: 95%;
    max-width: 600px;
    border-radius: 20px;
    position: relative;
    max-height: 90vh;
    overflow: hidden;
    padding: 0;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    animation: biocode-slide-up 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.biocode-pay-header {
    background: var(--biocode-primary, #00A99D);
    color: #fff;
    padding: 20px 25px;
    display: flex; 
    justify-content: space-between; 
    align-items: center;
}

.biocode-pay-body {
    padding: 25px;
    overflow-y: auto;
    background: #fff;
}

/* Section Labels (Image 1 Style) */
.biocode-pay-section-label {
    font-size: 13px;
    font-weight: 700;
    color: #1e293b;
    margin-bottom: 15px;
    margin-top: 5px;
}

/* User Info Grid */
.biocode-pay-user-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin-bottom: 10px;
}

/* Advanced Stripe Field Styling */
.biocode-pay-field {
    margin-bottom: 20px;
}

.biocode-pay-field label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 8px;
}

.biocode-pay-field input {
    width: 100%;
    padding: 12px 15px;
    background: #f8fafc;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    color: #1e293b;
    outline: none;
    transition: all 0.2s;
}

.biocode-pay-field input:focus {
    background: #f1f5f9;
    box-shadow: inset 0 0 0 1px #e2e8f0;
}

/* Stripe Wrapper matching inputs */
.biocode-stripe-input-wrapper {
    position: relative;
    background: #f8fafc;
    border-radius: 10px;
    padding: 12px 15px;
    min-height: 44px;
}

.biocode-autofill-badge {
    position: absolute;
    right: 40px;
    top: 50%;
    transform: translateY(-50%);
    background: #fff;
    border: 1px solid #e2e8f0;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 11px;
    color: #64748b;
    display: flex;
    align-items: center;
    pointer-events: none;
}

.biocode-field-help {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    background: #1e293b;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    cursor: pointer;
    font-weight: 700;
}

/* Modern Pay Button */
.biocode-pay-btn-modern {
    width: 100%;
    background: #00A99D;
    color: #fff;
    border: none;
    padding: 18px;
    border-radius: 15px;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    margin-bottom: 20px;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(0, 169, 157, 0.2), 0 2px 4px -1px rgba(0, 169, 157, 0.1);
}

.biocode-pay-btn-modern:hover {
    background: #00968b;
    transform: translateY(-1px);
    box-shadow: 0 10px 15px -3px rgba(0, 169, 157, 0.3);
}

.biocode-pay-btn-modern:active {
    transform: translateY(0);
}

.biocode-pay-footer {
    display: flex;
    justify-content: center;
    gap: 15px;
    font-size: 11px;
    color: #94a3b8;
    padding-top: 10px;
    border-top: 1px solid #f1f5f9;
}

.biocode-pay-input-container div {
    flex: 1;
}

/* Tooltips */
.biocode-pay-tooltip-trigger {
    position: relative;
    margin-left: 10px;
    cursor: help;
}

.biocode-pay-help-icon {
    width: 18px;
    height: 18px;
    background: #cbd5e1;
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: bold;
}

.biocode-pay-tooltip-content {
    position: absolute;
    bottom: calc(100% + 15px);
    right: -10px;
    width: 220px;
    background: #fff;
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.15);
    display: none;
    z-index: 10000;
    text-align: center;
    border: 1px solid #e2e8f0;
}

.biocode-pay-tooltip-content::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 14px;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #fff;
}

.biocode-pay-tooltip-trigger:hover .biocode-pay-tooltip-content {
    display: block;
}

.biocode-pay-tooltip-content img {
    width: 100%;
    border-radius: 8px;
    margin-bottom: 10px;
}

.biocode-pay-tooltip-content p {
    font-size: 11px;
    color: #64748b;
    margin: 0;
    line-height: 1.4;
}

/* Course Card / Summary */
.biocode-pay-course-card {
    background: #f0fdfa;
    border: 1px solid #ccfbf1;
    border-radius: 16px;
    padding: 16px;
    margin-bottom: 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.biocode-pay-badge {
    background: #14b8a6;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 99px;
}

.price-text-label {
    font-size: 12px;
    color: #0d9488;
    font-weight: 600;
    margin-bottom: 2px;
    text-align: right;
}

.price-values {
    display: flex;
    align-items: baseline;
    gap: 8px;
    justify-content: flex-end;
}

.original-price {
    text-decoration: line-through;
    color: #94a3b8;
    font-size: 13px;
}

.sale-price {
    color: #1e293b;
    font-size: 22px;
    font-weight: 800;
}

/* Coupon System */
.biocode-pay-coupon-wrapper {
    margin-bottom: 24px;
}

.biocode-pay-coupon-input-group {
    display: flex;
    gap: 8px;
}

.biocode-pay-coupon-input-group input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 13px;
    outline: none;
    transition: all 0.2s;
}

.biocode-pay-coupon-input-group input:focus {
    border-color: #00A99D;
    box-shadow: 0 0 0 3px rgba(0, 169, 157, 0.1);
}

#biocode-apply-coupon-btn {
    background: #1e293b;
    color: #fff;
    border: none;
    border-radius: 10px;
    padding: 0 16px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
}

#biocode-apply-coupon-btn:hover { background: #0f172a; }

/* Payment Elements */
.biocode-stripe-wrapper {
    margin-bottom: 24px;
}

#biocode-card-element {
    padding: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #fff;
    transition: all 0.2s;
}

#biocode-card-element--focus {
    border-color: #00A99D;
    box-shadow: 0 0 0 3px rgba(0, 169, 157, 0.1);
}

/* Submit Button */
#biocode-submit-payment {
    width: 100%;
    background: var(--biocode-btn);
    color: #fff;
    border: none;
    padding: 18px;
    border-radius: var(--biocode-btn-radius);
    font-weight: 700;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 169, 157, 0.25);
}

#biocode-submit-payment:hover {
    background: #008f84;
    transform: translateY(-2px);
    box-shadow: 0 12px 20px rgba(0, 169, 157, 0.35);
}

#biocode-submit-payment:active { transform: translateY(0); }

#biocode-submit-payment:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* Footer Notes */
.biocode-pay-footer-notes {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 20px;
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
}

.dot-separator { font-size: 8px; color: #e2e8f0; }

#biocode-card-errors {
    color: #ef4444; font-size: 12px; margin-top: 10px; text-align: center; font-weight: 600;
}

.biocode-buy-now-btn {
    background: var(--biocode-btn);
    color: #fff;
    border: none;
    padding: 10px 20px;
    border-radius: var(--biocode-btn-radius);
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    margin-top: 12px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.biocode-buy-now-btn:hover {
    background: #4f46e5;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

/* =====================================================
 * CHAT AVATAR - ensure circle display
 * ===================================================== */
.biocode-chat-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* =====================================================
 * MOBILE RESPONSIVE
 * ===================================================== */
@media (max-width: 480px) {
    #biocode-chat-widget-container {
        bottom: 12px;
        right: 12px;
    }

    .biocode-chat-window {
        position: fixed;
        bottom: 0 !important;
        right: 0 !important;
        left: 0 !important;
        top: 0 !important;
        width: 100vw !important;
        max-width: 100vw !important;
        height: 100vh !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
        transform: translateY(100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
    }

    .biocode-chat-window.active {
        transform: translateY(0) !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    .biocode-chat-trigger {
        width: 52px;
        height: 52px;
    }

    .biocode-messages-container {
        height: calc(100vh - 200px);
    }

    /* Prevent payment modal overflow on mobile */
    .biocode-pay-container {
        width: 95%;
        max-height: 90vh;
        overflow-y: auto;
    }
}

@media (min-width: 481px) and (max-width: 600px) {
    .biocode-chat-window {
        width: calc(100vw - 20px) !important;
        right: 10px !important;
    }
}

/* =====================================================
 * END CHAT MODAL
 * ===================================================== */
.biocode-end-chat-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10005;
    animation: biocodeFadeIn 0.3s ease;
}

.biocode-end-chat-modal-content {
    background: #fff;
    padding: 30px;
    border-radius: 20px;
    width: 90%;
    max-width: 340px;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

@keyframes biocodeFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}
/* ── Advanced Checkout & Multi-Course Styles ───────────────── */
.biocode-pay-course-list {
    margin: 15px 0;
}

.biocode-pay-course-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px 15px;
    margin-bottom: 10px;
}

.biocode-pay-course-info {
    flex: 1;
}

.biocode-pay-course-title {
    font-weight: 700;
    color: #1e293b;
    font-size: 14px;
}

.biocode-pay-course-price {
    font-size: 12px;
    color: #64748b;
    margin-top: 2px;
}

.biocode-remove-course {
    color: #94a3b8;
    cursor: pointer;
    font-size: 20px;
    padding: 5px;
    line-height: 1;
    transition: all 0.2s;
}

.biocode-remove-course:hover {
    color: #ef4444;
    transform: scale(1.1);
}

.biocode-stripe-custom-wrapper {
    margin-top: 15px;
}

.biocode-pay-field label {
    display: block;
    font-size: 11px;
    font-weight: 700;
    color: #64748b;
    text-transform: uppercase;
    margin-bottom: 8px;
    letter-spacing: 0.5px;
}

.biocode-input-with-icon {
    position: relative;
    display: flex;
    align-items: center;
}

.biocode-input-with-icon div[id$="-element"] {
    flex: 1;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 14px;
    min-height: 48px;
    box-sizing: border-box;
}

.stripe-help-icon {
    position: absolute;
    right: 15px;
    width: 18px;
    height: 18px;
    border: 1.5px solid #cbd5e1;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: #94a3b8;
    font-weight: 800;
    cursor: help;
}

#biocode-submit-payment {
    width: 100%;
    background: #00A99D;
    color: #fff;
    border: none;
    border-radius: 14px;
    padding: 18px;
    font-size: 16px;
    font-weight: 800;
    cursor: pointer;
    margin-top: 30px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0, 169, 157, 0.2);
}

#biocode-submit-payment:hover {
    background: #008f84;
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 169, 157, 0.3);
}

#biocode-pay-total-amount {
    font-weight: 900;
    padding: 0 4px;
}
