/* Sopheva Compact & Premium Chat Widget Styles */
#hw-chat-widget { position: fixed; bottom: 40px; right: 40px; z-index: 9999; font-family: 'Manrope', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; display: flex; flex-direction: column; align-items: flex-end; }

/* Floating Prompt Badge */
.hw-chat-badge { margin-bottom: 12px; background: #ffffff; border: 1px solid #ebd5d0; padding: 8px 16px; border-radius: 20px; box-shadow: 0 8px 24px rgba(163, 53, 30, 0.15); display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 600; color: #a3351e; cursor: pointer; animation: hwBounce 2s infinite ease-in-out; transition: opacity 0.3s, transform 0.3s; }
.hw-chat-badge:hover { transform: scale(1.05); }
.hw-badge-dot { width: 8px; height: 8px; background-color: #10b981; border-radius: 50%; box-shadow: 0 0 8px #10b981; animation: hwPulse 2s infinite; }

/* Toggle Button with Pulse Effect */
#hw-chat-toggle { width: 58px; height: 58px; border-radius: 50%; background: linear-gradient(135deg, #a3351e, #892816); color: #fff; border: none; box-shadow: 0 8px 24px rgba(163, 53, 30, 0.38); cursor: pointer; display: flex; align-items: center; justify-content: center; transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1); position: relative; z-index: 10; }
#hw-chat-toggle::before { content: ''; position: absolute; top: 0; left: 0; right: 0; bottom: 0; border-radius: 50%; border: 2px solid #a3351e; animation: hwRipple 2s infinite ease-in-out; z-index: -1; }
#hw-chat-toggle:hover { transform: scale(1.08) rotate(5deg); box-shadow: 0 8px 28px rgba(163, 53, 30, 0.45); }
#hw-chat-toggle span { font-size: 28px; }

/* Chat Window */
#hw-chat-window { position: absolute; bottom: 74px; right: 0; width: 374px; height: 564px; max-height: min(564px, calc(100vh - 96px)); background: #ffffff; border-radius: 22px; box-shadow: 0 18px 50px rgba(163, 53, 30, 0.18), 0 6px 16px rgba(0, 0, 0, 0.10); display: flex; flex-direction: column; overflow: hidden; border: 1px solid #f2e9e6; transition: all 0.35s cubic-bezier(0.16, 1, 0.3, 1); transform-origin: bottom right; z-index: 20; }
#hw-chat-window.hidden { opacity: 0; transform: scale(0.85); pointer-events: none; }
.hw-chat-header { background: linear-gradient(135deg, #a3351e, #7a2514); color: #fff; padding: 14px 18px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid rgba(255,255,255,0.1); box-shadow: 0 2px 10px rgba(0,0,0,0.1); }
.hw-chat-title { font-weight: 600; font-size: 15px; letter-spacing: 0.2px; }
.hw-online-dot { width: 8px; height: 8px; background-color: #10b981; border-radius: 50%; display: inline-block; box-shadow: 0 0 8px #10b981; animation: hwPulse 2s infinite; }
#hw-chat-reset { background: none; border: none; color: #fff; cursor: pointer; opacity: 0.8; padding: 0 4px; transition: all 0.2s; display: flex; align-items: center; justify-content: center; }
#hw-chat-reset:hover { opacity: 1; transform: rotate(180deg) scale(1.1); }
#hw-chat-close { background: none; border: none; color: #fff; cursor: pointer; font-size: 18px; opacity: 0.8; padding: 0 4px; transition: all 0.2s; }
#hw-chat-close:hover { opacity: 1; transform: scale(1.1); }
#hw-chat-messages { flex: 1; padding: 14px; overflow-y: auto; background: #fdfbfb; display: flex; flex-direction: column; gap: 10px; }
.hw-chat-message { display: flex; gap: 8px; align-items: flex-end; animation: hwFadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1); }
.hw-chat-ai { justify-content: flex-start; }
.hw-chat-user { justify-content: flex-end; }
.hw-chat-avatar { width: 26px; height: 26px; background: #ebd5d0; color: #a3351e; border-radius: 50%; display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 2px 6px rgba(163,53,30,0.1); }
.hw-chat-avatar span { font-size: 15px; }
.hw-chat-bubble { max-width: 78%; padding: 10px 14px; border-radius: 16px; font-size: 13px; line-height: 1.45; box-shadow: 0 2px 8px rgba(0,0,0,0.04); }
.hw-chat-ai .hw-chat-bubble { background: #fff; border: 1px solid #f2e9e6; border-bottom-left-radius: 4px; color: #4a3530; }
.hw-chat-user .hw-chat-bubble { background: linear-gradient(135deg, #a3351e, #892816); color: #fff; border-bottom-right-radius: 4px; }

/* ── Rich message formatting (markdown-rendered AI replies) ── */
.hw-chat-bubble { line-height: 1.5; }
.hw-chat-ai .hw-chat-bubble { max-width: 84%; }
.hw-chat-bubble p { margin: 0 0 8px 0; }
.hw-chat-bubble p:last-child { margin-bottom: 0; }
.hw-chat-ai .hw-chat-bubble strong { color: #7a2514; font-weight: 700; }
.hw-chat-bubble .hw-md-list { margin: 4px 0 8px 0; }
.hw-chat-bubble .hw-md-list:last-child { margin-bottom: 0; }
.hw-chat-bubble .hw-md-list li { margin: 4px 0; }
.hw-chat-bubble ul.hw-md-list { list-style: none; padding-left: 2px; }
.hw-chat-bubble ul.hw-md-list li { position: relative; padding-left: 16px; }
.hw-chat-bubble ul.hw-md-list li::before { content: ''; position: absolute; left: 3px; top: 8px; width: 5px; height: 5px; border-radius: 50%; background: #a3351e; }
.hw-chat-bubble ol.hw-md-list { padding-left: 18px; margin-left: 2px; }
.hw-chat-bubble ol.hw-md-list li { padding-left: 3px; }
.hw-chat-bubble ol.hw-md-list li::marker { color: #a3351e; font-weight: 700; }
.hw-chat-input-area { padding: 10px 14px; background: #fff; border-top: 1px solid #f2e9e6; display: flex; gap: 8px; align-items: center; }
.hw-chat-consent { padding: 9px 14px; border-top: 1px solid #f2e9e6; background: #fff8f5; color: #58423d; font-size: 10px; line-height: 1.35; }
.hw-chat-consent label { display: flex; align-items: flex-start; gap: 7px; cursor: pointer; }
.hw-chat-consent input { margin-top: 2px; flex: 0 0 auto; }
.hw-chat-consent a { display: inline-block; margin: 4px 0 0 22px; color: #a3351e; text-decoration: underline; }
.hw-chat-consent.is-accepted { display: none; }
.hw-chat-medical-note { padding: 5px 14px; background: #fff; color: #765f59; font-size: 9px; line-height: 1.3; text-align: center; border-top: 1px solid #f2e9e6; }
#hw-chat-input { flex: 1; padding: 10px 14px; border: 1px solid #ebd5d0; border-radius: 20px; font-size: 13px; outline: none; transition: all 0.2s; background: #faf8f7; color: #4a3530; }
#hw-chat-input:focus { border-color: #a3351e; background: #fff; box-shadow: 0 0 0 3px rgba(163,53,30,0.1); }
#hw-chat-send { background: linear-gradient(135deg, #a3351e, #892816); color: #fff; border: none; width: 38px; height: 38px; border-radius: 50%; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all 0.2s; box-shadow: 0 2px 8px rgba(163,53,30,0.2); }
#hw-chat-send:hover:not(:disabled) { transform: scale(1.08); box-shadow: 0 4px 12px rgba(163,53,30,0.3); }
#hw-chat-send span { font-size: 18px; }
#hw-chat-send:disabled { background: #ebd5d0; cursor: not-allowed; box-shadow: none; }

/* Mobile Optimization — full-screen sheet, safe-area aware, bigger touch targets */
@media (max-width: 480px) {
    #hw-chat-widget { bottom: calc(16px + env(safe-area-inset-bottom)); right: 16px; }
    #hw-chat-toggle { width: 60px; height: 60px; }
    #hw-chat-toggle span { font-size: 30px; }

    #hw-chat-window { position: fixed; top: 0; left: 0; right: 0; bottom: 0; width: 100vw; height: 100dvh; height: -webkit-fill-available; max-height: none; border-radius: 0; border: none; transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s cubic-bezier(0.16, 1, 0.3, 1); transform-origin: center bottom; display: flex; flex-direction: column; z-index: 999999; }
    #hw-chat-window.hidden { opacity: 0; transform: translateY(100%); pointer-events: none; }

    /* Header clears the status bar / notch in PWA standalone mode */
    .hw-chat-header { padding: calc(14px + env(safe-area-inset-top)) 18px 14px; }
    .hw-chat-title { font-size: 17px; }
    #hw-chat-close { font-size: 24px; padding: 4px 8px; }
    #hw-chat-reset { padding: 4px 8px; }
    #hw-chat-reset span, #hw-chat-close span { font-size: 22px; }

    .hw-chat-badge { font-size: 13px; padding: 8px 14px; }
    #hw-chat-messages { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px; gap: 12px; }

    .hw-chat-avatar { width: 30px; height: 30px; }
    .hw-chat-avatar span { font-size: 17px; }
    .hw-chat-bubble { max-width: 86%; font-size: 14.5px; padding: 12px 16px; border-radius: 18px; }

    .hw-quick-replies { padding: 12px 14px 8px; gap: 8px; }
    .hw-quick-reply { font-size: 13px; padding: 9px 14px; border-radius: 18px; }

    .hw-chat-consent { font-size: 11.5px; padding: 12px 16px; }
    .hw-chat-consent a { margin-left: 24px; }
    .hw-chat-medical-note { font-size: 10.5px; padding: 7px 16px; }

    .hw-chat-input-area { flex-shrink: 0; padding: 12px 14px; padding-bottom: max(14px, env(safe-area-inset-bottom)); background: #fff; z-index: 10; gap: 10px; }
    #hw-chat-input { font-size: 16px !important; padding: 12px 16px; }
    #hw-chat-send { width: 44px; height: 44px; }
    #hw-chat-send span { font-size: 20px; }
}

/* Quick Replies */
.hw-quick-replies { display: flex; gap: 6px; overflow-x: auto; padding: 10px 14px 6px 14px; background: #fdfbfb; border-top: 1px solid #f2e9e6; scrollbar-width: none; }
.hw-quick-replies::-webkit-scrollbar { display: none; }
.hw-quick-reply { flex-shrink: 0; background: #f2e9e6; color: #a3351e; border: 1px solid #ebd5d0; padding: 6px 12px; border-radius: 16px; font-size: 12px; font-weight: 600; cursor: pointer; transition: all 0.2s ease; white-space: nowrap; }
.hw-quick-reply:hover { background: #a3351e; color: #fff; border-color: #a3351e; transform: translateY(-1px); }

/* Animations */
@keyframes hwFadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes hwPulse {
    0% { opacity: 1; }
    50% { opacity: 0.4; }
    100% { opacity: 1; }
}
@keyframes hwBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}
@keyframes hwRipple {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.35); opacity: 0; }
}
@keyframes hwSpin {
    to { transform: rotate(360deg); }
}
