#chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: Arial, sans-serif;
    /* Prevent the widget from interfering with page scrolling when closed */
    pointer-events: none;
}

/* Only enable pointer events when the container is visible */
#chatbot-widget #chatbot-container {
    pointer-events: auto;
}

#chatbot-widget #chatbot-toggle {
    pointer-events: auto;
}

#chatbot-toggle {
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;

    background: var(--chatbot-toggle-bg, rgba(30, 30, 30, 0.77)); /* Default dark transparent */
    border-radius: 50%; /* Explicitly keep circular */
    box-shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
    backdrop-filter: blur(10.2px);
    -webkit-backdrop-filter: blur(10.2px);
    border: 1px solid var(--chatbot-toggle-border, rgba(30, 30, 30, 0.62)); /* Default dark transparent */
    transition: all 0.3s ease; /* Keep smooth transitions */
}

#chatbot-toggle:hover {
    background: var(--chatbot-toggle-hover-bg, rgba(30, 30, 30, 0.9)); /* Slightly darker default on hover */
    transform: scale(1.1); /* Restore hover scale effect */
}

#chatbot-toggle span {
    font-size: 24px;
    color: white;
}

#chatbot-container {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#chatbot-header {
    background: #007cba; /* This will be overridden by inline style from PHP */
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#chatbot-header h4 {
    margin: 0;
    font-size: 16px;
}

#chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    width: 25px;
    height: 25px;
}

#chatbot-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f9f9f9;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: #c1c1c1 #f9f9f9; /* Firefox */
}

/* Custom scrollbar for webkit browsers */
#chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

#chatbot-messages::-webkit-scrollbar-track {
    background: #f9f9f9;
    border-radius: 3px;
}

#chatbot-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

#chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

.message {
    margin-bottom: 15px;
}

.user-message {
    text-align: right;
}

.bot-message {
    text-align: left;
}

.message-content {
    display: inline-block;
    padding: 10px 15px;
    border-radius: 18px;
    max-width: 80%;
    word-wrap: break-word;
}

.user-message .message-content {
    background: #007cba; /* This will be overridden by inline style from PHP */
    color: white;
}

.bot-message .message-content {
    background: white;
    color: #333;
    border: 1px solid #e1e1e1;
}

#chatbot-input-container {
    padding: 15px;
    background: white;
    border-top: 1px solid #e1e1e1;
    display: flex;
    gap: 10px;
}

#chatbot-input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-size: 14px; /* This will be overridden by inline style from PHP */
}

#chatbot-input:focus {
    border-color: #007cba; /* This will be overridden by inline style from PHP */
}

#chatbot-send {
    background: #007cba; /* This will be overridden by inline style from PHP */
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 20px;
    cursor: pointer;
    font-size: 14px; /* This will be overridden by inline style from PHP */
    transition: background 0.3s ease;
}

#chatbot-send:hover {
    background: #005a87; /* This will be overridden by inline style from PHP */
}

/* Typing Indicator Styles - High Specificity for WordPress Compatibility */
#chatbot-widget .typing-indicator,
#chatbot-container .typing-indicator,
.bot-message .typing-indicator {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    padding: 8px 12px !important;
    background: #f0f0f0 !important;
    border-radius: 18px !important;
    max-width: 60px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

#chatbot-widget .typing-indicator span,
#chatbot-container .typing-indicator span,
.bot-message .typing-indicator span {
    width: 8px !important;
    height: 8px !important;
    border-radius: 50% !important;
    background-color: #999 !important;
    animation: chatbot-typing-bounce 1.4s infinite ease-in-out !important;
    display: inline-block !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

#chatbot-widget .typing-indicator span:nth-child(1),
#chatbot-container .typing-indicator span:nth-child(1),
.bot-message .typing-indicator span:nth-child(1) {
    animation-delay: -0.32s !important;
}

#chatbot-widget .typing-indicator span:nth-child(2),
#chatbot-container .typing-indicator span:nth-child(2),
.bot-message .typing-indicator span:nth-child(2) {
    animation-delay: -0.16s !important;
}

#chatbot-widget .typing-indicator span:nth-child(3),
#chatbot-container .typing-indicator span:nth-child(3),
.bot-message .typing-indicator span:nth-child(3) {
    animation-delay: 0s !important;
}

@keyframes chatbot-typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.8) !important;
        opacity: 0.5 !important;
    }
    40% {
        transform: scale(1) !important;
        opacity: 1 !important;
    }
}

