/* ─── Dedeho Chatbot ─────────────────────────────────────────────────────── */

:root {
    --dch-bg: linear-gradient(135deg, #4F6BED, #C94B4B);
    --dch-c1: #4F6BED;
    --dch-radius: 18px;
    --dch-w: 360px;
    --dch-h: 580px;
    --dch-z: 99990;
}

/* All selectors prefixed with #dch-root to beat theme specificity */
#dch-root,
#dch-root *,
#dch-root *::before,
#dch-root *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ── Bubble ──────────────────────────────────────────────────────────────── */

#dch-bubble {
    position: fixed !important;
    bottom: 24px !important;
    right: 24px !important;
    width: 56px !important;
    height: 56px !important;
    border-radius: 50% !important;
    background: var(--dch-bg) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    cursor: pointer !important;
    box-shadow: 0 4px 20px rgba(0,0,0,.22) !important;
    z-index: calc(var(--dch-z) + 1) !important;
    transition: transform .2s ease, box-shadow .2s ease !important;
    border: none !important;
    outline: none !important;
    user-select: none !important;
    padding: 0 !important;
    text-decoration: none !important;
}

#dch-bubble:hover  { transform: scale(1.08) !important; box-shadow: 0 6px 24px rgba(0,0,0,.28) !important; }
#dch-bubble:active { transform: scale(.96) !important; }

#dch-bubble-icon { display: block; }
#dch-bubble-x    { display: none; color: #fff; font-size: 22px; font-weight: 300; line-height: 1; }

/* ── Panel ───────────────────────────────────────────────────────────────── */

#dch-panel {
    position: fixed !important;
    bottom: 92px !important;
    right: 24px !important;
    width: var(--dch-w) !important;
    height: var(--dch-h) !important;
    max-height: calc(100vh - 120px) !important;
    background: #fff !important;
    border-radius: var(--dch-radius) !important;
    box-shadow: 0 8px 40px rgba(0,0,0,.18) !important;
    display: flex !important;
    flex-direction: column !important;
    z-index: var(--dch-z) !important;
    overflow: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateY(16px) scale(.97) !important;
    transition: opacity .22s ease, transform .22s ease !important;
}

#dch-panel.dch-open {
    opacity: 1 !important;
    pointer-events: all !important;
    transform: translateY(0) scale(1) !important;
}

/* ── Header ──────────────────────────────────────────────────────────────── */

#dch-header {
    background: var(--dch-bg) !important;
    padding: 14px 16px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: space-between !important;
    flex-shrink: 0 !important;
}

#dch-avatar {
    width: 38px !important;
    height: 38px !important;
    border-radius: 50% !important;
    background: rgba(255,255,255,.22) !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 18px !important;
    flex-shrink: 0 !important;
    overflow: hidden !important;
}

#dch-avatar img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
}

#dch-botname {
    color: #fff !important;
    font-size: 14px !important;
    font-weight: 600 !important;
    line-height: 1 !important;
    background: none !important;
    -webkit-background-clip: unset !important;
    -webkit-text-fill-color: unset !important;
}

#dch-status {
    color: rgba(255,255,255,.8) !important;
    font-size: 12px !important;
    line-height: 1 !important;
}

#dch-close {
    background: none !important;
    border: none !important;
    color: rgba(255,255,255,.8) !important;
    font-size: 20px !important;
    cursor: pointer !important;
    padding: 4px 8px !important;
    border-radius: 6px !important;
    line-height: 1 !important;
    transition: background .15s !important;
    box-shadow: none !important;
    text-shadow: none !important;
    -webkit-text-fill-color: rgba(255,255,255,.8) !important;
}
#dch-close:hover { background: rgba(255,255,255,.18) !important; color: #fff !important; -webkit-text-fill-color: #fff !important; }

/* ── Messages ────────────────────────────────────────────────────────────── */

#dch-messages {
    flex: 1 !important;
    overflow-y: auto !important;
    padding: 16px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
    scroll-behavior: smooth !important;
    background: #fff !important;
}

#dch-root .dch-msg {
    display: flex !important;
    align-items: flex-end !important;
    gap: 8px !important;
    margin: 0 !important;
    padding: 0 !important;
}

#dch-root .dch-user { justify-content: flex-end !important; }

#dch-root .dch-av {
    width: 28px !important;
    height: 28px !important;
    border-radius: 50% !important;
    background: #f0f0f0 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    font-size: 14px !important;
    flex-shrink: 0 !important;
    overflow: hidden !important;
}

#dch-root .dch-av img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    border-radius: 50% !important;
}

