/* dream-genie.ai — AI Chatbot Widget v1.4.0 */

/* [hidden] override */
#dg-chatbot [hidden] { display: none !important; }

/* ── Root ──────────────────────────────────────────────────────────── */
#dg-chatbot {
    position: fixed; z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 14px; line-height: 1.5; box-sizing: border-box;
}
#dg-chatbot *, #dg-chatbot *::before, #dg-chatbot *::after { box-sizing: inherit; }
#dg-chatbot.dg-pos--bottom-right { bottom: 24px; right: 24px; }
#dg-chatbot.dg-pos--bottom-left  { bottom: 24px; left:  24px; }

/* ── Bubble ────────────────────────────────────────────────────────── */
.dg-bubble {
    width: 62px; height: 62px; border-radius: 50%;
    background: var(--dg-primary, #7F77DD); border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 20px rgba(0,0,0,.22);
    transition: transform .2s, box-shadow .2s;
    animation: dg-pulse 3s infinite;
}
.dg-bubble:focus-visible { outline: 3px solid var(--dg-primary, #7F77DD); outline-offset: 3px; }
@keyframes dg-pulse {
    0%   { box-shadow: 0 4px 20px rgba(0,0,0,.22), 0 0 0 0    var(--dg-primary,#7F77DD); }
    50%  { box-shadow: 0 4px 20px rgba(0,0,0,.22), 0 0 0 10px transparent; }
    100% { box-shadow: 0 4px 20px rgba(0,0,0,.22), 0 0 0 0    transparent; }
}
.dg-bubble:hover { transform: scale(1.08); }

/* ── Panel ─────────────────────────────────────────────────────────── */
.dg-panel {
    position: absolute; bottom: 74px;
    width: 390px; max-height: 600px;
    background: #fff; border-radius: 20px;
    box-shadow: 0 10px 48px rgba(0,0,0,.16);
    display: flex; flex-direction: column;
    overflow: hidden;
    animation: dg-open .22s cubic-bezier(.34,1.56,.64,1);
}
#dg-chatbot.dg-pos--bottom-right .dg-panel { right: 0; transform-origin: bottom right; }
#dg-chatbot.dg-pos--bottom-left  .dg-panel { left: 0;  transform-origin: bottom left; }
@keyframes dg-open {
    from { opacity: 0; transform: scale(.88) translateY(12px); }
    to   { opacity: 1; transform: scale(1)   translateY(0); }
}

/* ── Header ────────────────────────────────────────────────────────── */
.dg-header {
    display: flex; align-items: center; gap: 10px;
    padding: 14px 16px;
    background: var(--dg-primary, #7F77DD); color: #fff; flex-shrink: 0;
}
.dg-header-avatar { font-size: 26px; flex-shrink: 0; }
.dg-header-info   { flex: 1; min-width: 0; }
.dg-header-info strong { display: block; font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dg-header-status { font-size: 12px; opacity: .82; display: flex; align-items: center; gap: 4px; }
.dg-header-status::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: #4ade80; flex-shrink: 0; }
.dg-header-close, .dg-handoff-btn {
    background: none; border: none; color: #fff; cursor: pointer;
    width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 17px; opacity: .75; transition: opacity .15s, background .15s; flex-shrink: 0;
}
.dg-header-close:hover, .dg-handoff-btn:hover { opacity: 1; background: rgba(255,255,255,.18); }
.dg-header-close:focus-visible, .dg-handoff-btn:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.dg-handoff-btn { opacity: .7; margin-right: -2px; }

/* ── Messages ──────────────────────────────────────────────────────── */
.dg-messages {
    flex: 1; overflow-y: auto; padding: 16px 14px;
    display: flex; flex-direction: column; gap: 10px;
    scroll-behavior: smooth; min-height: 0;
}
.dg-messages::-webkit-scrollbar { width: 4px; }
.dg-messages::-webkit-scrollbar-thumb { background: rgba(0,0,0,.14); border-radius: 2px; }

.dg-msg { display: flex; gap: 8px; animation: dg-msg-in .2s ease; max-width: 100%; }
@keyframes dg-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.dg-msg--user { justify-content: flex-end; }
.dg-msg--bot  { justify-content: flex-start; align-items: flex-end; }
.dg-msg--system { justify-content: center; }
.dg-msg-avatar { font-size: 20px; flex-shrink: 0; margin-bottom: 2px; }

.dg-bubble-text {
    max-width: 80%; padding: 10px 14px; border-radius: 18px;
    word-break: break-word;
    font-size: 13.5px; line-height: 1.6;
}
.dg-msg--user .dg-bubble-text {
    background: var(--dg-primary, #7F77DD); color: #fff;
    border-bottom-right-radius: 5px; white-space: pre-wrap;
}
.dg-msg--bot .dg-bubble-text {
    background: #f1f0f7; color: #111;
    border-bottom-left-radius: 5px;
}
.dg-bubble-text img {
    max-width: 100%; border-radius: 10px; margin-top: 8px; display: block; cursor: pointer;
}

/* System messages */
.dg-system-text {
    background: #f0f9ff; color: #0369a1; font-size: 12px;
    padding: 6px 14px; border-radius: 12px; text-align: center;
    border: 1px solid #bae6fd;
}

/* ── Markdown in bot messages ──────────────────────────────────────── */
.dg-bubble-text strong { font-weight: 700; }
.dg-bubble-text em { font-style: italic; }
.dg-bubble-text a { color: var(--dg-primary, #7F77DD); text-decoration: underline; }
.dg-bubble-text a:hover { opacity: .8; }
.dg-bubble-text .dg-md-list { margin: 6px 0; padding-left: 18px; }
.dg-bubble-text .dg-md-list li { margin: 2px 0; }
.dg-bubble-text .dg-code-block {
    background: #1e1e2e; color: #cdd6f4; border-radius: 8px;
    padding: 10px 12px; margin: 8px 0; font-size: 12px;
    overflow-x: auto; white-space: pre; font-family: 'SF Mono', Consolas, monospace;
}
.dg-bubble-text .dg-inline-code {
    background: #e8e6f0; padding: 1px 5px; border-radius: 4px;
    font-family: 'SF Mono', Consolas, monospace; font-size: 12px;
}
.dg-bubble-text p { margin: 4px 0; }

/* ── Typing indicator ──────────────────────────────────────────────── */
.dg-typing-dots { display: flex; gap: 5px; padding: 4px 0; }
.dg-typing-dots span { width: 8px; height: 8px; background: #aaa; border-radius: 50%; animation: dg-bounce .9s infinite ease-in-out; }
.dg-typing-dots span:nth-child(2) { animation-delay: .16s; }
.dg-typing-dots span:nth-child(3) { animation-delay: .32s; }
@keyframes dg-bounce { 0%,60%,100%{transform:translateY(0)} 30%{transform:translateY(-7px)} }
.dg-typing-label { display: block; font-size: 11px; color: #999; margin-top: 2px; font-style: italic; }

/* ── Suggested Replies ─────────────────────────────────────────────── */
.dg-suggestions {
    display: flex; gap: 6px; padding: 6px 14px 2px;
    flex-wrap: wrap; flex-shrink: 0;
}
.dg-suggest-btn {
    background: #fff; border: 1.5px solid var(--dg-primary, #7F77DD);
    color: var(--dg-primary, #7F77DD); padding: 5px 12px; border-radius: 16px;
    font-size: 12px; font-weight: 500; cursor: pointer;
    transition: all .15s; white-space: nowrap;
}
.dg-suggest-btn:hover {
    background: var(--dg-primary, #7F77DD); color: #fff;
}
.dg-suggest-btn:focus-visible { outline: 2px solid var(--dg-primary, #7F77DD); outline-offset: 2px; }

/* ── WooCommerce Product Cards ─────────────────────────────────────── */
.dg-cards-row {
    display: flex; gap: 10px; overflow-x: auto;
    padding: 4px 0; max-width: 100%; scroll-snap-type: x mandatory;
}
.dg-product-card {
    flex: 0 0 180px; background: #fff; border: 1px solid #e5e7eb;
    border-radius: 14px; overflow: hidden; scroll-snap-align: start;
    box-shadow: 0 2px 8px rgba(0,0,0,.06); transition: box-shadow .15s;
}
.dg-product-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,.1); }
.dg-card-img { width: 100%; height: 110px; object-fit: cover; }
.dg-card-body { padding: 10px; }
.dg-card-name { display: block; font-size: 12.5px; font-weight: 600; color: #1f2937; margin-bottom: 3px; line-height: 1.3; }
.dg-card-price { font-size: 13px; font-weight: 700; color: var(--dg-primary, #7F77DD); margin-bottom: 4px; }
.dg-card-stock { display: inline-block; font-size: 10px; padding: 1px 6px; border-radius: 4px; margin-bottom: 4px; }
.dg-card-stock--in { background: #ecfdf5; color: #059669; }
.dg-card-stock--out { background: #fef2f2; color: #dc2626; }
.dg-card-desc { font-size: 11px; color: #6b7280; margin: 0 0 6px; line-height: 1.3; }
.dg-card-actions { display: flex; gap: 4px; }
.dg-card-btn {
    flex: 1; text-align: center; padding: 5px 8px; border-radius: 8px;
    font-size: 11px; font-weight: 600; text-decoration: none;
    border: 1px solid #e5e7eb; color: #374151; background: #f9fafb;
    transition: all .15s; cursor: pointer;
}
.dg-card-btn:hover { background: #f3f4f6; }
.dg-card-btn--primary {
    background: var(--dg-primary, #7F77DD); color: #fff; border-color: transparent;
}
.dg-card-btn--primary:hover { opacity: .9; }

/* ── Proactive Message Toast ───────────────────────────────────────── */
.dg-proactive {
    position: absolute; bottom: 78px;
    background: #fff; border-radius: 16px; padding: 12px 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,.15);
    display: flex; align-items: center; gap: 10px;
    max-width: 280px; opacity: 0; transform: translateY(12px) scale(.95);
    transition: all .3s cubic-bezier(.34,1.56,.64,1); cursor: pointer;
}
#dg-chatbot.dg-pos--bottom-right .dg-proactive { right: 0; }
#dg-chatbot.dg-pos--bottom-left  .dg-proactive { left: 0; }
.dg-proactive--show { opacity: 1; transform: translateY(0) scale(1); }
.dg-proactive-avatar { font-size: 22px; flex-shrink: 0; }
.dg-proactive-text { font-size: 13px; color: #374151; line-height: 1.4; flex: 1; }
.dg-proactive-close {
    background: none; border: none; color: #9ca3af; cursor: pointer;
    font-size: 18px; padding: 0; line-height: 1; flex-shrink: 0;
}
.dg-proactive-close:hover { color: #4b5563; }

/* ── Lead capture ──────────────────────────────────────────────────── */
.dg-lead {
    padding: 14px 16px; background: #faf9ff;
    border-top: 1px solid rgba(0,0,0,.07);
    flex-shrink: 0; animation: dg-msg-in .2s ease;
}
.dg-lead p { margin: 0 0 10px; font-size: 13px; color: #444; font-weight: 500; }
.dg-lead input[type=email] {
    width: 100%; padding: 9px 12px; margin-bottom: 8px;
    border: 1.5px solid #ddd; border-radius: 10px;
    font-size: 13px; outline: none; transition: border-color .15s; background: #fff;
}
.dg-lead input[type=email]:focus { border-color: var(--dg-primary, #7F77DD); }
.dg-lead-actions { display: flex; gap: 8px; }
.dg-lead-submit {
    flex: 1; padding: 9px; border-radius: 10px; border: none; cursor: pointer;
    font-size: 13px; font-weight: 600;
    background: var(--dg-primary, #7F77DD); color: #fff; transition: opacity .15s;
}
.dg-lead-submit:hover { opacity: .86; }
.dg-lead-skip {
    flex: 0 0 auto; padding: 9px 14px; border-radius: 10px; cursor: pointer;
    font-size: 13px; background: transparent; color: #888; border: 1.5px solid #ddd;
}
.dg-lead-skip:hover { border-color: #aaa; color: #555; }

/* ── Footer / input ────────────────────────────────────────────────── */
.dg-footer {
    display: flex; align-items: flex-end; gap: 8px;
    padding: 10px 12px; border-top: 1px solid rgba(0,0,0,.07); flex-shrink: 0;
}
.dg-input {
    flex: 1; padding: 9px 12px; max-height: 100px;
    border: 1.5px solid #e0e0e0; border-radius: 20px;
    resize: none; font-size: 13.5px; font-family: inherit;
    outline: none; overflow-y: auto; line-height: 1.5;
    transition: border-color .15s; background: #fff;
}
.dg-input:focus { border-color: var(--dg-primary, #7F77DD); }
.dg-send {
    width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
    background: var(--dg-primary, #7F77DD); color: #fff;
    border: none; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    transition: opacity .15s, transform .1s;
}
.dg-send:hover:not(:disabled) { opacity: .86; }
.dg-send:active { transform: scale(.92); }
.dg-send:disabled { opacity: .42; cursor: default; }
.dg-send:focus-visible { outline: 3px solid var(--dg-primary, #7F77DD); outline-offset: 3px; }

/* ── Powered by ────────────────────────────────────────────────────── */
.dg-powered {
    text-align: center; font-size: 11px; color: #c0c0c0;
    padding: 5px 12px 7px; flex-shrink: 0; letter-spacing: .02em;
}

/* ── Dark mode ─────────────────────────────────────────────────────── */
@media (prefers-color-scheme: dark) {
    .dg-panel { background: #1c1b2e; box-shadow: 0 10px 48px rgba(0,0,0,.45); }
    .dg-msg--bot .dg-bubble-text { background: #2a2940; color: #e6e4f4; }
    .dg-msg--bot .dg-bubble-text a { color: #a5b4fc; }
    .dg-bubble-text .dg-inline-code { background: #3b3860; color: #e6e4f4; }
    .dg-input { background: #2a2940; border-color: #3d3b56; color: #e6e4f4; }
    .dg-input:focus { border-color: var(--dg-primary, #7F77DD); }
    .dg-footer, .dg-lead { border-color: rgba(255,255,255,.07); }
    .dg-lead { background: #211f34; }
    .dg-lead p { color: #c0bdd8; }
    .dg-lead input[type=email] { background: #2a2940; border-color: #3d3b56; color: #e6e4f4; }
    .dg-lead-skip { border-color: #3d3b56; color: #888; }
    .dg-powered { color: #44425a; }
    .dg-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); }
    .dg-suggest-btn { background: #2a2940; border-color: #5b5787; color: #c4bff0; }
    .dg-suggest-btn:hover { background: var(--dg-primary, #7F77DD); color: #fff; }
    .dg-system-text { background: #1e293b; color: #7dd3fc; border-color: #334155; }
    .dg-product-card { background: #2a2940; border-color: #3d3b56; }
    .dg-card-name { color: #e6e4f4; }
    .dg-card-desc { color: #9ca3af; }
    .dg-card-btn { background: #1c1b2e; color: #c4bff0; border-color: #3d3b56; }
    .dg-proactive { background: #2a2940; box-shadow: 0 8px 32px rgba(0,0,0,.4); }
    .dg-proactive-text { color: #e6e4f4; }
}

/* ── Focus / Accessibility ─────────────────────────────────────────── */
#dg-chatbot *:focus-visible { outline: 2px solid var(--dg-primary, #7F77DD); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    #dg-chatbot, #dg-chatbot *, .dg-bubble, .dg-msg, .dg-proactive { animation: none !important; transition: none !important; }
}

/* ── Mobile ────────────────────────────────────────────────────────── */
@media (max-width: 440px) {
    .dg-panel { width: calc(100vw - 20px); max-height: 80vh; }
    #dg-chatbot.dg-pos--bottom-right { right: 10px; }
    #dg-chatbot.dg-pos--bottom-left  { left: 10px; }
    .dg-product-card { flex: 0 0 160px; }
    .dg-card-img { height: 90px; }
}

/* ── Voice Chat (v1.6.0) ──────────────────────────────────────────── */
.dg-mic {
    display: flex; align-items: center; justify-content: center;
    width: 34px; height: 34px; flex-shrink: 0;
    background: none; border: 1.5px solid #d1d5db; border-radius: 50%;
    color: #6b7280; cursor: pointer; transition: all .2s;
    margin: 0 2px;
}
.dg-mic:hover { border-color: #7c3aed; color: #7c3aed; background: #f5f3ff; }
.dg-mic--recording {
    background: #dc2626 !important; border-color: #dc2626 !important; color: #fff !important;
    animation: dg-mic-pulse 1s ease-in-out infinite;
}
.dg-mic--processing {
    background: #f59e0b !important; border-color: #f59e0b !important; color: #fff !important;
    animation: dg-mic-spin 1s linear infinite;
}
@keyframes dg-mic-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220,38,38,.4); }
    50% { box-shadow: 0 0 0 8px rgba(220,38,38,0); }
}
@keyframes dg-mic-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* ── Multimodal: Image attach + preview (v1.8.0) ──────────────────── */
.dg-img-btn { background: none; border: none; color: #9ca3af; cursor: pointer;
    padding: 8px 4px 8px 10px; flex-shrink: 0; transition: color .15s; line-height: 0; }
.dg-img-btn:hover { color: var(--dg-primary, #7F77DD); }
.dg-img-btn svg { display: block; }
.dg-attach-preview {
    display: none; align-items: center; gap: 8px;
    padding: 6px 10px; background: rgba(127,119,221,.06);
    border-bottom: 1px solid rgba(127,119,221,.12);
    animation: dg-fade-in .2s;
}
.dg-attach-thumb { width: 40px; height: 40px; border-radius: 6px; object-fit: cover; flex-shrink: 0; }
.dg-attach-name { flex: 1; font-size: 11px; color: #9ca3af; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dg-attach-remove { background: none; border: none; color: #ef4444; cursor: pointer; font-size: 14px; padding: 2px 4px; }
.dg-attach-remove:hover { color: #dc2626; }
.dg-input-row { display: flex; align-items: flex-end; gap: 4px; padding: 0; }
.dg-bubble-img { line-height: 0; }
.dg-bubble-img img { max-width: 200px; max-height: 200px; border-radius: 10px; display: block; cursor: pointer; }
.dg-msg--user .dg-bubble-img img { margin-left: auto; }

/* Dark mode multimodal */
@media (prefers-color-scheme: dark) {
    .dg-attach-preview { background: rgba(255,255,255,.04); border-color: rgba(255,255,255,.06); }
    .dg-img-btn { color: #6b7280; }
}

@keyframes dg-fade-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

/* ── Conversation Flow: Choice Buttons (v1.8.0) ───────────────────── */
.dg-flow-choices {
    display: flex; flex-wrap: wrap; gap: 8px;
    padding: 8px 12px; animation: dg-fade-in .25s ease;
}
.dg-flow-choice-btn {
    background: rgba(127, 119, 221, 0.08);
    border: 1.5px solid rgba(127, 119, 221, 0.25);
    border-radius: 20px;
    padding: 8px 18px;
    font-size: 13px;
    font-weight: 600;
    color: var(--dg-primary, #7F77DD);
    cursor: pointer;
    transition: all 0.2s;
    line-height: 1.3;
    white-space: nowrap;
}
.dg-flow-choice-btn:hover {
    background: var(--dg-primary, #7F77DD);
    border-color: var(--dg-primary, #7F77DD);
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(127, 119, 221, 0.3);
}
.dg-flow-choice-btn:active {
    transform: translateY(0);
}

/* Dark mode flow buttons */
@media (prefers-color-scheme: dark) {
    .dg-flow-choice-btn {
        background: rgba(127, 119, 221, 0.12);
        border-color: rgba(127, 119, 221, 0.3);
    }
}