/* Fallback for older browsers */
@keyframes typing-bounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Additional WordPress/Theme Compatibility Fixes */
#chatbot-widget *,
#chatbot-container * {
    box-sizing: border-box !important;
}

/* Ensure typing indicator works with Elementor and other page builders */
.elementor #chatbot-widget .typing-indicator,
.elementor-page #chatbot-widget .typing-indicator,
.wpb_row #chatbot-widget .typing-indicator,
.vc_row #chatbot-widget .typing-indicator {
    display: flex !important;
    align-items: center !important;
    gap: 4px !important;
    padding: 8px 12px !important;
    background: #f0f0f0 !important;
    border-radius: 18px !important;
    max-width: 60px !important;
    margin: 0 !important;
    box-sizing: border-box !important;
}

.elementor #chatbot-widget .typing-indicator span,
.elementor-page #chatbot-widget .typing-indicator span,
.wpb_row #chatbot-widget .typing-indicator span,
.vc_row #chatbot-widget .typing-indicator span {
    width: 8px !important;
    height: 8px !important;
    border-radius: 50% !important;
    background-color: #999 !important;
    animation: chatbot-typing-bounce 1.4s infinite ease-in-out !important;
    display: inline-block !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box !important;
}

/* Override any theme animations that might interfere */
#chatbot-widget .typing-indicator span {
    animation: chatbot-typing-bounce 1.4s infinite ease-in-out !important;
    animation-play-state: running !important;
}

/* Ensure the typing message is properly styled */
.typing-message .message-content {
    background: white !important;
    color: #333 !important;
    border: 1px solid #e1e1e1 !important;
    padding: 10px 15px !important;
    border-radius: 18px !important;
    max-width: 80% !important;
    word-wrap: break-word !important;
}

/* Modal Message Box Styles */
#chatbot-message-box {
    display: none;
    padding: 10px;
    margin: 10px 0;
    border-radius: 4px;
    font-size: 14px;
}

#chatbot-message-box.info {
    background-color: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

#chatbot-message-box.success {
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

#chatbot-message-box.error {
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

/* Cache Indicator Styles */
.cache-indicator {
    font-size: 11px !important;
    color: #666 !important;
    text-align: center !important;
    padding: 5px !important;
    background: #f0f0f0 !important;
    border-radius: 4px !important;
    margin: 5px 0 !important;
    border: 1px solid #ddd !important;
}

.cache-indicator .dashicons {
    font-size: 12px !important;
    margin-right: 3px !important;
    color: #007cba !important;
}

.contact-widget {
    display: flex;
    align-items: center;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px solid #dee2e6;
    border-radius: 12px;
    padding: 12px 16px;
    margin: 10px 0;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.contact-widget:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    border-color: var(--chatbot-primary-color, #007cba); /* Uses primary color variable */
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.contact-widget .contact-icon {
    font-size: 24px;
    margin-right: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,0.8);
    border-radius: 50%;
}

.contact-widget .contact-icon svg {
    width: 20px;
    height: 20px;
    fill: currentColor;
}

.contact-widget .contact-info {
    flex: 1;
}

.contact-widget .contact-label {
    font-weight: 600;
    color: #495057;
    font-size: 14px;
    margin-bottom: 2px;
}

.contact-widget .contact-value {
    color: #6c757d;
    font-size: 13px;
}

.contact-widget .contact-action {
    font-size: 18px;
    color: var(--chatbot-primary-color, #007cba); /* Uses primary color variable */
    font-weight: bold;
}

.email-widget:hover .contact-icon {
    background: #fff3cd;
}

.phone-widget:hover .contact-icon {
    background: #d1ecf1;
}

/* Responsive design */
@media (max-width: 480px) {
    .contact-widget {
        padding: 10px 12px;
    }
    
    .contact-widget .contact-icon {
        width: 35px;
        height: 35px;
        font-size: 20px;
        margin-right: 10px;
    }
    
    .contact-widget .contact-icon svg {
        width: 18px;
        height: 18px;
    }
    
    .contact-widget .contact-label {
        font-size: 13px;
    }
    
    .contact-widget .contact-value {
        font-size: 12px;
    }
}



/* Mobile responsiveness */
@media (max-width: 768px) {
    #chatbot-container {
        width: 300px;
        height: 400px;
    }
    
    #chatbot-widget {
        bottom: 10px;
        right: 10px;
    }
}
