/* 408: live-chat bubble (Views/Shared/_ChatWidget.cshtml, js/rt-chat-widget.js).
   Everything is scoped under .rtc so the public site's and the tenant portal's own styles
   cannot reach in, and these cannot leak out. */
.rtc {
    --rtc-brand: #F96302;
    --rtc-brand-dark: #d95400;
    --rtc-ink: #1f2933;
    --rtc-muted: #6b7280;
    --rtc-line: #e5e7eb;
    --rtc-bg: #ffffff;
    --rtc-soft: #f4f5f7;
    --rtc-shadow: 0 12px 40px rgba(15, 23, 42, .18), 0 2px 8px rgba(15, 23, 42, .08);
    --rtc-gap: 20px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.45;
    color: var(--rtc-ink);
}
.rtc *, .rtc *::before, .rtc *::after { box-sizing: border-box; }
.rtc [hidden] { display: none !important; }

/* ── launcher ──────────────────────────────────────────────────────────────── */
.rtc-launcher {
    position: fixed; right: var(--rtc-gap); bottom: var(--rtc-gap); z-index: 1060;
    width: 58px; height: 58px; border-radius: 50%; border: 0;
    background: var(--rtc-brand); color: #fff; font-size: 24px;
    box-shadow: 0 6px 20px rgba(249, 99, 2, .35);
    cursor: pointer; display: grid; place-items: center;
    transition: transform .15s ease, background .15s ease;
}
.rtc-launcher:hover { background: var(--rtc-brand-dark); transform: scale(1.05); }
.rtc-launcher:focus-visible { outline: 3px solid rgba(249, 99, 2, .45); outline-offset: 3px; }
.rtc-launcher .rtc-ico-close { display: none; }
.rtc.is-open .rtc-launcher .rtc-ico-open { display: none; }
.rtc.is-open .rtc-launcher .rtc-ico-close { display: inline-block; }
.rtc-badge {
    position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 6px;
    border-radius: 10px; background: #dc2626; color: #fff; font-size: 11px; font-weight: 700;
    line-height: 20px; text-align: center; border: 2px solid #fff;
}
/* Tenant app: sit above the bottom tab bar. */
.rt-app .rtc-launcher { bottom: calc(var(--rtapp-bar-h, 60px) + 14px + env(safe-area-inset-bottom)); }
.rt-app .rtc-panel { bottom: calc(var(--rtapp-bar-h, 60px) + 84px + env(safe-area-inset-bottom)); }

/* ── panel ─────────────────────────────────────────────────────────────────── */
.rtc-panel {
    position: fixed; right: var(--rtc-gap); bottom: calc(var(--rtc-gap) + 72px); z-index: 1061;
    width: 380px; max-width: calc(100vw - 32px);
    height: 600px; max-height: calc(100vh - 120px);
    background: var(--rtc-bg); border-radius: 16px; box-shadow: var(--rtc-shadow);
    display: flex; flex-direction: column; overflow: hidden;
    animation: rtc-pop .18s ease-out;
}
@keyframes rtc-pop { from { opacity: 0; transform: translateY(12px) scale(.98); } to { opacity: 1; transform: none; } }

