/* Main Chatbot Toggle Button */
#hari-chatbot-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    background-color: #b3de4f;
    color: #000;
    border-radius: 50%;
    display: flex !important;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
    z-index: 9998;
    transition: transform 0.2s ease-in-out;
}

#hari-chatbot-toggle:hover {
    transform: scale(1.1);
}

/* Main Chatbot Window */
#hari-chatbot-container {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 340px;
    max-height: 500px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    z-index: 9999;
    display: none; /* Changed from flex to none by default */
    flex-direction: column;
    overflow: hidden;
}

/* Mobile fullscreen class */
#hari-chatbot-container.mobile-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    max-width: 100vw !important;
    max-height: 100vh !important;
    border-radius: 0 !important;
    border: none !important;
    z-index: 999999 !important;
}

/* Chatbot Header */
#hari-chatbot-header {
    background: #b3de4f;
    color: #000;
    padding: 12px 15px;
    font-weight: bold;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

#hari-header-controls {
    display: flex;
    align-items: center;
}

#hari-chatbot-close {
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
}

/* Chat Log / Messages Area */
#hari-chat-log {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    background: #f9f9f9;
    font-size: 14px;
    display: flex;
    flex-direction: column;
    min-height: 0; /* Important for flex scrolling */
}

.hari-msg-container {
    display: flex;
    flex-direction: column;
    margin-bottom: 10px;
    max-width: 85%;
}

.hari-msg-container.user {
    align-self: flex-end;
}

.hari-msg-container.bot {
    align-self: flex-start;
}

.hari-bot-msg,
.hari-user-msg {
    padding: 10px 14px;
    border-radius: 18px;
    line-height: 1.4;
    word-wrap: break-word;
}

.hari-bot-msg {
    background-color: #e1e3e6;
    color: #000;
}

.hari-user-msg {
    background-color: #b3de4f;
    color: #000;
}

.hari-bot-msg button,
.hari-bot-msg a {
    display: block;
    width: 100%;
    box-sizing: border-box;
    margin: 8px 0;
    padding: 10px;
    border: 1px solid #9fca3e;
    background-color: #fff;
    color: #333;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
    font-size: 14px;
    text-decoration: none;
}

.hari-bot-msg button:hover,
.hari-bot-msg a:hover {
    background-color: #b3de4f;
    color: #000;
}

/* Input Area */
#hari-chat-input-container {
    padding: 10px;
    border-top: 1px solid #ddd;
    background: #fff;
    flex-shrink: 0;
}

#hari-chat-input {
    padding: 10px;
    font-size: 14px;
    border-radius: 8px;
    border: 1px solid #ccc;
    outline: none;
    width: 100%;
    box-sizing: border-box;
    background-color: #ffffff;
    color: #000000;
}

#hari-chat-input.hari-chat-input-active {
    border-color: #b3de4f;
    box-shadow: 0 0 0 1px #b3de4f;
}

#hari-chat-input:disabled {
    background-color: #f1f1f1;
    cursor: not-allowed;
}

/* Typing Indicator Style */
.hari-typing-indicator {
    padding: 10px 15px;
    font-size: 14px;
    color: #555;
    font-style: italic;
    background: #f9f9f9;
}

/* Style for validation error on input */
#hari-chat-input.hari-chat-input-error {
    border-color: #e53e3e; /* Red */
    box-shadow: 0 0 0 1px #e53e3e; /* Red glow */
}

/* Style for the error message text below the input */
#hari-chat-error-message {
    color: #e53e3e; /* Red */
    font-size: 12px;
    padding: 0 2px 0 2px;
    display: none; /* Hidden by default */
    line-height: 1.2;
}

/* Minimalist style for the "New Chat" button */
#hari-chatbot-reset {
    background: none;
    border: none;
    padding: 0;
    margin-right: 15px;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    color: #000;
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

#hari-chatbot-reset:hover {
    opacity: 1;
}

/*
 * --- ENHANCED MOBILE SUPPORT ---
 * This media query ensures the chatbot is visible and usable on screens 768px or smaller.
 */
@media screen and (max-width: 768px) {
    /* Force toggle button visibility */
    #hari-chatbot-toggle {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        pointer-events: auto !important;
    }

    /* Mobile optimizations for chat container */
    #hari-chatbot-container {
        /* Better mobile positioning when not fullscreen */
        width: 95vw;
        max-width: 95vw;
        height: 80vh;
        max-height: 80vh;
        bottom: 20px;
        right: 2.5vw;
        left: 2.5vw;
    }

    /* Mobile fullscreen takes entire viewport */
    #hari-chatbot-container.mobile-fullscreen {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
    }
}