/**
 * Hebo Chatbot Widget Styles
 * Namespace: #hebo-chatbot-widget
 */

:root {
    --hebo-primary-color: #fc0;
    /* Brand Yellow */
    --hebo-primary-hover: #e5b800;
    /* Darker Yellow for Hover */
    --hebo-bg-color: #ffffff;
    /* Chat Content Background */
    --hebo-text-color: #404040;
    /* Brand Dark Gray */
    --hebo-border-color: #d9d9d9;
    --hebo-msg-user-bg: #fff5cc;
    /* Very light yellow for user bubbles */
    --hebo-msg-bot-bg: #f5f5f5;
    /* Light gray for assistant bubbles */
    --hebo-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    --hebo-font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

#hebo-chatbot-widget {
    font-family: var(--hebo-font-family);
    font-size: 14px;
    color: var(--hebo-text-color);
    line-height: 1.5;
    box-sizing: border-box;
    position: relative;
    z-index: 9999;
}

#hebo-chatbot-widget * {
    box-sizing: inherit;
}

/* --- Floating Toggle Button --- */
#hebo-chatbot-widget .chat-toggle-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--hebo-primary-color);
    color: var(--hebo-text-color);
    border: none;
    border-radius: 50px;
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: var(--hebo-shadow);
    transition: background-color 0.2s ease, transform 0.2s ease;
}

#hebo-chatbot-widget .chat-toggle-btn:hover {
    background-color: var(--hebo-primary-hover);
    transform: translateY(-2px);
}

/* --- Chat Overlay Window --- */
#hebo-chatbot-widget .chat-overlay {
    position: fixed;
    bottom: 80px;
    right: 20px;
    width: 360px;
    height: 550px;
    max-height: calc(100vh - 100px);
    background-color: var(--hebo-bg-color);
    border-radius: 12px;
    box-shadow: var(--hebo-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--hebo-border-color);
}

/* --- Header --- */
#hebo-chatbot-widget .chat-header {
    background-color: var(--hebo-primary-color);
    color: var(--hebo-text-color);
    padding: 12px 16px;
    font-weight: bold;
    font-size: 16px;
    border-bottom: 1px solid var(--hebo-border-color);

    /* Flexbox setup for title and close button */
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* WCAG conform Close Button */
#hebo-chatbot-widget .chat-close-btn {
    background: transparent;
    border: none;
    color: var(--hebo-text-color);
    font-size: 24px;
    font-weight: bold;
    line-height: 1;
    cursor: pointer;
    padding: 0 4px;
    transition: opacity 0.2s;
}

/* WCAG: Visible focus outline for keyboard navigation */
#hebo-chatbot-widget .chat-close-btn:focus-visible {
    outline: 2px solid var(--hebo-text-color);
    outline-offset: 2px;
    border-radius: 2px;
}

#hebo-chatbot-widget .chat-close-btn:hover {
    opacity: 0.6;
}

/* --- Output Area (Scrollable) --- */
#hebo-chatbot-widget .chat-output {
    flex-grow: 1;
    padding: 16px;
    overflow-y: auto;
    background-color: var(--hebo-bg-color);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

#hebo-chatbot-widget .chat-output::-webkit-scrollbar {
    width: 6px;
}

#hebo-chatbot-widget .chat-output::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 3px;
}

/* --- Messages --- */
#hebo-chatbot-widget .chat-message {
    padding: 10px 14px;
    border-radius: 8px;
    max-width: 85%;
    word-wrap: break-word;
}

#hebo-chatbot-widget .msg-user {
    background-color: var(--hebo-msg-user-bg);
    color: var(--hebo-text-color);
    align-self: flex-end;
    border-bottom-right-radius: 0;
}

#hebo-chatbot-widget .msg-assistant {
    background-color: var(--hebo-msg-bot-bg);
    color: var(--hebo-text-color);
    align-self: flex-start;
    border-bottom-left-radius: 0;
}

#hebo-chatbot-widget .msg-system-error {
    background-color: #ffebee;
    color: #c62828;
    align-self: center;
    font-size: 13px;
    border-radius: 4px;
}

#hebo-chatbot-widget .assistant-sources {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #ddd;
    font-size: 12px;
}

#hebo-chatbot-widget .assistant-sources ul {
    margin: 4px 0 0 0;
    padding-left: 20px;
}

#hebo-chatbot-widget .assistant-sources a {
    color: #0056b3;
    /* Keep links visible/clickable with standard blue */
    text-decoration: none;
}

#hebo-chatbot-widget .assistant-sources a:hover {
    text-decoration: underline;
}

/* --- Loading Indicator --- */
#hebo-chatbot-widget .chat-loading {
    padding: 10px 16px;
    font-size: 13px;
    color: var(--hebo-text-color);
    font-style: italic;
    background: #f9f9f9;
    border-top: 1px solid var(--hebo-border-color);
}

/* --- Input Form --- */
#hebo-chatbot-widget form {
    display: flex;
    padding: 12px;
    background-color: var(--hebo-bg-color);
    border-top: 1px solid var(--hebo-border-color);
    gap: 8px;
}

#hebo-chatbot-widget input[type="text"] {
    flex-grow: 1;
    padding: 10px 12px;
    border: 1px solid var(--hebo-border-color);
    border-radius: 20px;
    font-size: 14px;
    color: var(--hebo-text-color);
    outline: none;
    transition: border-color 0.2s;
}

#hebo-chatbot-widget input[type="text"]:focus {
    border-color: var(--hebo-primary-color);
}

#hebo-chatbot-widget input[type="text"]:disabled {
    background-color: #f0f0f0;
}

#hebo-chatbot-widget button[type="submit"] {
    background-color: var(--hebo-primary-color);
    color: var(--hebo-text-color);
    border: none;
    border-radius: 20px;
    padding: 0 16px;
    font-weight: bold;
    cursor: pointer;
    transition: background-color 0.2s;
}

#hebo-chatbot-widget button[type="submit"]:hover:not(:disabled) {
    background-color: var(--hebo-primary-hover);
}

#hebo-chatbot-widget button[type="submit"]:disabled {
    background-color: #ccc;
    color: #666;
    cursor: not-allowed;
}

/* --- Mobile Responsiveness --- */
@media (max-width: 480px) {
    #hebo-chatbot-widget .chat-overlay {
        width: 100%;
        height: 100%;
        bottom: 0;
        right: 0;
        border-radius: 0;
        max-height: 100vh;
    }

    #hebo-chatbot-widget .chat-toggle-btn {
        bottom: 16px;
        right: 16px;
    }
}