/* =============================================================================
   DDH AI Chatbot – Widget CSS v5.0
   Thiết kế clean, professional theo mẫu reference.
   ============================================================================= */

:root {
    --ddh-green:    #1c6b4a;
    --ddh-green-dk: #144d35;
    --ddh-green-lt: #e8f5ef;
    --ddh-orange:   #f5821f;
    --ddh-white:    #ffffff;
    --ddh-bg:       #f5f7fa;
    --ddh-text:     #1a1a2e;
    --ddh-muted:    #8a94a6;
    --ddh-border:   #e4e8ef;
    --ddh-shadow:   0 12px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.08);
    --ddh-font:     -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    --ddh-z:        99998;
}

/* ============================================================
   CONTAINER – fixed position
   ============================================================ */
#ddh-chatbot-container {
    position: fixed;
    z-index: var(--ddh-z);
    font-family: var(--ddh-font);
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
    box-sizing: border-box;
}
#ddh-chatbot-container *,
#ddh-chatbot-container *::before,
#ddh-chatbot-container *::after {
    box-sizing: border-box;
}
.ddh-chatbot-bottom-right { bottom: 20px; right: 85px; }
.ddh-chatbot-bottom-left  { bottom: 20px; left:  85px; }

/* ============================================================
   LAUNCHER – FAB button + badge
   ============================================================ */
.ddh-launcher {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    position: relative;
}

/* Badge – ẩn hoàn toàn, chỉ dùng icon */
.ddh-chat-badge {
    display: none !important;
}

.ddh-fab-chat {
    width: 52px;
    height: 52px;
    min-width: 52px;
    border-radius: 50%;
    background: var(--ddh-green);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    box-shadow: 0 4px 18px rgba(28,107,74,0.45);
    transition: transform 0.22s, box-shadow 0.22s, background 0.18s;
    outline: none;
    position: relative;
    flex-shrink: 0;
}
.ddh-fab-chat:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 24px rgba(28,107,74,0.55);
    background: var(--ddh-green-dk);
}
.ddh-fab-chat svg {
    width: 24px;
    height: 24px;
    display: block;
}

/* Pulse ring */
.ddh-fab-chat::before {
    content: '';
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    border: 2.5px solid rgba(28,107,74,0.4);
    animation: ddh-pulse 2.5s ease-out infinite;
    pointer-events: none;
}
@keyframes ddh-pulse {
    0%   { transform: scale(1);    opacity: 0.8; }
    100% { transform: scale(1.7);  opacity: 0;   }
}

/* ============================================================
   CHAT WINDOW
   ============================================================ */
