/* Chat Widget Container */
.ma-widget {
    position: fixed !important;
    z-index: 9999 !important;
    bottom: 1.25rem !important; /* 20px converted to rem */
    font-family: 'Poppins', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    display: none !important;
}
#ma-chat-v2-popup, #ma-chatbot-v2-widget{z-index:1000000 !important;}
/* Override for visible state */
.ma-widget[style*="display: block"] {
    display: block !important;
}

/* Responsive Design */
@media screen and (max-width: 480px) {
    .ma-widget {
        bottom: 0.625rem !important; /* 10px */
        position: fixed !important;
        z-index: 9999 !important;
    }
    
    .ma-widget.bottom-right {
        right: 0.625rem !important; /* 10px */
    }
    
    .ma-widget.bottom-left {
        left: 0.625rem !important; /* 10px */
    }
    
    .chat-popup {
        width: calc(100vw - 1.25rem) !important; /* 20px margin */
        max-width: 100vw !important;
        height: calc(100vh - 5rem) !important; /* 80px */
        max-height: calc(100vh - 1.25rem) !important; /* 20px */
        bottom: 5rem !important; /* 80px */
        left: 0.625rem !important; /* 10px */
        right: 0.625rem !important; /* 10px */
        margin: 0 auto !important;
        position: fixed !important;
        transform: none !important; /* Prevent transform issues with zoom */
    }
    
    .chat-toggle {
        width: 3.125rem !important; /* 50px */
        height: 3.125rem !important; /* 50px */
        min-width: 3.125rem !important;
        min-height: 3.125rem !important;
    }

    .chat-input input {
        font-size: 16px !important; /* Prevent zoom on iOS */
    }

    .user-info-form input {
        font-size: 16px !important; /* Prevent zoom on iOS */
    }
}

/* Additional responsive breakpoints */
@media screen and (min-width: 481px) and (max-width: 768px) {
    .chat-popup {
        width: 90vw !important;
        max-width: 25rem !important; /* 400px */
        height: 80vh !important;
        max-height: 37.5rem !important; /* 600px */
        bottom: 5.625rem !important; /* 90px */
    }
}

@media screen and (max-height: 600px) {
    .chat-popup {
        height: calc(100vh - 6.25rem) !important; /* 100px */
        bottom: 5rem !important; /* 80px */
    }
}

/* Modern touch-device & viewport optimizations */
@media (hover: none) and (pointer: coarse) {
    /* Larger touch targets */
    .chat-toggle {
        width: 3.75rem !important;  /* 60px */
        height: 3.75rem !important; /* 60px */
    }

    .chat-input input,
    .user-info-form input {
        min-height: 2.75rem !important; /* 44px – iOS recommended */
        font-size: 1rem !important;      /* Prevent viewport zoom */
    }
}

/* Viewport-based sizing for extreme zoom and dynamic browser chrome */
@media screen and (max-width: 480px),
       screen and (max-height: 600px) {
    .chat-popup {
        width: calc(100vw - 1.25rem) !important;
        height: calc(100dvh - 5rem) !important;
        max-height: calc(100dvh - 1.25rem) !important;
        bottom: clamp(4rem, 10vh, 5rem) !important;
    }
}

.ma-widget.bottom-right {
    right: 1.25rem; /* 20px */
}

.ma-widget.bottom-left {
    left: 1.25rem; /* 20px */
}

/* Chat Toggle Button */
.chat-toggle {
    width: 3.75rem !important; /* 60px */
    height: 3.75rem !important; /* 60px */
    border-radius: 50% !important;
    background-color: #29ABE2 !important;
    border: none !important;
    cursor: pointer !important;
    box-shadow: 0 0.25rem 1rem rgba(41, 171, 226, 0.25) !important;
    transition: all 0.3s ease !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    outline: none !important;
    padding: 0 !important;
    color: #ffffff !important;
    transform-origin: center center !important;
}

.chat-toggle:hover {
    transform: scale(1.05) !important;
    box-shadow: 0 0.375rem 1.25rem rgba(41, 171, 226, 0.35) !important;
    background-color: #2196F3 !important;
}

.toggle-icon {
    width: 1.5rem; /* 24px */
    height: 1.5rem; /* 24px */
}

.toggle-icon svg {
    fill: #ffffff !important;
    width: 100%;
    height: 100%;
    color: #ffffff !important;
    stroke: #ffffff !important;
}

