/* ==============================================
   Live Chat Widget Styles
   All classes prefixed with mlc_ to avoid conflicts
   ============================================== */
   
@import url('https://fonts.googleapis.com/css2?family=Montserrat:ital,wght@0,100..900;1,100..900&family=Nunito:ital,wght@0,200..1000;1,200..1000&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&family=Work+Sans:ital,wght@0,100..900;1,100..900&display=swap');
   
   

/* Reset and Base Styles for Chat Components */
.mlc_chat-button,
.mlc_chat-window,
.mlc_chat-window * {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Utility Classes */
.mlc_hidden {
    display: none !important;
}

/* Chat Button (Floating Action Button) */
.mlc_chat-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: auto;
    height: auto;
    border-radius: 0;
    background: #3B82F6;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 9998;
    outline: none;
    padding: 14px 24px;
    font-size: 15px;
    font-weight: 600;
    color: #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    letter-spacing: 0.3px;
    overflow: visible;
}

.mlc_chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.mlc_chat-button:active {
    transform: scale(0.95);
}

/* When chat is open, switch back to round icon button */
.mlc_chat-button.mlc_is-open {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    padding: 0;
    font-size: 0;
}

.mlc_chat-icon,
.mlc_close-icon {
    width: 28px;
    height: 28px;
    color: #ffffff;
    transition: all 0.3s ease;
}

/* Notification Badge */
.mlc_notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ff4757;
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 2px solid #ffffff;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}


/* Online pulsating dot on chat button */
.mlc_online-dot {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 12px;
    height: 12px;
    background: #2ecc71;
    border-radius: 50%;
    border: 2px solid #ffffff;
    animation: mlc_online-pulse 2s ease-in-out infinite;
}

.mlc_chat-button.mlc_is-open .mlc_online-dot {
    display: none;
}

@keyframes mlc_online-pulse {
    0%, 100% { transform: scale(1);   opacity: 1; }
    50%       { transform: scale(1.4); opacity: 0.6; }
}


/* Chat Window */
.mlc_chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    max-width: calc(100vw - 48px);
    height: 600px;
    max-height: calc(100vh - 140px);
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    display: flex;
    flex-direction: column;
    z-index: 99999;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    animation: mlc_slideUp 0.3s ease;
}

@keyframes mlc_slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Header */
.mlc_chat-header {
    background: #3B82F6;
    color: #ffffff;
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.mlc_header-content {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.mlc_avatar {
    width: 44px;
    height: 44px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mlc_avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.mlc_avatar svg {
    width: 28px;
    height: 28px;
    color: #ffffff;
}

.mlc_header-info {
    flex: 1;
}

.mlc_header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mlc_header-title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 0px;
    color: #fff!important;
}

.mlc_header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    opacity: 0.9;
    margin-top: -15px;
}

.mlc_status-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #2ecc71;
    animation: mlc_pulse 2s ease-in-out infinite;
}

.mlc_status-indicator.mlc_online {
    background: #2ecc71;
}

.mlc_status-indicator.mlc_offline {
    background: #95a5a6;
}

@keyframes mlc_pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.mlc_notification-toggle {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    outline: none;
}

.mlc_notification-toggle:hover {
    background: rgba(255, 255, 255, 0.3);
}

.mlc_notification-toggle svg {
    width: 18px;
    height: 18px;
    color: #ffffff;
}

.mlc_minimize-button {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease;
    outline: none;
}

.mlc_minimize-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.mlc_minimize-button svg {
    width: 20px;
    height: 20px;
    color: #ffffff;
}

/* Chat Messages Area */
.mlc_chat-messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px;
    background: #f7f9fc;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Critical for flex child scrolling */
}

/* Messages wrapper */
.mlc_messages-wrapper {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.mlc_chat-messages::-webkit-scrollbar {
    width: 6px;
}

.mlc_chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.mlc_chat-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.mlc_chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Message Styles */
.mlc_message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: mlc_fadeIn 0.3s ease;
}

@keyframes mlc_fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.mlc_message-received {
    align-self: flex-start;
}

.mlc_message-sent {
    align-self: flex-end;
}

.mlc_message-content {
    padding: 12px 16px;
    border-radius: 12px;
    word-wrap: break-word;
}

.mlc_message-received .mlc_message-content {
    background: #ffffff;
    color: #2d3748;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
}

.mlc_message-sent .mlc_message-content {
    background: #3B82F6;
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.mlc_message-content p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    font-family: "Work Sans", sans-serif!important;
}

.mlc_message-time {
    font-size: 11px;
    color: #718096;
    margin-top: 4px;
    padding: 0 4px;
}

.mlc_message-received .mlc_message-time {
    align-self: flex-start;
}

.mlc_message-sent .mlc_message-time {
    align-self: flex-end;
}