.ddh-chatbot-window {
    position: absolute;
    width: 375px;
    height: 560px;
    background: var(--ddh-white);
    border-radius: 20px;
    box-shadow: var(--ddh-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.ddh-chatbot-bottom-right .ddh-chatbot-window {
    bottom: 62px;
    right: -61px;
}
.ddh-chatbot-bottom-left .ddh-chatbot-window {
    bottom: 62px;
    left: -61px;
}

/* Entrance animation */
.ddh-window-enter {
    animation: ddh-popup 0.30s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}
@keyframes ddh-popup {
    from { transform: translateY(16px) scale(0.95); opacity: 0; }
    to   { transform: translateY(0)    scale(1);    opacity: 1; }
}

/* ============================================================
   HEADER
   ============================================================ */
.ddh-chat-header {
    background: var(--ddh-green);
    padding: 0 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
    height: 68px;
    min-height: 68px;
}

/* Avatar circle with SVG icon */
.ddh-header-logo-wrap {
    position: relative;
    flex-shrink: 0;
}
.ddh-header-logo {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    background: rgba(255,255,255,0.18);
    border: 2px solid rgba(255,255,255,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
}
.ddh-header-logo svg {
    width: 28px;
    height: 28px;
    display: block;
}
.ddh-online-dot {
    width: 12px;
    height: 12px;
    background: #4ade80;
    border-radius: 50%;
    border: 2.5px solid var(--ddh-green);
    position: absolute;
    bottom: 0;
    right: 0;
}

/* Name & subtitle */
.ddh-header-info { flex: 1; min-width: 0; }
.ddh-header-name {
    font-size: 15px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.ddh-header-sub {
    font-size: 11.5px;
    color: rgba(255,255,255,0.70);
    margin-top: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Action buttons */
.ddh-header-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
}
.ddh-header-btn {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    border: none;
    background: rgba(255,255,255,0.18);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.18s;
    outline: none;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
}
.ddh-header-btn:hover {
    background: rgba(255,255,255,0.35);
}
.ddh-header-btn svg {
    width: 15px;
    height: 15px;
    display: block;
    flex-shrink: 0;
    pointer-events: none;
    stroke: #ffffff;
    fill: none;
}
.ddh-header-btn svg * {
    stroke: inherit;
}

/* ============================================================
   MESSAGES AREA
   ============================================================ */
.ddh-messages {
    flex: 1;
    overflow-y: auto;
    padding: 18px 16px 8px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--ddh-white);
    scroll-behavior: smooth;
    min-height: 0;
}
.ddh-messages::-webkit-scrollbar { width: 4px; }
.ddh-messages::-webkit-scrollbar-thumb {
    background: #d1d9e0;
    border-radius: 2px;
}

/* Message row */
.ddh-msg {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-width: 85%;
    animation: ddh-msg-in 0.2s ease both;
}
@keyframes ddh-msg-in {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.ddh-msg-bot  { align-self: flex-start; }
.ddh-msg-user { align-self: flex-end; }

/* Bubble */
.ddh-msg-bubble {
    padding: 11px 15px;
    border-radius: 18px;
    font-size: 13.5px;
    line-height: 1.65;
    word-break: break-word;
    white-space: pre-wrap;
}
.ddh-msg-bot .ddh-msg-bubble {
    background: #f0f2f5;
    color: var(--ddh-text);
    border-bottom-left-radius: 4px;
}
.ddh-msg-user .ddh-msg-bubble {
    background: var(--ddh-green);
    color: #fff;
    border-bottom-right-radius: 4px;
    box-shadow: 0 2px 8px rgba(28,107,74,0.25);
}
.ddh-msg-bubble strong { font-weight: 700; }
.ddh-msg-bubble em     { font-style: italic; }

/* Time */
.ddh-msg-time {
    font-size: 10px;
    color: var(--ddh-muted);
    padding: 0 4px;
    line-height: 1;
}
.ddh-msg-user .ddh-msg-time { text-align: right; }

/* ============================================================
   TYPING INDICATOR
   ============================================================ */
.ddh-typing-indicator {
    align-self: flex-start;
    padding: 0 16px 6px;
    display: flex;
    align-items: center;
    background: var(--ddh-white);
    flex-shrink: 0;
}
.ddh-typing-dots {
    background: #f0f2f5;
    border-radius: 18px;
    border-bottom-left-radius: 4px;
    padding: 10px 16px;
    display: flex;
    gap: 5px;
    align-items: center;
}
.ddh-typing-dots span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #9ca3af;
    animation: ddh-bounce 1.1s ease-in-out infinite;
}
.ddh-typing-dots span:nth-child(2) { animation-delay: 0.18s; }
.ddh-typing-dots span:nth-child(3) { animation-delay: 0.36s; }
@keyframes ddh-bounce {
    0%, 60%, 100% { transform: translateY(0);    opacity: 0.5; }
    30%            { transform: translateY(-5px); opacity: 1;   }
}

/* ============================================================
   QUICK REPLIES
   ============================================================ */
.ddh-quick-replies {
    display: flex;
    flex-wrap: nowrap;
    gap: 8px;
    padding: 10px 16px 10px;
    overflow-x: auto;
    background: var(--ddh-white);
    border-top: 1px solid #edf0f4;
    flex-shrink: 0;
    scrollbar-width: none;
}
.ddh-quick-replies::-webkit-scrollbar { display: none; }

.ddh-quick-btn {
    white-space: nowrap;
    padding: 7px 15px;
    border-radius: 24px;
    border: 1.5px solid var(--ddh-green);
    background: #fff;
    color: var(--ddh-green);
    font-size: 12.5px;
    font-weight: 500;
    font-family: var(--ddh-font);
    cursor: pointer;
    transition: background 0.15s, color 0.15s, transform 0.12s;
    outline: none;
    flex-shrink: 0;
    line-height: 1.4;
}
.ddh-quick-btn:hover {
    background: var(--ddh-green);
    color: #fff;
    transform: translateY(-1px);
}

/* ============================================================
   INPUT AREA
   ============================================================ */
.ddh-input-area {
    background: var(--ddh-white);
    padding: 8px 12px 10px;
    flex-shrink: 0;
    border-top: 1px solid #edf0f4;
}

.ddh-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #f0f2f5;
    border-radius: 22px;
    padding: 6px 6px 6px 14px;
    min-height: 40px;
}

.ddh-input {
    flex: 1;
    min-width: 0;
    border: none;
    background: transparent;
    outline: none;
    resize: none;
    font-family: var(--ddh-font);
    font-size: 13px;
    color: var(--ddh-text);
    line-height: 1.45;
    /* Single-line height by default, grows with content */
    height: 22px;
    max-height: 66px;
    overflow-y: hidden;
    padding: 0;
    margin: 0;
    display: block;
    scrollbar-width: none;
}
.ddh-input.ddh-input-expanded { overflow-y: auto; }
.ddh-input::-webkit-scrollbar { display: none; }
.ddh-input::placeholder { color: #a0aab4; }

/* Send button – small green circle */
.ddh-send-btn {
    width: 30px;
    height: 30px;
    min-width: 30px;
    border-radius: 50%;
    background: var(--ddh-green);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(28,107,74,0.30);
    transition: background 0.18s, transform 0.14s;
    outline: none;
    padding: 0;
    align-self: center;
}
.ddh-send-btn:hover  { background: var(--ddh-green-dk); transform: scale(1.08); }
.ddh-send-btn:active { transform: scale(0.92); }
.ddh-send-btn:disabled { opacity: 0.55; cursor: not-allowed; }
.ddh-send-btn svg {
    width: 13px;
    height: 13px;
    display: block;
}

/* ============================================================
   HIDE – arcu-widget / arcontactus speech bubble prompt
   ============================================================ */
.arcu-widget .arcu-prompt,
.arcontactus-widget .arcontactus-prompt,
.arcontactus-widget .arcontactus-prompt.active,
.arcu-widget [class*="prompt"] {
    display: none !important;
    opacity:  0   !important;
    visibility: hidden !important;
}

/* ============================================================
   MOBILE – Ẩn các thành phần không cần thiết, căn chỉnh chatbot
   ============================================================ */
@media (max-width: 768px) {
    /* ẨN: Left contact bar (#arcontactus) trên mobile */
    #arcontactus,
    .arcu-widget.left,
    .arcontactus-widget.left {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    /* ẨN: Scroll-to-top trên mobile */
    #wpfront-scroll-top-container,
    #scroll-to-top,
    .back-to-top,
    [class*="scroll-top"],
    [id*="scroll-top"],
    [class*="back-top"],
    [id*="back-top"] {
        display: none !important;
        opacity: 0 !important;
        visibility: hidden !important;
        pointer-events: none !important;
    }

    /* arcu contact widget phải (nếu có) – giữ nguyên */
    .arcu-widget.right.arcu-message {
        bottom: 20px !important;
        right:  20px !important;
    }

    /* Chat AI: sát góc phải dưới, right: 20px */
    .ddh-chatbot-bottom-right { bottom: 20px; right: 20px; }
    .ddh-chatbot-bottom-left  { bottom: 20px; left:  20px; }

    /* Chat window chiếm gần full màn hình */
    .ddh-chatbot-window {
        width: calc(100vw - 24px);
        height: calc(100dvh - 100px);
        border-radius: 16px;
    }
    .ddh-chatbot-bottom-right .ddh-chatbot-window {
        right: -4px;
        bottom: 62px;
    }
    .ddh-chatbot-bottom-left .ddh-chatbot-window {
        left: -4px;
        bottom: 62px;
    }

    /* Ẩn pulse animation trên mobile để đỡ tốn pin */
    .ddh-fab-chat::before { display: none; }
}

@media (max-width: 440px) {
    /* Chat AI: sát góc phải dưới, right: 20px */
    .ddh-chatbot-bottom-right { bottom: 20px; right: 20px; }
    .ddh-chatbot-bottom-left  { bottom: 20px; left:  20px; }
    .ddh-chatbot-window {
        width: calc(100vw - 16px);
        height: calc(100dvh - 90px);
        border-radius: 14px;
    }
    .ddh-chatbot-bottom-right .ddh-chatbot-window { right: -4px; }
    .ddh-chatbot-bottom-left  .ddh-chatbot-window { left:  -4px; }
}
