/* =========================================================
   PSR Compliance — AI Chat Widget (Step 1: UI only)
   Drop-in styles. Inherits site fonts; only sets its own
   color/spacing tokens below so it's easy to re-theme in
   one place once you confirm your exact brand hex values.
   ========================================================= */

:root {
    --psr-chat-primary: #0F62D6;       /* swap to your brand accent */
    --psr-chat-primary-dark: #0A47A0;
    --psr-chat-online: #25D366;        /* reused from your WhatsApp CTA */
    --psr-chat-ink: #12151C;
    --psr-chat-paper: #FFFFFF;
    --psr-chat-mist: #F3F5F9;
    --psr-chat-border: #E5E8EF;
    --psr-chat-muted: #6B7280;
    --psr-chat-radius: 18px;
    --psr-chat-shadow: 0 20px 48px rgba(15, 23, 42, 0.18), 0 4px 12px rgba(15, 23, 42, 0.08);
}

/* ---------- Desktop floating launcher ---------- */
.psr-chat-launcher {
    position: fixed;
    right: 10px;
    bottom: 15px;
    z-index: 9998;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--psr-chat-primary);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 12px 15px 12px 15px;
    box-shadow: var(--psr-chat-shadow);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    line-height: 1;
    transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.psr-chat-launcher:hover {
    transform: translateY(-2px);
    background: var(--psr-chat-primary-dark);
}
.psr-chat-launcher:active { transform: translateY(0); }

.psr-chat-launcher .psr-chat-icon-wrap {
    position: relative;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}
