/* Chatbot CSS */
.chatbot-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: 'Open Sans', sans-serif;
}

.chatbot-button {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #c11325;
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s ease;
    animation: chatbotPulse 3s infinite;
}

.chatbot-button:hover {
    transform: scale(1.1);
    animation-play-state: paused;
}

@keyframes chatbotPulse {
    0% { transform: scale(1); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); }
    10% { transform: scale(1.1); box-shadow: 0 0 20px rgba(193, 19, 37, 0.6); }
    20% { transform: scale(1); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); }
    100% { transform: scale(1); box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15); }
}

.chatbot-button svg {
    width: 30px;
    height: 30px;
    fill: currentColor;
}

.chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background-color: white;
    border-radius: 12px;
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform-origin: bottom right;
    transform: scale(0);
    opacity: 0;
    transition: all 0.3s ease;
    border: 1px solid #eee;
}

.chatbot-window.open {
    transform: scale(1);
    opacity: 1;
}

.chatbot-header {
    background-color: #c11325;
    color: white;
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chatbot-header h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-close {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    line-height: 1;
}

.chatbot-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background-color: #f9f9f9;
}

.chat-message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.chat-message.bot {
    background-color: #e9ecef;
    color: #333;
    align-self: flex-start;
    border-bottom-left-radius: 4px;
}

.chat-message.user {
    background-color: #c11325;
    color: white;
    align-self: flex-end;
    border-bottom-right-radius: 4px;
}

.chatbot-input-area {
    padding: 15px;
    background-color: white;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
}

.chatbot-input-area input {
    flex: 1;
    padding: 10px 15px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-size: 14px;
    transition: border-color 0.2s;
}

.chatbot-input-area input:focus {
    border-color: #c11325;
}

.chatbot-input-area button {
    background-color: #c11325;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background-color 0.2s;
}

.chatbot-input-area button:hover {
    background-color: #a00f1e;
}

.chatbot-input-area button svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* Mobile Responsiveness (WhatsApp style) */
@media (max-width: 768px) {
    .chatbot-window {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 100dvh; /* Uses dynamic viewport height to account for mobile keyboard */
        border-radius: 0;
        box-shadow: none;
        z-index: 99999;
        transform-origin: center;
        border: none;
    }
    
    .chatbot-header {
        position: sticky;
        top: 0;
        flex-shrink: 0;
        z-index: 10;
        border-radius: 0;
    }
    
    .chatbot-messages {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch; /* Smooth native scrolling on iOS */
        padding-bottom: 20px;
    }
    
    .chatbot-input-area {
        position: sticky;
        bottom: 0;
        flex-shrink: 0;
        z-index: 10;
        background: white;
        /* Padding for safe areas on iOS (like the home indicator) */
        padding-bottom: calc(15px + env(safe-area-inset-bottom, 0px)); 
    }

    /* Hide the floating button when the chat window is open on mobile */
    .chatbot-window.open ~ .chatbot-button {
        display: none;
    }
}

/* Actions inside input area */
.chatbot-input-area {
    padding: 10px;
    align-items: center;
}

.chatbot-input-wrapper {
    display: flex;
    flex: 1;
    align-items: center;
    background-color: #f0f2f5;
    border-radius: 24px;
    padding: 5px 15px;
    border: 1px solid #ddd;
    transition: border-color 0.2s;
}

.chatbot-input-wrapper:focus-within {
    border-color: #c11325;
}

.chatbot-input-area input {
    border: none;
    background: transparent;
    padding: 8px 10px;
    border-radius: 0;
}

.chatbot-input-area input:focus {
    border-color: transparent;
}

.action-btn {
    background: transparent !important;
    color: #888 !important;
    width: 32px !important;
    height: 32px !important;
    padding: 0 !important;
}

.action-btn:hover {
    background: transparent !important;
    color: #c11325 !important;
}

.action-btn svg {
    fill: currentColor !important;
    width: 22px !important;
    height: 22px !important;
}

.chatbot-send-btn {
    background-color: #c11325 !important;
    margin-left: 8px;
    flex-shrink: 0;
}

/* Pulsing mic indicator */
.action-btn.recording {
    color: #c11325 !important;
    animation: pulseMic 1.5s infinite;
}

@keyframes pulseMic {
    0% { transform: scale(1); }
    50% { transform: scale(1.2); }
    100% { transform: scale(1); }
}

emoji-picker {
    width: 100%;
    height: 300px;
}

/* Typing Dots Animation */
.typing-dots {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 2px 4px;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background-color: #888;
    border-radius: 50%;
    animation: typingPulse 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typingPulse {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

/* Dark Mode Chatbot Overrides */
.chatbot-window {
    background-color: #1a1a1a;
    border: 1px solid #333;
}

.chatbot-messages {
    background-color: #121212;
}

.chat-message.bot {
    background-color: #2a2a2a;
    color: #e0e0e0;
}

.chatbot-input-area {
    background-color: #1a1a1a;
    border-top: 1px solid #333;
}

.chatbot-input-wrapper {
    background-color: #2a2a2a;
    border-color: #444;
}

.chatbot-input-area input {
    color: #fff;
}

.chatbot-input-area input::placeholder {
    color: #888;
}

.chatbot-header {
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}
