/* CloudPrime Chatbot Widget Styles - Fixed Version */

:root {
    --chat-primary: #007bff;
    --chat-secondary: #2c3e50;
    --chat-success: #28a745;
    --chat-danger: #dc3545;
    --chat-light: #f8f9fa;
    --chat-dark: #343a40;
}

/* Chat Toggle Button */
#chatbot-toggle {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 70px;
    height: 70px;
    background: linear-gradient(135deg, var(--chat-primary), #0056b3);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 999999; /* Higher than chatbot window */
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 3px solid white;
    pointer-events: auto; /* Ensure it can receive clicks */
}

#chatbot-toggle.hidden,
#chatbot-toggle[style*="display: none"] {
    display: none !important;
}

#chatbot-toggle:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

#chatbot-toggle:active {
    transform: scale(0.95);
}

.chat-icon {
    font-size: 32px;
    color: white;
    line-height: 1;
}

.feature-indicators {
    position: absolute;
    top: -8px;
    right: -8px;
    display: flex;
    flex-direction: column;
    gap: 3px;
    pointer-events: none;
}

.feature-badge {
    background: white;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    border: 2px solid var(--chat-primary);
}

/* Chat Window */
#cloudprime-chatbot {
    position: fixed;
    bottom: 100px; /* Above the toggle button */
    left: 20px;
    width: 400px;
    height: 600px;
    max-height: calc(100vh - 120px);
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.25);
    z-index: 99999; /* Below toggle button */
    display: none;
    flex-direction: column;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    animation: slideUp 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    overflow: hidden;
    pointer-events: auto; /* Ensure it can receive clicks */
}

#cloudprime-chatbot.active,
#cloudprime-chatbot[style*="display: flex"] {
    display: flex !important;
}

@keyframes slideUp {
    from {
        transform: translateY(30px) scale(0.9);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Header */
#chatbot-header {
    background: linear-gradient(135deg, var(--chat-secondary), var(--chat-primary));
    color: white;
    padding: 20px;
    border-radius: 20px 20px 0 0;
    display: flex;
    align-items: center;
    gap: 15px;
    flex-shrink: 0;
}

.chatbot-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.chatbot-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-placeholder {
    font-size: 28px;
    line-height: 1;
}

.chatbot-info {
    flex: 1;
    min-width: 0;
}

.chatbot-info h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.version-badge {
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 10px;
    font-weight: 500;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    margin-top: 5px;
    opacity: 0.95;
}

.status-dot {
    width: 8px;
    height: 8px;
    background: var(--chat-success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.4);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(40, 167, 69, 0);
    }
}

.chatbot-controls {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.control-btn,
#chatbot-minimize {
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    font-size: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.control-btn:hover,
#chatbot-minimize:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}

.control-btn:active,
#chatbot-minimize:active {
    transform: scale(0.95);
}

/* Messages Container */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: linear-gradient(to bottom, #f8f9fa 0%, #ffffff 100%);
    scroll-behavior: smooth;
}

#chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

#chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

#chatbot-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

#chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* Messages */
.message {
    margin-bottom: 16px;
    animation: fadeInUp 0.3s ease-out;
    clear: both;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message-sender {
    font-size: 11px;
    color: #6c757d;
    margin-bottom: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.message-content {
    display: inline-block;
    padding: 12px 16px;
    border-radius: 18px;
    max-width: 85%;
    line-height: 1.5;
    font-size: 14px;
    word-wrap: break-word;
}

.message.user {
    text-align: right;
}

.message.user .message-sender {
    text-align: right;
}

.message.user .message-content {
    background: linear-gradient(135deg, var(--chat-primary), #0056b3);
    color: white;
    border-bottom-right-radius: 6px;
}

.message.bot .message-content {
    background: white;
    color: #333;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 6px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

/* Typing indicator */
.message.typing .message-content {
    padding: 8px 16px;
}

.typing-dots {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: #6c757d;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-dots span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* Contact Form Inline */
.contact-form-inline {
    width: 100%;
}

.contact-form-inline input {
    width: 100%;
    padding: 10px 14px;
    margin-bottom: 10px;
    border: 1px solid #ddd;
    border-radius: 10px;
    font-size: 14px;
    box-sizing: border-box;
    transition: border-color 0.2s;
}

.contact-form-inline input:focus {
    outline: none;
    border-color: var(--chat-primary);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.contact-form-inline .btn-primary {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, var(--chat-primary), #0056b3);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.contact-form-inline .btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.4);
}

/* Quick Questions */
.quick-questions {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.quick-question {
    width: 100%;
    padding: 10px 14px;
    background: white;
    border: 1px solid #e9ecef;
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    font-size: 13px;
    transition: all 0.2s;
}

.quick-question:hover {
    background: var(--chat-light);
    border-color: var(--chat-primary);
    transform: translateX(4px);
}

/* WhatsApp Button */
.whatsapp-button {
    display: inline-block;
    padding: 12px 20px;
    background: #25d366;
    color: white;
    text-decoration: none;
    border-radius: 12px;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
}

.whatsapp-button:hover {
    background: #20b858;
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(37, 211, 102, 0.4);
}

/* Input Area */
#chatbot-input-area {
    display: flex;
    gap: 10px;
    padding: 16px;
    border-top: 1px solid #e9ecef;
    background: white;
    border-radius: 0 0 20px 20px;
    flex-shrink: 0;
}

#chatbot-input {
    flex: 1;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    outline: none;
    font-size: 14px;
    background: var(--chat-light);
    transition: all 0.2s;
}

#chatbot-input:focus {
    border-color: var(--chat-primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

#chatbot-input:disabled {
    background: #e9ecef;
    cursor: not-allowed;
}

.voice-button {
    width: 44px;
    height: 44px;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.voice-button:hover {
    border-color: var(--chat-primary);
    background: var(--chat-light);
}

.voice-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.voice-button.listening {
    background: var(--chat-danger);
    border-color: var(--chat-danger);
    animation: voicePulse 1.5s infinite;
}

.voice-button.listening svg {
    stroke: white;
}

@keyframes voicePulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(220, 53, 69, 0.4);
    }
    50% {
        box-shadow: 0 0 0 12px rgba(220, 53, 69, 0);
    }
}

#chatbot-send {
    padding: 12px 24px;
    background: linear-gradient(135deg, var(--chat-primary), #0056b3);
    color: white;
    border: none;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    transition: all 0.2s;
    white-space: nowrap;
    flex-shrink: 0;
}

#chatbot-send:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.4);
}

#chatbot-send:active {
    transform: translateY(0);
}

#chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #cloudprime-chatbot {
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 0;
    }
    
    #chatbot-header {
        border-radius: 0;
    }
    
    #chatbot-input-area {
        border-radius: 0;
        padding: 12px;
    }
    
    #chatbot-toggle {
        width: 60px;
        height: 60px;
        bottom: 16px;
        left: 16px;
    }
    
    .chat-icon {
        font-size: 28px;
    }
    
    .feature-indicators {
        top: -6px;
        right: -6px;
    }
    
    .feature-badge {
        width: 20px;
        height: 20px;
        font-size: 10px;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .message-content {
        max-width: 90%;
        font-size: 13px;
    }
    
    #chatbot-input {
        font-size: 16px; /* Prevent zoom on iOS */
    }
    
    #chatbot-send {
        padding: 12px 16px;
    }
}