/* Read Receipt */
.mlc_read-receipt {
    font-size: 10px;
    color: #a0aec0;
    margin-top: 2px;
    padding: 0 4px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.mlc_message-sent .mlc_read-receipt {
    align-self: flex-end;
}

.mlc_read-receipt.mlc_delivered {
    color: #a0aec0;
}

.mlc_read-receipt.mlc_read {
    color: #667eea;
}

/* Typing Indicator */
.mlc_typing-indicator {
    padding: 12px 20px;
    background: #f7f9fc;
    display: flex;
    align-items: center;
    gap: 8px;
    border-top: 1px solid #e2e8f0;
}

.mlc_typing-dots {
    display: flex;
    gap: 4px;
}

.mlc_typing-dots span {
    width: 8px;
    height: 8px;
    background: #cbd5e0;
    border-radius: 50%;
    animation: mlc_typingDot 1.4s infinite;
}

.mlc_typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.mlc_typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes mlc_typingDot {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-8px);
    }
}

.mlc_typing-text {
    font-size: 13px;
    color: #718096;
    font-style: italic;
}

/* Chat Input Container */
.mlc_chat-input-container {
    padding: 16px 20px;
    background: #ffffff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
    position: relative;
}

/* Emoji Picker */
.mlc_emoji-picker {
    position: absolute;
    bottom: 100%;
    left: 20px;
    right: 20px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.1);
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 8px;
    z-index: 10;
}

.mlc_emoji-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 8px;
}

.mlc_emoji-btn {
    background: transparent;
    border: none;
    font-size: 24px;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s ease;
    outline: none;
}

.mlc_emoji-btn:hover {
    background: #f7f9fc;
}

.mlc_emoji-btn:active {
    transform: scale(0.9);
}

.mlc_emoji-picker::-webkit-scrollbar {
    width: 6px;
}

.mlc_emoji-picker::-webkit-scrollbar-track {
    background: transparent;
}

.mlc_emoji-picker::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.mlc_chat-form {
    display: flex;
    align-items: center;
    gap: 8px;
}

.mlc_emoji-toggle {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s ease;
    outline: none;
    flex-shrink: 0;
}

.mlc_emoji-toggle:hover {
    background: #f7f9fc;
}

.mlc_emoji-toggle svg {
    width: 20px;
    height: 20px;
    color: #718096;
}

.mlc_attachment-button {
    width: 36px;
    height: 36px;
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s ease;
    outline: none;
    flex-shrink: 0;
}

.mlc_attachment-button:hover {
    background: #f7f9fc;
}

.mlc_attachment-button svg {
    width: 20px;
    height: 20px;
    color: #718096;
}

.mlc_message-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    font-size: 18px;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s ease;
}

.mlc_message-input:focus {
    border-color: #667eea;
}

.mlc_message-input::placeholder {
    color: #a0aec0;
}

.mlc_send-button {
    width: 36px;
    height: 36px;
    background: #3B82F6;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    outline: none;
    flex-shrink: 0;
}

.mlc_send-button:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.mlc_send-button:active {
    transform: scale(0.95);
}

.mlc_send-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.mlc_send-button svg {
    width: 18px;
    height: 18px;
    color: #ffffff;
}

/* Chat Footer */
.mlc_chat-footer {
    padding: 10px 20px;
    background: #f7f9fc;
    border-top: 1px solid #e2e8f0;
    text-align: center;
    font-size: 12px;
    color: #718096;
    flex-shrink: 0;
}

.mlc_chat-footer strong {
    color: #667eea;
}

/* Responsive Design */
@media (max-width: 480px) {

    /* ── Chat window ─────────────────────────────────────────────────────
       JS writes style.top and style.height from visualViewport so the
       window always fits exactly in the visible space above the keyboard.
       We set position/width here; height is intentionally left to JS.    */
    .mlc_chat-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        max-height: none;   /* let JS control height freely */
        border-radius: 0;
        overscroll-behavior: contain; /* FIX 2: no scroll escape */
    }

    .mlc_chat-button {
        bottom: 20px;
        right: 20px;
        width: 156px;
        height: 46px;
    }

    .mlc_message {
        max-width: 85%;
    }

    /* ── Messages area ───────────────────────────────────────────────────
       Only this element scrolls. overscroll-behavior-y:contain stops
       rubber-band / over-scroll from propagating to the page underneath. */
    .mlc_chat-messages {
        flex: 1;
        min-height: 0;                     /* must shrink inside flex column  */
        overflow-y: scroll;                /* always-on track avoids reflow   */
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch; /* momentum scroll on iOS Safari   */
        overscroll-behavior-y: contain;    /* FIX 2: scroll stays inside chat */
        display: flex;
        flex-direction: column;
    }

    /* Wrapper: grows so messages stack top-down */
    .mlc_chat-messages .mlc_messages-wrapper {
        flex: 1 0 auto;
        justify-content: flex-start;
    }

    /* These sections must never shrink or scroll off-screen */
    .mlc_chat-header,
    .mlc_chat-input-container,
    .mlc_chat-footer,
    .mlc_typing-indicator {
        flex-shrink: 0;
    }
}

/* Print styles - hide chat widget when printing */
@media print {
    .mlc_chat-button,
    .mlc_chat-window {
        display: none !important;
    }
}
/* Applied to <body> while the chat is open on mobile to hard-stop
   any scroll that slips past the touchmove handler (e.g. inertia
   scroll already in flight when the touch started).               */
body.mlc_chat-open-mobile {
    overflow: hidden;
    position: fixed;
    width: 100%;
}