#dch-root .dch-bbl {
    max-width: 80% !important;
    padding: 10px 14px !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
    word-break: break-word !important;
    border-radius: 4px 16px 16px 16px !important;
    background: #f1f3f4 !important;
    color: #1a1a1a !important;
    -webkit-text-fill-color: #1a1a1a !important;
    box-shadow: none !important;
    border: none !important;
}

#dch-root .dch-user .dch-bbl {
    background: var(--dch-bg) !important;
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
    border-radius: 16px 16px 4px 16px !important;
}

#dch-root .dch-user .dch-bbl a { color: rgba(255,255,255,.9) !important; -webkit-text-fill-color: rgba(255,255,255,.9) !important; }
#dch-root .dch-bot  .dch-bbl a { color: var(--dch-c1) !important; }
#dch-root .dch-bbl strong { font-weight: 600 !important; }

/* ── Typing dots ─────────────────────────────────────────────────────────── */

#dch-root .dch-typing {
    display: flex !important;
    align-items: center !important;
    gap: 5px !important;
    padding: 14px 18px !important;
    min-width: 58px !important;
    background: #f1f3f4 !important;
}

#dch-root .dch-typing span {
    width: 8px !important;
    height: 8px !important;
    border-radius: 50% !important;
    background: #bbb !important;
    display: inline-block !important;
    animation: dch-bounce 1.3s infinite ease-in-out !important;
}
#dch-root .dch-typing span:nth-child(2) { animation-delay: .18s !important; }
#dch-root .dch-typing span:nth-child(3) { animation-delay: .36s !important; }

@keyframes dch-bounce {
    0%, 80%, 100% { transform: translateY(0);    opacity: .4; }
    40%           { transform: translateY(-7px); opacity: 1;  }
}

/* ── Suggestions ─────────────────────────────────────────────────────────── */

#dch-root .dch-suggestions {
    display: flex !important;
    flex-direction: column !important;
    gap: 7px !important;
    padding-left: 36px !important;
    margin-top: 2px !important;
}

#dch-root .dch-sugg-btn {
    background: transparent !important;
    border: 1.5px solid var(--dch-c1) !important;
    color: var(--dch-c1) !important;
    -webkit-text-fill-color: var(--dch-c1) !important;
    padding: 7px 14px !important;
    border-radius: 20px !important;
    font-size: 13px !important;
    cursor: pointer !important;
    text-align: left !important;
    transition: background .15s !important;
    line-height: 1.4 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    font-weight: 400 !important;
    width: auto !important;
    display: block !important;
    text-decoration: none !important;
}
#dch-root .dch-sugg-btn:hover {
    background: rgba(79,107,237,.09) !important;
    color: var(--dch-c1) !important;
    -webkit-text-fill-color: var(--dch-c1) !important;
}

/* ── Privacy notice ──────────────────────────────────────────────────────── */

#dch-privacy {
    background: #f7f7f7 !important;
    border-top: 1px solid #e8e8e8 !important;
    padding: 14px 16px !important;
    font-size: 13px !important;
    color: #444 !important;
    -webkit-text-fill-color: #444 !important;
    line-height: 1.55 !important;
    flex-shrink: 0 !important;
}

#dch-privacy p {
    color: #444 !important;
    -webkit-text-fill-color: #444 !important;
    font-size: 13px !important;
    margin: 0 !important;
}

#dch-privacy a {
    color: var(--dch-c1) !important;
    -webkit-text-fill-color: var(--dch-c1) !important;
    text-decoration: underline !important;
}

#dch-root .dch-btn-primary {
    background: var(--dch-bg) !important;
    color: #fff !important;
    -webkit-text-fill-color: #fff !important;
    border: none !important;
    padding: 8px 16px !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    transition: opacity .15s !important;
    box-shadow: none !important;
    text-shadow: none !important;
    line-height: 1.4 !important;
    text-decoration: none !important;
    display: inline-block !important;
}
#dch-root .dch-btn-primary:hover { opacity: .88 !important; }

#dch-root .dch-btn-secondary {
    background: transparent !important;
    color: #666 !important;
    -webkit-text-fill-color: #666 !important;
    border: 1px solid #ccc !important;
    padding: 8px 16px !important;
    border-radius: 8px !important;
    cursor: pointer !important;
    font-size: 13px !important;
    font-weight: 400 !important;
    transition: background .15s !important;
    box-shadow: none !important;
    text-shadow: none !important;
    line-height: 1.4 !important;
    text-decoration: none !important;
    display: inline-block !important;
}
#dch-root .dch-btn-secondary:hover { background: #ebebeb !important; }

/* ── Input area ──────────────────────────────────────────────────────────── */

