/* ============================================================
   DHH Chatbot — Public Styles
   ============================================================ */

/* CSS custom properties (overridden by JS via inline style on root) */
#dhh-chatbot-root {
    --dhh-primary:    #1a3a2a;
    --dhh-primary-lt: #2a5a40;
    --dhh-accent:     #c8963e;
    --dhh-bg:         #ffffff;
    --dhh-msg-user:   #e8f0eb;
    --dhh-msg-bot:    #f7f4ef;
    --dhh-text:       #1a1a1a;
    --dhh-border:     #d4ccc0;
    --dhh-radius:     14px;
    --dhh-shadow:     0 8px 40px rgba(0,0,0,.22);
    font-family: Georgia, 'Times New Roman', serif;
    position: fixed;
    z-index: 99999;
}

/* ---- Toggle Button ---- */
#dhh-chat-toggle {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    background: var(--dhh-primary);
    border-radius: 50%;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,.3);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: background .2s, transform .15s;
}
#dhh-chat-toggle:hover { background: var(--dhh-primary-lt); transform: scale(1.08); }
#dhh-chat-toggle svg   { width: 28px; height: 28px; fill: #fff; }
#dhh-chat-toggle .dhh-badge {
    position: absolute;
    top: -4px; right: -4px;
    background: var(--dhh-accent);
    color: #fff;
    border-radius: 50%;
    width: 18px; height: 18px;
    font-size: 11px;
    display: flex; align-items: center; justify-content: center;
    font-family: sans-serif;
    display: none;
}

/* ---- Chat Window ---- */
#dhh-chat-window {
    position: fixed;
    bottom: 96px;
    right: 24px;
    width: 380px;
    max-height: 580px;
    background: var(--dhh-bg);
    border-radius: var(--dhh-radius);
    box-shadow: var(--dhh-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.9) translateY(20px);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s, transform .25s;
    border: 1px solid var(--dhh-border);
}
#dhh-chat-window.dhh-open {
    opacity: 1;
    transform: scale(1) translateY(0);
    pointer-events: all;
}

/* left position variant */
#dhh-chatbot-root.dhh-left #dhh-chat-toggle,
#dhh-chatbot-root.dhh-left #dhh-chat-window {
    right: auto;
    left: 24px;
}

/* ---- Header ---- */
.dhh-chat-header {
    background: var(--dhh-primary);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}
.dhh-chat-header-icon {
    width: 34px; height: 34px;
    background: rgba(255,255,255,.15);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 18px;
}
.dhh-chat-header-info { flex: 1; }
.dhh-chat-header-title { font-weight: 700; font-size: 15px; margin: 0; }
.dhh-chat-header-sub   { font-size: 11px; opacity: .7; font-family: sans-serif; }
.dhh-chat-close {
    background: none; border: none; color: #fff; cursor: pointer;
    font-size: 20px; line-height: 1; opacity: .7; padding: 4px;
}
.dhh-chat-close:hover { opacity: 1; }

/* ---- Messages ---- */
.dhh-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    scroll-behavior: smooth;
}

.dhh-message {
    max-width: 88%;
    padding: 10px 14px;
    border-radius: 12px;
    line-height: 1.55;
    font-size: 14px;
    word-break: break-word;
    animation: dhh-fade-in .2s ease;
}
@keyframes dhh-fade-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.dhh-message-user {
    background: var(--dhh-msg-user);
    align-self: flex-end;
    border-bottom-right-radius: 3px;
    color: var(--dhh-text);
}
.dhh-message-bot {
    background: var(--dhh-msg-bot);
    align-self: flex-start;
    border-bottom-left-radius: 3px;
    color: var(--dhh-text);
    border: 1px solid var(--dhh-border);
}

/* Sources panel inside bot message */
.dhh-sources {
    margin-top: 10px;
    padding-top: 8px;
    border-top: 1px dashed var(--dhh-border);
    font-size: 12px;
    font-family: sans-serif;
}
.dhh-sources strong { display: block; margin-bottom: 4px; color: var(--dhh-primary); }
.dhh-sources a { color: var(--dhh-primary-lt); text-decoration: underline; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Typing indicator */
.dhh-typing {
    display: flex; gap: 5px; align-items: center; padding: 10px 14px;
    background: var(--dhh-msg-bot);
    border-radius: 12px; border-bottom-left-radius: 3px;
    align-self: flex-start;
    border: 1px solid var(--dhh-border);
}
.dhh-dot {
    width: 7px; height: 7px;
    background: #999;
    border-radius: 50%;
    animation: dhh-bounce 1.2s infinite;
}
.dhh-dot:nth-child(2) { animation-delay: .2s; }
.dhh-dot:nth-child(3) { animation-delay: .4s; }
@keyframes dhh-bounce {
    0%,60%,100% { transform: translateY(0); }
    30%          { transform: translateY(-6px); }
}

/* ---- Input Area ---- */
.dhh-chat-footer {
    border-top: 1px solid var(--dhh-border);
    padding: 10px 12px;
    background: #fafaf8;
}
.dhh-chat-input-row {
    display: flex; gap: 8px;
}
.dhh-chat-input {
    flex: 1;
    border: 1px solid var(--dhh-border);
    border-radius: 8px;
    padding: 9px 12px;
    font-size: 14px;
    font-family: sans-serif;
    outline: none;
    transition: border-color .2s;
}
.dhh-chat-input:focus { border-color: var(--dhh-primary); }
.dhh-chat-send {
    background: var(--dhh-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    padding: 9px 16px;
    cursor: pointer;
    font-size: 14px;
    font-family: sans-serif;
    transition: background .2s;
    white-space: nowrap;
}
.dhh-chat-send:hover    { background: var(--dhh-primary-lt); }
.dhh-chat-send:disabled { opacity: .5; cursor: not-allowed; }
.dhh-chat-footer-note {
    font-size: 10px;
    color: #999;
    font-family: sans-serif;
    text-align: center;
    margin-top: 6px;
}

/* ---- Inline Shortcode Embed ---- */
.dhh-chatbot-inline {
    border: 1px solid var(--dhh-border, #d4ccc0);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: Georgia, serif;
    background: #fff;
}
.dhh-chatbot-inline .dhh-chat-messages { flex: 1; }
.dhh-chatbot-inline .dhh-chat-input-row {
    padding: 10px 12px;
    border-top: 1px solid #d4ccc0;
    background: #fafaf8;
}

/* ---- Mobile ---- */
@media (max-width: 480px) {
    #dhh-chat-window {
        width: calc(100vw - 20px);
        right: 10px; left: 10px;
        bottom: 84px;
    }
    #dhh-chat-toggle { right: 14px; bottom: 14px; }
}
