/* Public chatbot widget */
.chat-root {
    position: fixed;
    z-index: 80;
    font-family: Manrope, sans-serif;
    width: max-content;
    max-width: calc(100vw - 40px);
    max-width: calc(100dvw - 40px);
    --chat-safe-t: env(safe-area-inset-top, 0px);
    --chat-safe-r: env(safe-area-inset-right, 0px);
    --chat-safe-b: env(safe-area-inset-bottom, 0px);
    --chat-safe-l: env(safe-area-inset-left, 0px);
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}
.chat-launcher {
    border: 0;
    border-radius: 999px;
    padding: .85rem 1.2rem;
    background: var(--ink, #07111f);
    color: #fff;
    font-weight: 700;
    cursor: grab;
    touch-action: none;
    user-select: none;
    box-shadow: 0 12px 30px rgba(7, 17, 31, .28);
    box-sizing: border-box;
    max-width: calc(100vw - 40px);
}
.chat-launcher:hover { background: #0d1a2e; }
.chat-launcher.is-dragging { cursor: grabbing; }
.chat-launcher.is-open { background: var(--orange, #f08020); color: var(--ink, #07111f); }
.chat-panel {
    position: absolute;
    right: 0;
    left: auto;
    bottom: calc(100% + 12px);
    width: min(380px, calc(100vw - 1.5rem));
    height: min(520px, calc(100dvh - 7.5rem));
    max-height: calc(100dvh - 5.5rem);
    display: flex;
    flex-direction: column;
    background: #fff;
    border: 1px solid var(--line, #d5dde8);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: 0 18px 48px rgba(7, 17, 31, .22);
}
.chat-root--anchor-right .chat-panel {
    right: 0;
    left: auto;
}
.chat-root--left-panel .chat-panel {
    right: auto;
    left: 0;
}
.chat-root--panel-below .chat-panel {
    top: calc(100% + 12px);
    bottom: auto;
}
.chat-panel[hidden] {
    display: none !important;
}
.chat-panel-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: .75rem;
    padding: .9rem 1rem;
    background: var(--ink, #07111f);
    color: #fff;
}
.chat-close {
    border: 0;
    background: transparent;
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}
.chat-log {
    flex: 1 1 auto;
    min-height: 0;
    overflow: auto;
    padding: .9rem;
    display: grid;
    gap: .7rem;
    align-content: start;
    background:
        radial-gradient(120% 80% at 100% 0%, rgba(240, 128, 32, .08), transparent 55%),
        linear-gradient(180deg, #eef3f9, #f7f9fc);
}
.chat-menu {
    display: flex;
    flex-wrap: wrap;
    gap: .4rem;
    padding: .55rem .8rem;
    border-top: 1px solid var(--line, #d5dde8);
    background: #fff;
    flex: 0 0 auto;
    max-height: 7.5rem;
    overflow: auto;
}
.chat-menu:empty {
    display: none;
    padding: 0;
    border: 0;
}
.chat-compose,
.chat-contact {
    display: grid;
    gap: .45rem;
    padding: .7rem .8rem .85rem;
    border-top: 1px solid var(--line, #d5dde8);
    background: #fff;
    flex: 0 0 auto;
}
.chat-compose[hidden],
.chat-contact[hidden] {
    display: none !important;
}
.chat-compose {
    grid-template-columns: 1fr auto;
    align-items: center;
}
.chat-contact {
    grid-template-columns: 1fr;
}
.chat-contact .chat-contact-actions {
    display: flex;
    gap: .45rem;
    flex-wrap: wrap;
}
.chat-contact .chat-contact-actions .btn {
    flex: 1 1 auto;
}
.chat-bubble {
    max-width: 88%;
    padding: .7rem .85rem;
    border-radius: 16px;
    background: #fff;
    border: 1px solid var(--line, #d5dde8);
    box-shadow: 0 6px 16px rgba(7, 17, 31, .05);
}
.chat-bubble--visitor {
    justify-self: end;
    background: linear-gradient(180deg, #fff7ef, #ffefdf);
    border-color: rgba(240, 128, 32, .4);
    border-bottom-right-radius: 6px;
}
.chat-bubble--staff {
    justify-self: start;
    background: #fff;
    border-color: #c9d6e6;
    border-bottom-left-radius: 6px;
}
.chat-bubble--bot {
    justify-self: start;
    background: linear-gradient(180deg, #0d1a2e, #07111f);
    color: #f4f7fb;
    border-color: transparent;
    border-bottom-left-radius: 6px;
}
.chat-bubble--bot .chat-bubble-who,
.chat-bubble--bot .chat-bubble-time {
    color: rgba(244, 247, 251, .72);
}
.chat-bubble--system {
    justify-self: center;
    max-width: 96%;
    background: transparent;
    border: 0;
    box-shadow: none;
    padding: .25rem .5rem;
    font-size: .84rem;
    color: var(--muted, #5b6b7c);
    text-align: center;
}
.chat-bubble--system .chat-bubble-meta {
    justify-content: center;
}
.chat-bubble-meta {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: .75rem;
    margin-bottom: .3rem;
}
.chat-bubble-who {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    color: var(--muted, #5b6b7c);
}
.chat-bubble-time {
    font-size: .7rem;
    color: var(--muted, #5b6b7c);
    white-space: nowrap;
}
.chat-bubble p { margin: 0; line-height: 1.45; font-size: .94rem; word-break: break-word; }
.chat-bubble.is-entering {
    animation: chat-bubble-in .4s ease;
}
@keyframes chat-bubble-in {
    from { opacity: 0; transform: translateY(10px) scale(.98); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}
.chat-typing {
    justify-self: start;
    display: inline-flex;
    align-items: center;
    gap: .55rem;
    max-width: 88%;
    padding: .65rem .85rem;
    border-radius: 16px;
    border-bottom-left-radius: 6px;
    background: linear-gradient(180deg, #0d1a2e, #07111f);
    color: rgba(244, 247, 251, .8);
    box-shadow: 0 6px 16px rgba(7, 17, 31, .05);
}
.chat-typing--staff {
    background: #fff;
    color: var(--muted, #5b6b7c);
    border: 1px solid #c9d6e6;
}
.chat-typing-who {
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
}
.chat-typing-dots {
    display: inline-flex;
    align-items: center;
    gap: .22rem;
}
.chat-typing-dots i {
    width: .42rem;
    height: .42rem;
    border-radius: 50%;
    background: currentColor;
    opacity: .35;
    animation: chat-typing-dot 1.2s ease-in-out infinite;
}
.chat-typing-dots i:nth-child(2) { animation-delay: .15s; }
.chat-typing-dots i:nth-child(3) { animation-delay: .3s; }
@keyframes chat-typing-dot {
    0%, 80%, 100% { opacity: .25; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-3px); }
}
.chat-menu-btn {
    border: 1px solid var(--line, #d5dde8);
    background: #fff;
    border-radius: 999px;
    padding: .4rem .75rem;
    font: inherit;
    font-size: .86rem;
    font-weight: 600;
    cursor: pointer;
}
.chat-menu-btn:hover {
    border-color: var(--orange, #f08020);
    color: var(--orange, #f08020);
}
.chat-compose input,
.chat-contact input {
    min-height: 42px;
    border: 1px solid var(--line, #d5dde8);
    border-radius: 12px;
    padding: .55rem .7rem;
    font: inherit;
    width: 100%;
    box-sizing: border-box;
}
.chat-contact p {
    margin: 0;
    font-size: .9rem;
    color: var(--muted, #5b6b7c);
}
html[dir="rtl"] .chat-bubble--visitor { justify-self: start; }
html[dir="rtl"] .chat-bubble--staff,
html[dir="rtl"] .chat-bubble--bot { justify-self: end; }
