/* ============================================================
   Hawaii AG AI Chatbot Widget — hiag-chatbot.css
   ============================================================ */

/* --- Root / Reset --- */
#hiag-chat-root {
    --hiag-primary:     #2C7DA0;
    --hiag-primary-dk:  #1a5f7a;
    --hiag-accent:      #48CAE4;
    --hiag-white:       #ffffff;
    --hiag-bg:          #f9fafb;
    --hiag-card:        #ffffff;
    --hiag-text:        #111827;
    --hiag-text-sub:    #6b7280;
    --hiag-border:      #e5e7eb;
    --hiag-shadow:      0 8px 32px rgba(0,0,0,0.18);
    --hiag-radius:      16px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-sizing: border-box;
}
#hiag-chat-root *, #hiag-chat-root *::before, #hiag-chat-root *::after {
    box-sizing: inherit;
}

/* --- Floating Bubble --- */
#hiag-chat-bubble {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99999;
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--hiag-primary) 0%, var(--hiag-accent) 100%);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--hiag-white);
    box-shadow: 0 4px 20px rgba(44,125,160,0.45);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}
#hiag-chat-bubble:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(44,125,160,0.55);
}
#hiag-chat-bubble:focus-visible {
    outline: 3px solid var(--hiag-accent);
    outline-offset: 3px;
}

/* --- Chat Panel --- */
#hiag-chat-panel {
    position: fixed;
    bottom: 92px;
    right: 24px;
    z-index: 99998;
    width: 360px;
    max-height: 560px;
    background: var(--hiag-card);
    border-radius: var(--hiag-radius);
    box-shadow: var(--hiag-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.92) translateY(12px);
    transform-origin: bottom right;
    opacity: 0;
    pointer-events: none;
    transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s ease;
}
#hiag-chat-panel.hiag-open {
    transform: scale(1) translateY(0);
    opacity: 1;
    pointer-events: all;
}

/* Mobile: full-width near bottom */
@media (max-width: 480px) {
    #hiag-chat-panel {
        left: 12px;
        right: 12px;
        width: auto;
        bottom: 84px;
    }
}

/* --- Header --- */
#hiag-chat-header {
    background: linear-gradient(135deg, var(--hiag-primary) 0%, var(--hiag-primary-dk) 100%);
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
#hiag-chat-header-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--hiag-white);
    font-size: 18px;
    flex-shrink: 0;
}
#hiag-chat-header-name {
    color: var(--hiag-white);
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
}
#hiag-chat-header-sub {
    color: rgba(255,255,255,0.78);
    font-size: 12px;
    margin-top: 2px;
}

/* --- Messages Scroll Area --- */
#hiag-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px 12px 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    scroll-behavior: smooth;
    background: var(--hiag-bg);
}
#hiag-chat-messages::-webkit-scrollbar { width: 4px; }
#hiag-chat-messages::-webkit-scrollbar-track { background: transparent; }
#hiag-chat-messages::-webkit-scrollbar-thumb { background: var(--hiag-border); border-radius: 4px; }

/* --- Message rows --- */
.hiag-msg {
    display: flex;
    flex-direction: column;
}
.hiag-msg-user {
    align-items: flex-end;
}
.hiag-msg-bot {
    align-items: flex-start;
}

/* --- Bubbles --- */
.hiag-bubble {
    max-width: 82%;
    padding: 10px 14px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.55;
    word-wrap: break-word;
    white-space: normal;
}
.hiag-bubble-user {
    white-space: pre-wrap;
}
.hiag-bubble-user {
    background: var(--hiag-primary);
    color: var(--hiag-white);
    border-bottom-right-radius: 4px;
    white-space: pre-wrap;
}
.hiag-bubble-bot {
    background: var(--hiag-card);
    color: var(--hiag-text);
    border: 1px solid var(--hiag-border);
    border-bottom-left-radius: 4px;
}

/* Markdown-lite in bot bubbles */
.hiag-bubble-bot strong { font-weight: 700; color: var(--hiag-primary-dk); }
.hiag-bubble-bot a { color: var(--hiag-primary); text-decoration: underline; }
.hiag-bubble-bot a:hover { color: var(--hiag-primary-dk); }
.hiag-bubble-bot ul, .hiag-bubble-bot ol {
    margin: 6px 0 4px 16px;
    padding: 0;
}
.hiag-bubble-bot li { margin: 2px 0; }

/* --- Quick question chips --- */
#hiag-quick-questions {
    padding: 8px 12px 4px;
    background: var(--hiag-bg);
    border-top: 1px solid var(--hiag-border);
    flex-shrink: 0;
}
#hiag-quick-label {
    font-size: 11px;
    color: var(--hiag-text-sub);
    margin: 0 0 6px;
    font-weight: 500;
}
#hiag-quick-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.hiag-chip {
    background: #e8f4f8;
    border: 1px solid #b3d9ea;
    border-radius: 20px;
    padding: 6px 12px;
    font-size: 12px;
    color: #1a5f7a;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    white-space: nowrap;
    transition: background 0.15s, transform 0.1s;
    line-height: 1.4;
}
.hiag-chip:hover {
    background: #cceaf5;
    transform: scale(1.03);
}

/* --- Typing dots --- */
#hiag-typing {
    padding: 4px 12px 8px;
    background: var(--hiag-bg);
}
.hiag-typing-dots {
    display: flex;
    gap: 5px;
    align-items: center;
    padding: 10px 14px;
    width: fit-content;
}
.hiag-typing-dots span {
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--hiag-primary);
    opacity: 0.4;
    animation: hiag-bounce 1.2s infinite ease-in-out;
}
.hiag-typing-dots span:nth-child(1) { animation-delay: 0s; }
.hiag-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.hiag-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes hiag-bounce {
    0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
    40%            { transform: translateY(-6px); opacity: 1; }
}

/* --- Input area --- */
#hiag-chat-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--hiag-border);
    background: var(--hiag-card);
    flex-shrink: 0;
}
#hiag-chat-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--hiag-border);
    border-radius: 12px;
    padding: 9px 12px;
    font-size: 14px;
    line-height: 1.4;
    color: var(--hiag-text);
    background: var(--hiag-bg);
    outline: none;
    max-height: 100px;
    overflow-y: auto;
    font-family: inherit;
    transition: border-color 0.15s;
}
#hiag-chat-input:focus {
    border-color: var(--hiag-primary);
}
#hiag-chat-input::placeholder {
    color: var(--hiag-text-sub);
}
#hiag-chat-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--hiag-primary);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--hiag-white);
    flex-shrink: 0;
    transition: background 0.15s, transform 0.12s;
    outline: none;
}
#hiag-chat-send:hover { background: var(--hiag-primary-dk); transform: scale(1.05); }
#hiag-chat-send:disabled { background: var(--hiag-border); cursor: not-allowed; transform: none; }
#hiag-chat-send:focus-visible { outline: 3px solid var(--hiag-accent); outline-offset: 2px; }