/* Chat Popup */
.chat-popup {
    position: fixed;
    bottom: 5.625rem; /* 90px */
    width: 23.75rem; /* 380px */
    height: 37.5rem; /* 600px */
    background: #ffffff;
    border-radius: 1rem; /* 16px */
    box-shadow: 0 0.5rem 2rem rgba(41, 171, 226, 0.15);
    display: none;
    transition: all 0.3s ease;
    overflow: hidden;
    max-width: calc(100vw - 2.5rem); /* Prevent overflow on zoom */
    max-height: calc(100vh - 7.5rem); /* Prevent overflow on zoom */
    transform-origin: bottom center !important;
}

.chat-popup.active {
    display: block;
    animation: slideUp 0.3s ease;
}

.bottom-right .chat-popup {
    right: 1.25rem; /* 20px */
    left: auto !important;
}

.bottom-left .chat-popup {
    left: 1.25rem; /* 20px */
    right: auto !important;
}

/* Viewport-based positioning for extreme zoom */
@supports (dvh: 1dvh) {
    .chat-popup {
        max-height: calc(100dvh - 7.5rem);
    }
    
    @media screen and (max-width: 480px) {
        .chat-popup {
            height: calc(100dvh - 5rem);
            max-height: calc(100dvh - 1.25rem);
        }
    }
}

