/* Main Widget Container */
#ai-chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 10000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Chat Icon (Floating Button) */
#chatbot-icon {
    width: 60px;
    height: 60px;
    background-color: #007bff;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: transform 0.3s;
}

#chatbot-icon:hover {
    transform: scale(1.1);
}

/* Hide icon when chat is open */
#ai-chatbot-widget.chat-open #chatbot-icon {
    display: none;
}

/* Chat Window (The actual chat box) */
#chatbot-window {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 350px;
    height: 500px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: opacity 0.3s, transform 0.3s;
    transform-origin: bottom right;
}

#chatbot-window.hidden {
    display: none;
    opacity: 0;
    pointer-events: none;
}

/* Header */
.chatbot-header {
    background: #007bff;
    color: white;
    padding: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: bold;
    flex-shrink: 0;
    /* Never shrink header */
}

.chatbot-header button {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
}

/* Message Area */
.chatbot-messages {
    flex: 1;
    padding: 15px;
    overflow-y: auto;
    background: #f8f9fa;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    /* Smooth scroll on iOS */
}

.message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.4;
    word-wrap: break-word;
}

.message.bot {
    align-self: flex-start;
    background: white;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
}

.message.user {
    align-self: flex-end;
    background: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

/* Input Area */
.chatbot-input {
    padding: 15px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    background: white;
    flex-shrink: 0;
    /* Never shrink input area */
}

.chatbot-input input {
    flex: 1;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 20px;
    outline: none;
    font-family: inherit;
}

/* CRITICAL FIXES FOR MOBILE ZOOM */
@media screen and (max-width: 600px) {
    .chatbot-input input {
        font-size: 16px !important;
        /* Prevents iOS auto-zoom */
    }
}

.chatbot-input input:focus {
    border-color: #007bff;
}

.chatbot-input button {
    background: #007bff;
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-shrink: 0;
}

/* =========================================
   MOBILE RESPONSIVENESS (FULL SCREEN MODE)
   ========================================= */
@media (max-width: 480px) {
    #ai-chatbot-widget {
        bottom: 0;
        right: 0;
        width: 100%;
        height: 0;
        /* Collapsed by default */
        z-index: 99999;
    }

    /* Floating Button Position on Mobile */
    #chatbot-icon {
        position: fixed;
        bottom: 20px;
        right: 20px;
        z-index: 10002;
    }

    /* Full Screen Window */
    #chatbot-window {
        position: fixed !important;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100%;
        /* Fallback */
        height: 100dvh;
        /* Dynamic height */
        margin: 0;
        border-radius: 0;
        z-index: 10001;

        display: flex;
        flex-direction: column;
    }

    /* Ensure hidden actually hides it */
    #chatbot-window.hidden {
        display: none !important;
    }

    /* Adjust padding for touch */
    .chatbot-header {
        padding: 15px 20px;
    }

    .chatbot-input {
        padding: 10px 15px;
        /* Padding bottom to handle safe area (iPhone X+) */
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }
}

/* Increase text size for all mobile devices */
@media (max-width: 768px) {
    .message {
        font-size: 16px !important;
        line-height: 1.5;
    }
}