/* Rendsee Live Support Chat (Agent Josh). Self-contained so theme styles don't leak in. */
.rd-chat, .rd-chat * { box-sizing: border-box; }
.rd-chat {
    --rd-chat-red: #c1272d;
    --rd-chat-red-dark: #9e1f24;
    position: fixed; right: 20px; bottom: 20px; z-index: 2147483000;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 15px; line-height: 1.4; color: #111;
    -webkit-font-smoothing: antialiased;
}
.rd-chat-launcher {
    display: block; width: 40px; height: 35px; padding: 0; border: 0; background: none; cursor: pointer;
    filter: drop-shadow(0 3px 6px rgba(0, 0, 0, .22)); transition: transform .18s ease;
}
.rd-chat-launcher:hover { transform: scale(1.06); }
.rd-chat-launcher:focus-visible { outline: 3px solid #1a5fb4; outline-offset: 4px; border-radius: 8px; }
.rd-chat-launcher img { display: block; width: 40px; height: 35px; object-fit: fill; }
.rd-chat-badge {
    position: absolute; top: -6px; right: -4px; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
    background: #111; color: #fff; font-size: 12px; font-weight: 600; line-height: 20px; text-align: center;
}
.rd-chat-badge[hidden] { display: none; }
.rd-chat.is-open .rd-chat-launcher { display: none; }

.rd-chat-panel {
    display: none; flex-direction: column; width: 372px; height: min(600px, calc(100vh - 40px));
    background: #fff; border-radius: 16px; overflow: hidden;
    box-shadow: 0 10px 40px rgba(0, 0, 0, .22), 0 2px 8px rgba(0, 0, 0, .08);
    animation: rd-chat-in .2s ease-out;
}
.rd-chat.is-open .rd-chat-panel { display: flex; }
@keyframes rd-chat-in { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.rd-chat-header {
    display: flex; align-items: center; gap: 10px; flex: none; padding: 14px 12px 14px 18px;
    background: var(--rd-chat-red); color: #fff;
}
.rd-chat-title { flex: 1; margin: 0; font-size: 16px; font-weight: 600; letter-spacing: .1px; color: #fff; }
.rd-chat-close {
    display: grid; place-items: center; width: 32px; height: 32px; padding: 0; border: 0; border-radius: 50%;
    background: transparent; color: #fff; cursor: pointer;
}
.rd-chat-close:hover { background: rgba(255, 255, 255, .16); }
.rd-chat-close:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }
.rd-chat-close svg { width: 18px; height: 18px; }

.rd-chat-log { flex: 1; overflow-y: auto; padding: 16px 14px 8px; overscroll-behavior: contain; background: #fff; }
.rd-chat-note { margin: 2px 0 14px; text-align: center; font-size: 12.5px; color: #7a7a7a; }
.rd-chat-note.is-connecting { animation: rd-chat-pulse 1.4s ease-in-out infinite; }
@keyframes rd-chat-pulse { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
.rd-chat-group { display: flex; flex-direction: column; align-items: flex-start; margin-bottom: 12px; }
.rd-chat-group.is-customer { align-items: flex-end; }
.rd-chat-name { margin: 0 0 4px 12px; font-size: 12px; color: #6b6b6b; }
.rd-chat-bubble {
    max-width: 82%; padding: 9px 14px; margin-top: 2px; border-radius: 20px;
    background: #f1f1f3; color: #111; white-space: pre-wrap; overflow-wrap: anywhere;
}
.rd-chat-group:not(.is-customer) .rd-chat-bubble:not(:last-child) { border-bottom-left-radius: 6px; }
.rd-chat-group:not(.is-customer) .rd-chat-bubble + .rd-chat-bubble { border-top-left-radius: 6px; }
.rd-chat-group.is-customer .rd-chat-bubble { background: var(--rd-chat-red); color: #fff; }
.rd-chat-group.is-customer .rd-chat-bubble:not(:last-child) { border-bottom-right-radius: 6px; }
.rd-chat-group.is-customer .rd-chat-bubble + .rd-chat-bubble { border-top-right-radius: 6px; }
.rd-chat-bubble a { color: var(--rd-chat-red-dark); font-weight: 600; text-decoration: underline; }
.rd-chat-group.is-customer .rd-chat-bubble a { color: #fff; }
.rd-chat-bubble ul { margin: 4px 0; padding-left: 18px; white-space: normal; }
.rd-chat-bubble li { margin: 3px 0; }
.rd-chat-bubble p { margin: 0; }
.rd-chat-bubble p + p, .rd-chat-bubble p + ul, .rd-chat-bubble ul + p { margin-top: 8px; }

.rd-chat-typing { display: inline-flex; gap: 4px; padding: 13px 16px; }
.rd-chat-typing span { width: 7px; height: 7px; border-radius: 50%; background: #9a9a9a; animation: rd-chat-dot 1.2s infinite ease-in-out; }
.rd-chat-typing span:nth-child(2) { animation-delay: .15s; }
.rd-chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes rd-chat-dot { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.rd-chat-form { display: flex; align-items: flex-end; gap: 8px; flex: none; padding: 10px 12px 12px; border-top: 1px solid #ececec; background: #fff; }
.rd-chat-input {
    flex: 1; min-height: 40px; max-height: 120px; margin: 0; padding: 9px 14px; resize: none;
    border: 1px solid #dcdcdc; border-radius: 20px; background: #fff; color: #111;
    font: inherit; line-height: 1.4; outline: none;
}
.rd-chat .rd-chat-input:focus { border-color: #a9a9a9; outline: none !important; box-shadow: none !important; }
.rd-chat-input::placeholder { color: #8c8c8c; }
.rd-chat-send {
    display: grid; place-items: center; flex: none; width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%;
    background: var(--rd-chat-red); color: #fff; cursor: pointer;
}
.rd-chat-send:disabled { opacity: .45; cursor: default; }
.rd-chat-send:focus-visible { outline: 3px solid #1a5fb4; outline-offset: 2px; }
.rd-chat-send svg { width: 18px; height: 18px; margin-left: 2px; }

@media (max-width: 520px) {
    .rd-chat { right: 14px; bottom: 14px; }
    .rd-chat.is-open { inset: 0; }
    .rd-chat-panel { width: 100%; height: 100%; border-radius: 0; }
    .rd-chat-input { font-size: 16px; }
}
@media (prefers-reduced-motion: reduce) {
    .rd-chat-panel, .rd-chat-typing span { animation: none; }
    .rd-chat-launcher { transition: none; }
}