/* Chat Window */
.chat-window {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Chat Header */
.chat-header {
    background-color: #29ABE2;
    color: #ffffff;
    padding: 1.25rem; /* 20px */
    border-radius: 1rem 1rem 0 0; /* 16px */
    position: relative;
}

.chat-header h3 {
    margin: 0;
    font-size: 1.125rem; /* 18px */
    font-weight: 600;
    letter-spacing: 0.0125rem; /* 0.2px */
    color: #ffffff !important; /* Ensure title is always white */
}

.chat-status {
    display: flex;
    align-items: center;
    gap: 0.375rem; /* 6px */
    font-size: 0.8125rem; /* 13px */
    margin-top: 0.375rem; /* 6px */
    opacity: 0.9;
}

.status-dot {
    width: 0.5rem; /* 8px */
    height: 0.5rem; /* 8px */
    border-radius: 50%;
    background-color: #4CAF50;
    position: relative;
}

.status-dot::after {
    content: '';
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    background-color: inherit;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    70% { transform: scale(2); opacity: 0; }
    100% { transform: scale(1); opacity: 0; }
}

/* User Info Form */
.user-info-form {
    padding: 1.5rem; /* 24px */
    display: flex;
    flex-direction: column;
    gap: 1rem; /* 16px */
}

.user-info-form input {
    padding: 0.75rem 1rem !important; /* 12px 16px */
    border: 0.125rem solid #E8F5FC !important; /* 2px */
    border-radius: 0.75rem !important; /* 12px */
    font-size: 0.875rem !important; /* 14px */
    transition: all 0.3s ease !important;
    background-color: #F8FCFE !important;
    color: #2C3E50 !important;
    box-shadow: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    width: 100% !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

.user-info-form input:focus {
    border-color: #29ABE2 !important;
    outline: none !important;
    box-shadow: 0 0 0 0.1875rem rgba(41, 171, 226, 0.1) !important; /* 3px */
    background-color: #ffffff !important;
}

.user-info-form button {
    background-color: #29ABE2 !important;
    color: #ffffff !important;
    border: none !important;
    padding: 0.875rem !important; /* 14px */
    border-radius: 0.75rem !important; /* 12px */
    cursor: pointer !important;
    font-weight: 500 !important;
    font-size: 0.9375rem !important; /* 15px */
    transition: all 0.3s ease !important;
    text-transform: uppercase !important;
    letter-spacing: 0.03125rem !important; /* 0.5px */
    width: 100% !important;
    margin: 0 !important;
    box-shadow: 0 0.125rem 0.5rem rgba(41, 171, 226, 0.2) !important; /* 2px 8px */
}

.user-info-form button:hover {
    background-color: #2196F3 !important;
    transform: translateY(-0.0625rem) !important; /* -1px */
    box-shadow: 0 0.25rem 0.75rem rgba(41, 171, 226, 0.2) !important; /* 4px 12px */
}

.error-message {
    color: #FF5252;
    font-size: 0.75rem; /* 12px */
    display: none;
}

/* Chat Body */
.chat-body {
    flex: 1;
    padding: 1.25rem; /* 20px */
    overflow-y: auto;
    background-color: #F8FCFE;
}

.message {
    max-width: 85%;
    margin-bottom: 1rem; /* 16px */
    padding: 0.75rem 1rem; /* 12px 16px */
    border-radius: 1rem; /* 16px */
    font-size: 0.875rem; /* 14px */
    line-height: 1.5;
    position: relative;
}

.message.bot {
    background-color: #E8F5FC;
    margin-right: auto;
    border-bottom-left-radius: 0.25rem; /* 4px */
    color: #2C3E50;
}

.message.user {
    background-color: #29ABE2;
    color: #ffffff;
    margin-left: auto;
    border-bottom-right-radius: 0.25rem; /* 4px */
}

.message a {
    color: inherit;
    text-decoration: underline;
}

/* Chat Input */
.chat-input {
    padding: 1.25rem; /* 20px */
    border-top: 0.0625rem solid #E8F5FC; /* 1px */
    background-color: #ffffff;
}

.chat-input-container {
    display: flex;
    gap: 0.75rem; /* 12px */
    align-items: center;
}

.chat-input input {
    flex: 1 !important;
    padding: 0.75rem 1rem !important; /* 12px 16px */
    border: 0.125rem solid #E8F5FC !important; /* 2px */
    border-radius: 0.75rem !important; /* 12px */
    font-size: 0.875rem !important; /* 14px */
    background-color: #F8FCFE !important;
    transition: all 0.3s ease !important;
    color: #2C3E50 !important;
    box-shadow: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    margin: 0 !important;
    min-height: 2.75rem !important; /* 44px */
    box-sizing: border-box !important;
}

.chat-input input:focus {
    border-color: #29ABE2 !important;
    outline: none !important;
    background-color: #ffffff !important;
    box-shadow: 0 0 0 0.1875rem rgba(41, 171, 226, 0.1) !important; /* 3px */
}

.send-btn {
    background-color: #29ABE2 !important;
    color: #ffffff !important;
    border: none !important;
    width: 2.75rem !important; /* 44px */
    height: 2.75rem !important; /* 44px */
    border-radius: 0.75rem !important; /* 12px */
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    transition: all 0.3s ease !important;
    box-shadow: 0 0.125rem 0.5rem rgba(41, 171, 226, 0.2) !important; /* 2px 8px */
    padding: 0 !important;
    margin: 0 !important;
    min-width: 2.75rem !important; /* 44px */
}

.send-btn:hover {
    background-color: #2196F3 !important;
    transform: translateY(-0.0625rem) !important; /* -1px */
    box-shadow: 0 0.25rem 0.75rem rgba(41, 171, 226, 0.3) !important; /* 4px 12px */
}

.send-btn svg {
    width: 1.25rem !important; /* 20px */
    height: 1.25rem !important; /* 20px */
    fill: #ffffff !important;
    transform: translateX(0.0625rem) !important; /* 1px */
    color: #ffffff !important;
    stroke: #ffffff !important;
}

/* Typing Indicator */
.typing-indicator {
    padding: 1rem; /* 16px */
    display: flex;
    align-items: center;
    gap: 0.25rem; /* 4px */
    width: fit-content;
}

.typing-indicator span {
    width: 0.5rem; /* 8px */
    height: 0.5rem; /* 8px */
    border-radius: 50%;
    background-color: #29ABE2;
    display: inline-block;
    animation: typing 1.4s 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: translateY(0); opacity: 0.5; }
    50% { transform: translateY(-0.375rem); opacity: 1; } /* -6px */
}

@keyframes slideUp {
    from { 
        transform: translateY(1.25rem); /* 20px */
        opacity: 0; 
    }
    to { 
        transform: translateY(0); 
        opacity: 1; 
    }
}

/* Custom Scrollbar */
.chat-body::-webkit-scrollbar {
    width: 0.375rem; /* 6px */
}

.chat-body::-webkit-scrollbar-track {
    background: #F8FCFE;
}

.chat-body::-webkit-scrollbar-thumb {
    background: #BDE6F8;
    border-radius: 0.1875rem; /* 3px */
}

.chat-body::-webkit-scrollbar-thumb:hover {
    background: #29ABE2;
}

/* Fallback for browsers that don't support zoom media queries */
@supports not (zoom: 1) {
    .ma-widget {
        bottom: clamp(0.625rem, 2vw, 1.25rem) !important;
    }
    
    .ma-widget.bottom-right {
        right: clamp(0.625rem, 2vw, 1.25rem) !important;
    }
    
    .ma-widget.bottom-left {
        left: clamp(0.625rem, 2vw, 1.25rem) !important;
    }
    
    .chat-popup {
        bottom: clamp(4.375rem, 8vh, 5.625rem) !important;
        width: clamp(18.75rem, 90vw, 23.75rem) !important;
        height: clamp(25rem, 80vh, 37.5rem) !important;
    }
    
    .bottom-right .chat-popup {
        right: clamp(0.625rem, 2vw, 1.25rem) !important;
    }
    
    .bottom-left .chat-popup {
        left: clamp(0.625rem, 2vw, 1.25rem) !important;
    }
}