.rtc-head {
    display: flex; align-items: center; gap: 8px; padding: 14px 12px 14px 8px;
    border-bottom: 1px solid var(--rtc-line); background: var(--rtc-bg);
}
.rtc-head-text { flex: 1; min-width: 0; }
.rtc-title { font-weight: 700; font-size: 16px; display: flex; align-items: center; gap: 6px; }
.rtc-sub { color: var(--rtc-muted); font-size: 12px; }
.rtc-dot { width: 8px; height: 8px; border-radius: 50%; background: #9ca3af; display: inline-block; }
.rtc-dot.is-on { background: #10b981; box-shadow: 0 0 0 3px rgba(16, 185, 129, .18); }
.rtc-icon-btn {
    width: 34px; height: 34px; border: 0; background: transparent; border-radius: 8px;
    color: var(--rtc-ink); cursor: pointer; font-size: 16px;
}
.rtc-icon-btn:hover { background: var(--rtc-soft); }
.rtc-menu-wrap { position: relative; }
.rtc-menu {
    position: absolute; right: 0; top: 38px; z-index: 2; min-width: 200px;
    background: #fff; border: 1px solid var(--rtc-line); border-radius: 10px; box-shadow: var(--rtc-shadow);
    padding: 6px;
}
.rtc-menu button {
    display: block; width: 100%; text-align: left; padding: 9px 10px; border: 0; background: none;
    border-radius: 6px; cursor: pointer; color: var(--rtc-ink); font-size: 13px;
}
.rtc-menu button:hover { background: var(--rtc-soft); }

.rtc-body { flex: 1; overflow-y: auto; padding: 16px; background: #fafafa; overscroll-behavior: contain; }

/* pre-chat form */
.rtc-intro { display: flex; flex-direction: column; gap: 10px; }
.rtc-hello { background: #fff; border: 1px solid var(--rtc-line); border-radius: 12px; padding: 12px 14px; }
.rtc-hello p { margin: 4px 0 0; color: var(--rtc-muted); font-size: 13px; }
.rtc-fields { display: flex; flex-direction: column; gap: 8px; }
.rtc-intro label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; font-weight: 600; color: var(--rtc-muted); }
.rtc input, .rtc textarea {
    width: 100%; border: 1px solid #d1d5db; border-radius: 8px; padding: 9px 10px;
    font: inherit; font-weight: 400; color: var(--rtc-ink); background: #fff; resize: none;
}
.rtc input:focus, .rtc textarea:focus { outline: none; border-color: var(--rtc-brand); box-shadow: 0 0 0 3px rgba(249, 99, 2, .15); }

.rtc-primary {
    border: 0; border-radius: 10px; background: var(--rtc-brand); color: #fff; font-weight: 600;
    padding: 11px 16px; cursor: pointer; font-size: 15px; width: 100%;
}
.rtc-primary:hover { background: var(--rtc-brand-dark); }
.rtc-primary:disabled { opacity: .6; cursor: default; }
.rtc-primary.rtc-small { width: auto; padding: 8px 16px; font-size: 13px; align-self: flex-end; }
.rtc-error { color: #b91c1c; font-size: 12px; }

/* thread */
.rtc-thread { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.rtc-day { align-self: center; font-size: 11px; color: var(--rtc-muted); margin: 6px 0; }
.rtc-msg { display: flex; flex-direction: column; max-width: 82%; }
.rtc-msg .rtc-bubble {
    padding: 9px 13px; border-radius: 16px; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere;
}
.rtc-msg .rtc-meta { font-size: 10.5px; color: var(--rtc-muted); margin-top: 2px; padding: 0 4px; }
.rtc-msg.is-me { align-self: flex-end; align-items: flex-end; }
.rtc-msg.is-me .rtc-bubble { background: var(--rtc-brand); color: #fff; border-bottom-right-radius: 4px; }
.rtc-msg.is-them { align-self: flex-start; }
.rtc-msg.is-them .rtc-bubble { background: #fff; border: 1px solid var(--rtc-line); border-bottom-left-radius: 4px; }
.rtc-msg.is-pending .rtc-bubble { opacity: .6; }
.rtc-msg.is-failed .rtc-bubble { background: #fee2e2; color: #991b1b; }
.rtc-sys { align-self: center; font-size: 12px; color: var(--rtc-muted); font-style: italic; margin: 6px 0; text-align: center; }

.rtc-typing { display: inline-flex; gap: 4px; padding: 10px 14px; background: #fff; border: 1px solid var(--rtc-line); border-radius: 16px; margin-top: 6px; }
.rtc-typing span { width: 6px; height: 6px; border-radius: 50%; background: #9ca3af; animation: rtc-blink 1.2s infinite; }
.rtc-typing span:nth-child(2) { animation-delay: .2s; }
.rtc-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes rtc-blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

/* rating */
.rtc-rate { margin-top: 14px; background: #fff; border: 1px solid var(--rtc-line); border-top: 3px solid var(--rtc-brand); border-radius: 12px; padding: 16px; text-align: center; }
.rtc-rate-q { font-weight: 700; margin: 0 0 10px; }
.rtc-stars { display: flex; justify-content: center; gap: 10px; }
.rtc-stars button { border: 0; background: none; font-size: 26px; color: #9ca3af; cursor: pointer; padding: 0; }
.rtc-stars button.is-on { color: #f59e0b; }
.rtc-rate-more { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.rtc-rate-done { margin: 8px 0 0; color: #047857; font-weight: 600; }

/* footer */
.rtc-foot { border-top: 1px solid var(--rtc-line); padding: 10px 12px 8px; background: var(--rtc-bg); display: flex; flex-direction: column; gap: 6px; }
.rtc-composer { display: flex; align-items: flex-end; gap: 8px; }
.rtc-composer textarea { max-height: 120px; min-height: 40px; border-radius: 20px; padding: 10px 14px; overflow-y: hidden; }
.rtc-send {
    flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; background: var(--rtc-brand); color: #fff;
    cursor: pointer; font-size: 15px;
}
.rtc-send:hover { background: var(--rtc-brand-dark); }
.rtc-foot-msg { text-align: center; }
.rtc-powered { text-align: center; font-size: 11px; color: #9ca3af; }

/* phones: full screen */
@media (max-width: 520px) {
    .rtc.is-open .rtc-panel { inset: 0; width: 100%; max-width: none; height: 100%; max-height: none; border-radius: 0; }
    .rtc.is-open .rtc-launcher { display: none; }
    .rt-app .rtc.is-open .rtc-panel { bottom: 0; }
    .rtc-body { padding: 12px; }
}

@media (prefers-reduced-motion: reduce) {
    .rtc-panel, .rtc-typing span { animation: none; }
    .rtc-launcher { transition: none; }
}
