/* =========================================================
   ONDX — Floating chat widget (public site)
   ========================================================= */

.ondx-chat-fab {
    position: fixed;
    bottom: 24px;
    inset-inline-end: 24px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, var(--ondx-accent, #14b8a6), var(--ondx-primary, #0d9488));
    color: #fff;
    font-size: 1.35rem;
    box-shadow: 0 12px 24px -8px rgba(13, 148, 136, .55);
    cursor: pointer;
    z-index: 1080;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform var(--ondx-transition, 180ms cubic-bezier(.4,0,.2,1)),
                box-shadow 180ms cubic-bezier(.4,0,.2,1);
}
.ondx-chat-fab:hover {
    transform: translateY(-2px);
    box-shadow: 0 16px 32px -8px rgba(13, 148, 136, .65);
}
.ondx-chat-fab:active { transform: translateY(0); }

.ondx-chat-fab .ondx-chat-fab-icon-close { display: none; }
.ondx-chat-fab.open .ondx-chat-fab-icon-chat  { display: none; }
.ondx-chat-fab.open .ondx-chat-fab-icon-close { display: inline-flex; }

.ondx-chat-fab .ondx-chat-badge {
    position: absolute;
    top: -2px;
    inset-inline-end: -2px;
    background: #ef4444;
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 999px;
    min-width: 18px;
    text-align: center;
    line-height: 1.3;
    box-shadow: 0 0 0 2px var(--ondx-surface, #fff);
}

/* Panel */
.ondx-chat-panel {
    position: fixed;
    bottom: 92px;
    inset-inline-end: 24px;
    width: min(380px, calc(100vw - 32px));
    height: min(560px, calc(100vh - 120px));
    background: var(--ondx-surface, #fff);
    color: var(--ondx-text, #0f172a);
    border: 1px solid var(--ondx-border, #e2e8f0);
    border-radius: 16px;
    box-shadow: 0 24px 48px -12px rgba(15, 23, 42, .35);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 1081;
    opacity: 0;
    transform: translateY(16px) scale(.98);
    pointer-events: none;
    transition: opacity 220ms cubic-bezier(.4,0,.2,1),
                transform 220ms cubic-bezier(.4,0,.2,1);
}
.ondx-chat-panel.open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.ondx-chat-head {
    padding: 14px 16px;
    background: linear-gradient(135deg, #0d9488, #0f766e);
    color: #fff;
    display: flex;
    align-items: center;
    gap: 10px;
}
.ondx-chat-head-title { flex: 1; min-width: 0; }
.ondx-chat-head-title strong { display: block; font-weight: 700; font-size: .95rem; }
.ondx-chat-head-title small  { color: rgba(255,255,255,.85); font-size: .78rem; }
.ondx-chat-head-close {
    background: transparent; border: none;
    color: #fff; cursor: pointer;
    width: 32px; height: 32px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
}
.ondx-chat-head-close:hover { background: rgba(255,255,255,.15); }

.ondx-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: var(--ondx-bg, #f8fafc);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ondx-chat-msg {
    max-width: 85%;
    padding: 10px 12px;
    border-radius: 12px;
    font-size: .88rem;
    line-height: 1.5;
    white-space: pre-line;
    word-break: break-word;
}
.ondx-chat-msg.user {
    align-self: flex-end;
    background: var(--ondx-primary, #0d9488);
    color: #fff;
    border-end-end-radius: 4px;
}
.ondx-chat-msg.assistant {
    align-self: flex-start;
    background: var(--ondx-surface, #fff);
    color: var(--ondx-text, #0f172a);
    border: 1px solid var(--ondx-border, #e2e8f0);
    border-end-start-radius: 4px;
}
.ondx-chat-msg.assistant code {
    background: var(--ondx-surface-alt, #f1f5f9);
    padding: 1px 4px;
    border-radius: 4px;
    font-size: .82rem;
}
.ondx-chat-msg.assistant a { color: var(--ondx-primary, #0d9488); }
.ondx-chat-msg.system {
    align-self: center;
    background: transparent;
    color: var(--ondx-text-muted, #64748b);
    font-size: .78rem;
    padding: 4px 8px;
}
.ondx-chat-msg.error {
    align-self: flex-start;
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    font-size: .82rem;
}
[data-bs-theme="dark"] .ondx-chat-msg.error {
    background: #450a0a; color: #fca5a5; border-color: #7f1d1d;
}

.ondx-chat-typing {
    align-self: flex-start;
    display: inline-flex;
    gap: 4px;
    padding: 10px 14px;
    background: var(--ondx-surface, #fff);
    border: 1px solid var(--ondx-border, #e2e8f0);
    border-radius: 12px;
}
.ondx-chat-typing span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--ondx-text-subtle, #94a3b8);
    animation: ondx-typing 1.2s infinite ease-in-out;
}
.ondx-chat-typing span:nth-child(2) { animation-delay: .15s; }
.ondx-chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes ondx-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30%           { transform: translateY(-4px); opacity: 1; }
}

.ondx-chat-foot {
    padding: 10px 12px;
    background: var(--ondx-surface, #fff);
    border-top: 1px solid var(--ondx-border, #e2e8f0);
}
.ondx-chat-form {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.ondx-chat-input {
    flex: 1;
    resize: none;
    border: 1px solid var(--ondx-border, #e2e8f0);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: .9rem;
    font-family: inherit;
    max-height: 120px;
    background: var(--ondx-surface, #fff);
    color: var(--ondx-text, #0f172a);
}
.ondx-chat-input:focus {
    outline: none;
    border-color: var(--ondx-primary, #0d9488);
    box-shadow: 0 0 0 3px rgba(13, 148, 136, .15);
}
.ondx-chat-send {
    background: var(--ondx-primary, #0d9488);
    border: none;
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    font-size: .95rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background-color var(--ondx-transition, 180ms);
}
.ondx-chat-send:hover { background: var(--ondx-primary-hover, #0f766e); }
.ondx-chat-send:disabled { opacity: .5; cursor: not-allowed; }

.ondx-chat-disclaimer {
    font-size: .72rem;
    color: var(--ondx-text-muted, #64748b);
    margin-top: 6px;
    text-align: center;
}

@media (max-width: 480px) {
    .ondx-chat-panel {
        inset-inline-end: 8px;
        inset-inline-start: 8px;
        width: auto;
        bottom: 84px;
        height: calc(100vh - 120px);
    }
    .ondx-chat-fab { bottom: 16px; inset-inline-end: 16px; }
}