.psr-chat-launcher .psr-chat-ring {
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 1.5px solid rgba(255,255,255,0.55);
    animation: psrChatPulse 2.2s ease-out infinite;
}
.psr-chat-launcher .psr-chat-ring--delay { animation-delay: 1.1s; }
@keyframes psrChatPulse {
    0%   { transform: scale(0.8); opacity: 0.8; }
    100% { transform: scale(1.6); opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
    .psr-chat-launcher .psr-chat-ring { animation: none; }
}

.psr-chat-launcher-label { white-space: nowrap; }

/* On mobile, keep the launcher but shrink it to an icon-only floating
   button on the bottom-right, offset above the Call/WhatsApp CTA bar
   so the two never overlap or share a row. */
@media (max-width: 767.98px) {
    .psr-chat-launcher {
        right: 16px;
        bottom: 50px;
        padding: 0;
        width: 54px;
        height: 54px;
        justify-content: center;
        gap: 0;
    }
    .psr-chat-launcher .psr-chat-launcher-label {
        display: none;
    }
}

/* ---------- Chat panel ---------- */
.psr-chat-panel {
    position: fixed;
    right: 24px;
    bottom: 24px;
    z-index: 9999;
    width: 380px;
    max-width: calc(100vw - 32px);
    height: 560px;
    max-height: calc(100vh - 48px);
    background: var(--psr-chat-paper);
    border-radius: var(--psr-chat-radius);
    box-shadow: var(--psr-chat-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.98);
    pointer-events: none;
    transition: opacity 0.2s ease, transform 0.2s ease;
}
.psr-chat-panel.psr-chat-open {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}
.psr-chat-panel.psr-chat-minimized {
    height: 64px;
}
.psr-chat-panel.psr-chat-minimized .psr-chat-body,
.psr-chat-panel.psr-chat-minimized .psr-chat-footer {
    display: none;
}

@media (max-width: 767.98px) {
    .psr-chat-panel {
        right: 0;
        left: 0;
        bottom: 0;
        width: 100%;
        max-width: 100%;
        height: 100dvh;
        max-height: 100dvh;
        border-radius: 0;
    }
    .psr-chat-panel.psr-chat-minimized { height: 100dvh; } /* minimize = fully close on mobile */
}

/* ---------- Header ---------- */
.psr-chat-header {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 14px 14px 16px;
    background: var(--psr-chat-ink);
    color: #fff;
}
.psr-chat-badge {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--psr-chat-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
}
.psr-chat-header-text { flex: 1 1 auto; min-width: 0; }
.psr-chat-header-title {
    font-size: 14px;
    font-weight: 700;
    margin: 0;
    line-height: 1.2;
}
.psr-chat-header-status {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    color: #C7CCDA;
    margin-top: 2px;
}
.psr-chat-header-status .dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--psr-chat-online);
    box-shadow: 0 0 0 2px rgba(37,211,102,0.25);
}
.psr-chat-header-actions { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; }
.psr-chat-icon-btn {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: #C7CCDA;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.psr-chat-icon-btn:hover { background: rgba(255,255,255,0.1); color: #fff; }

/* ---------- Body / messages ---------- */
.psr-chat-body {
    flex: 1 1 auto;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: var(--psr-chat-mist);
}
.psr-chat-body::-webkit-scrollbar { width: 6px; }
.psr-chat-body::-webkit-scrollbar-thumb { background: #D6DAE3; border-radius: 999px; }

.psr-chat-msg {
    max-width: 82%;
    padding: 10px 13px;
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-wrap: break-word;
}
.psr-chat-msg.bot {
    align-self: flex-start;
    background: #fff;
    color: #23262E;
    border: 1px solid var(--psr-chat-border);
    border-bottom-left-radius: 4px;
}
.psr-chat-msg.user {
    align-self: flex-end;
    background: var(--psr-chat-primary);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* Markdown rendered inside bot bubbles (headings, bold, lists, etc.) */
.psr-chat-msg.bot p { margin: 0 0 8px; }
.psr-chat-msg.bot p:last-child { margin-bottom: 0; }
.psr-chat-msg.bot strong { font-weight: 700; color: var(--psr-chat-ink); }
.psr-chat-msg.bot em { font-style: italic; }
.psr-chat-msg.bot ul,
.psr-chat-msg.bot ol {
    margin: 0 0 8px;
    padding-left: 20px;
}
.psr-chat-msg.bot li { margin-bottom: 4px; }
.psr-chat-msg.bot li:last-child { margin-bottom: 0; }
.psr-chat-msg.bot h1,
.psr-chat-msg.bot h2,
.psr-chat-msg.bot h3 {
    font-size: 14px;
    font-weight: 700;
    margin: 0 0 6px;
    color: var(--psr-chat-ink);
}
.psr-chat-msg.bot a {
    color: var(--psr-chat-primary);
    text-decoration: underline;
}
.psr-chat-msg.bot code {
    background: var(--psr-chat-mist);
    border-radius: 4px;
    padding: 1px 5px;
    font-size: 12.5px;
}
.psr-chat-msg.bot table {
    border-collapse: collapse;
    width: 100%;
    margin: 0 0 8px;
    font-size: 12.5px;
}
.psr-chat-msg.bot th,
.psr-chat-msg.bot td {
    border: 1px solid var(--psr-chat-border);
    padding: 5px 7px;
    text-align: left;
}
.psr-chat-msg-time {
    font-size: 10px;
    color: var(--psr-chat-muted);
    margin-top: 4px;
    align-self: flex-end;
}
.psr-chat-msg.user + .psr-chat-msg-time { align-self: flex-end; }

.psr-chat-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 2px 2px 6px;
}
.psr-chat-quick-reply {
    border: 1px solid var(--psr-chat-primary);
    color: var(--psr-chat-primary);
    background: #fff;
    border-radius: 999px;
    padding: 7px 12px;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}
.psr-chat-quick-reply:hover { background: var(--psr-chat-primary); color: #fff; }

/* Typing indicator */
.psr-chat-typing {
    align-self: flex-start;
    display: flex;
    align-items: center;
    gap: 4px;
    background: #fff;
    border: 1px solid var(--psr-chat-border);
    padding: 12px 14px;
    border-radius: 14px;
    border-bottom-left-radius: 4px;
}
.psr-chat-typing span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #B7BCC8;
    animation: psrChatTyping 1.1s infinite ease-in-out;
}
.psr-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.psr-chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes psrChatTyping {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- Footer / input ---------- */
.psr-chat-footer {
    flex: 0 0 auto;
    padding: 10px 12px;
    background: #fff;
    border-top: 1px solid var(--psr-chat-border);
}
.psr-chat-input-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    background: var(--psr-chat-mist);
    border: 1px solid var(--psr-chat-border);
    border-radius: 14px;
    padding: 6px 6px 6px 12px;
}
.psr-chat-input {
    flex: 1 1 auto;
    border: none;
    background: transparent;
    resize: none;
    max-height: 96px;
    font-size: 13.5px;
    line-height: 1.4;
    padding: 8px 0;
    outline: none;
    font-family: inherit;
    color: var(--psr-chat-ink);
}
.psr-chat-input::placeholder { color: #9AA0AC; }
.psr-chat-send {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    border: none;
    background: var(--psr-chat-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    flex: 0 0 auto;
    transition: background 0.15s ease, opacity 0.15s ease;
}
.psr-chat-send:hover { background: var(--psr-chat-primary-dark); }
.psr-chat-send:disabled { opacity: 0.4; cursor: not-allowed; }

.psr-chat-disclaimer {
    text-align: center;
    font-size: 10.5px;
    color: var(--psr-chat-muted);
    margin: 6px 0 0;
}

/* ---------- Mobile bottom CTA bar ---------- */
/* Intentionally NOT adding a chat button here — the AI chat is
   triggered on mobile via the existing openMobileChat() hook in
   footer.jsp (repurposed from Zoho), not the Call/WhatsApp bar. */