:root {
    --dh-primary: #0b63ce;          /* Fallback, overwritten by JS */
    --dh-primary-dark: #084a9a;
    --dh-bg: #ffffff;
    --dh-text: #1a1a1a;
    --dh-secondary-bg: #f6f8fa;
    --dh-border: #e1e4e8;
    --dh-radius: 12px;
    --dh-shadow: 0 8px 30px rgba(0,0,0,0.12);
    --dh-font: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    --dh-chat-width: 360px;
    --dh-chat-height: 560px;
}

/* Floating button (bottom‑left) with bell ring animation */
.dh-float-btn {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 99998;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--dh-primary);
    color: #fff;
    border: none;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s, box-shadow 0.2s;
    animation: dh-bell-ring 2.5s ease-in-out infinite;
    transform-origin: center;
}

@keyframes dh-bell-ring {
    0%   { transform: rotate(0) scale(1); }
    5%   { transform: rotate(8deg) scale(1.05); }
    10%  { transform: rotate(-6deg) scale(1.05); }
    15%  { transform: rotate(4deg) scale(1.02); }
    20%  { transform: rotate(-2deg) scale(1); }
    25%  { transform: rotate(0) scale(1); }
    100% { transform: rotate(0) scale(1); }
}

.dh-float-btn:hover {
    background: var(--dh-primary-dark);
    box-shadow: 0 6px 18px rgba(0,0,0,0.25);
    animation: none;              /* Stops ringing on hover */
    transform: scale(1.05);
}

.dh-float-btn:active {
    transform: scale(0.95);
}

/* Speech bubble */
.dh-float-bubble {
    position: fixed;
    bottom: 90px;
    left: 24px;
    z-index: 99997;
    background: #fff;
    border: 1px solid var(--dh-border);
    border-radius: 16px;
    padding: 10px 15px;
    max-width: 220px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.08);
    font-family: var(--dh-font);
    font-size: 13px;
    color: #333;
    display: none;
    opacity: 0;
    transition: opacity 0.4s;
    /* For absolute positioning of close button inside fixed container */
}

.dh-float-bubble::after {
    content: '';
    position: absolute;
    bottom: -8px;
    left: 20px;
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 8px solid #fff;
}

.dh-float-bubble.show {
    display: block;
    opacity: 1;
}

/* Close button inside bubble */
.dh-bubble-close {
    position: absolute;
    top: 4px;
    right: 8px;
    background: none;
    border: none;
    font-size: 16px;
    line-height: 1;
    cursor: pointer;
    color: #888;
    padding: 0;
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.dh-bubble-close:hover {
    color: #333;
}

/* Chat window */
.dh-chat-window {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 99999;
    width: var(--dh-chat-width);
    max-width: calc(100vw - 48px);
    height: var(--dh-chat-height);
    max-height: calc(100vh - 100px);
    background: var(--dh-bg);
    border-radius: var(--dh-radius);
    box-shadow: var(--dh-shadow);
    border: 1px solid var(--dh-border);
    display: none;
    flex-direction: column;
    overflow: hidden;
    font-family: var(--dh-font);
    color: var(--dh-text);
}

.dh-chat-window.open {
    display: flex;
}

.dh-chat-header {
    padding: 14px 16px;
    background: var(--dh-primary);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}

.dh-chat-header img {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
}

.dh-chat-header h4 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    flex: 1;
}

.dh-close-btn {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}

.dh-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--dh-secondary-bg);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.dh-message {
    max-width: 85%;
    padding: 10px 14px;
    border-radius: 16px;
    line-height: 1.5;
    word-wrap: break-word;
    font-size: 14px;
}

.dh-message.bot {
    align-self: flex-start;
    background: #e8f0fe;
    color: #1a1a1a;
    border-bottom-left-radius: 4px;
}

.dh-message.user {
    align-self: flex-end;
    background: var(--dh-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.dh-thinking {
    align-self: flex-start;
    background: #e8f0fe;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    padding: 10px 18px;
    display: flex;
    gap: 4px;
}

.dh-thinking span {
    width: 8px;
    height: 8px;
    background: #90a4ae;
    border-radius: 50%;
    animation: dh-bounce 1.2s infinite ease-in-out both;
}

.dh-thinking span:nth-child(1) { animation-delay: -0.32s; }
.dh-thinking span:nth-child(2) { animation-delay: -0.16s; }

@keyframes dh-bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.dh-input-area {
    display: flex;
    border-top: 1px solid var(--dh-border);
    padding: 10px;
    background: #fff;
}

.dh-input-area textarea {
    flex: 1;
    border: 1px solid var(--dh-border);
    border-radius: 20px;
    padding: 10px 16px;
    resize: none;
    font-family: inherit;
    font-size: 14px;
    outline: none;
    max-height: 80px;
}

.dh-send-btn {
    margin-left: 8px;
    background: var(--dh-primary);
    color: #fff;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

/* Mobile */
@media (max-width: 480px) {
    :root {
        --dh-chat-width: 100%;
        --dh-chat-height: 70vh;
    }
    .dh-chat-window {
        left: 0;
        right: 0;
        bottom: 0;
        max-width: 100%;
        border-radius: 12px 12px 0 0;
    }
    .dh-float-btn {
        bottom: 16px;
        left: 16px;
    }
    .dh-float-bubble {
        bottom: 80px;
        left: 16px;
    }
}