#dch-inputarea {
    border-top: 1px solid #eee !important;
    padding: 10px 12px !important;
    display: flex !important;
    align-items: flex-end !important;
    gap: 8px !important;
    flex-shrink: 0 !important;
    background: #fff !important;
}

#dch-input {
    flex: 1 !important;
    border: 1px solid #e0e0e0 !important;
    border-radius: 20px !important;
    padding: 9px 14px !important;
    font-size: 14px !important;
    resize: none !important;
    outline: none !important;
    line-height: 1.45 !important;
    max-height: 120px !important;
    overflow-y: auto !important;
    background: #f8f8f8 !important;
    color: #1a1a1a !important;
    -webkit-text-fill-color: #1a1a1a !important;
    transition: border-color .2s, background .2s !important;
    box-shadow: none !important;
    width: auto !important;
    min-height: 0 !important;
}

#dch-input:focus {
    border-color: var(--dch-c1) !important;
    background: #fff !important;
    box-shadow: none !important;
    outline: none !important;
}

#dch-input:disabled { opacity: .45 !important; cursor: not-allowed !important; }

#dch-root .dch-icon-btn {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    border: 1px solid #e0e0e0 !important;
    background: #fff !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #888 !important;
    -webkit-text-fill-color: #888 !important;
    flex-shrink: 0 !important;
    transition: background .15s, color .15s !important;
    padding: 0 !important;
    box-shadow: none !important;
    text-shadow: none !important;
}
#dch-root .dch-icon-btn:hover { background: #f0f0f0 !important; color: #444 !important; }

#dch-root .dch-icon-btn.dch-mic-on {
    background: #fff0f0 !important;
    color: #c00 !important;
    border-color: #fcc !important;
}

#dch-root .dch-send-btn {
    width: 36px !important;
    height: 36px !important;
    border-radius: 50% !important;
    border: none !important;
    background: var(--dch-bg) !important;
    cursor: pointer !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
    color: #fff !important;
    flex-shrink: 0 !important;
    transition: opacity .15s, transform .15s !important;
    padding: 0 !important;
    box-shadow: none !important;
}
#dch-root .dch-send-btn:hover   { opacity: .88 !important; }
#dch-root .dch-send-btn:active  { transform: scale(.94) !important; }
#dch-root .dch-send-btn:disabled { opacity: .45 !important; cursor: not-allowed !important; }

/* ── Footer ──────────────────────────────────────────────────────────────── */

#dch-footer {
    text-align: center !important;
    font-size: 11px !important;
    color: #c0c0c0 !important;
    -webkit-text-fill-color: #c0c0c0 !important;
    padding: 5px !important;
    background: #fafafa !important;
    border-top: 1px solid #f0f0f0 !important;
    flex-shrink: 0 !important;
}

#dch-footer strong {
    font-weight: 600 !important;
    color: #c0c0c0 !important;
    -webkit-text-fill-color: #c0c0c0 !important;
}

/* ── Proactive callout ───────────────────────────────────────────────────── */

#dch-proactive {
    position: fixed !important;
    bottom: 90px !important;
    right: 24px !important;
    max-width: 220px !important;
    background: #fff !important;
    border: 0.5px solid #e0e0e0 !important;
    border-radius: 14px 14px 4px 14px !important;
    padding: 10px 14px !important;
    font-size: 13px !important;
    color: #1a1a1a !important;
    -webkit-text-fill-color: #1a1a1a !important;
    line-height: 1.5 !important;
    box-shadow: 0 4px 16px rgba(0,0,0,.12) !important;
    z-index: var(--dch-z) !important;
    cursor: pointer !important;
    opacity: 0 !important;
    transform: translateY(8px) !important;
    transition: opacity .3s ease, transform .3s ease !important;
    pointer-events: none !important;
}

#dch-proactive.dch-pro-visible {
    opacity: 1 !important;
    transform: translateY(0) !important;
    pointer-events: all !important;
}

#dch-proactive-close {
    position: absolute !important;
    top: 4px !important;
    right: 8px !important;
    font-size: 14px !important;
    color: #bbb !important;
    -webkit-text-fill-color: #bbb !important;
    cursor: pointer !important;
    line-height: 1 !important;
    padding: 2px !important;
}
#dch-proactive-close:hover { color: #888 !important; -webkit-text-fill-color: #888 !important; }

@media (max-width: 480px) {
    #dch-proactive { right: 16px !important; bottom: 82px !important; }
}

@media (max-width: 480px) {
    #dch-panel {
        bottom: 0 !important;
        right: 0 !important;
        width: 100% !important;
        height: 85dvh !important;
        max-height: 85dvh !important;
        border-radius: 20px 20px 0 0 !important;
    }
    #dch-bubble {
        bottom: 16px !important;
        right: 16px !important;
    }
}
