/* ── CHATBOT WIDGET ── */
#safir-chatbot { position: fixed; right: 24px; bottom: 24px; z-index: 900; }

#safir-chat-launcher {
width: 58px; height: 58px; border-radius: 50%;
background: var(--blue2); color: #fff; border: none;
display: flex; align-items: center; justify-content: center;
cursor: pointer; box-shadow: 0 10px 28px -4px rgba(6,14,31,0.32), 0 6px 18px rgba(0,99,204,0.32);
transition: background .18s, transform .18s;
position: relative; overflow: visible;
}
#safir-chat-launcher:hover { background: var(--blue3); transform: translateY(-2px); }

#safir-chat-launcher::after {
content: '';
position: absolute;
inset: 0;
border-radius: 50%;
background: var(--blue2);
opacity: 0.5;
animation: safir-pulse 2s ease-out infinite;
z-index: -1;
}
@keyframes safir-pulse {
0%   { transform: scale(1);   opacity: 0.5; }
70%  { transform: scale(1.55); opacity: 0;   }
100% { transform: scale(1.55); opacity: 0;   }
}
#safir-chat-launcher.is-open::after { animation: none; opacity: 0; }

.safir-chat-panel {
position: absolute; right: 0; bottom: 72px;
width: 360px; max-width: calc(100vw - 32px);
height: auto; min-height: 0;
max-height: min(64vh, 560px);
background: var(--white);
border-radius: 20px;
border: 1px solid var(--card-border);
box-shadow: 0 24px 56px -10px rgba(6,14,31,0.32), 0 6px 20px rgba(0,99,204,0.08);
display: flex; flex-direction: column;
overflow: hidden;
opacity: 0;
transform: translateY(12px) scale(0.97);
pointer-events: none;
transform-origin: bottom right;
transition: opacity 220ms ease, transform 220ms ease, max-height 260ms ease, width 260ms ease;
}
.safir-chat-panel[hidden] { display: flex; }
.safir-chat-panel.is-open {
opacity: 1;
transform: translateY(0) scale(1);
pointer-events: auto;
}

/* Manual "size adjustment" toggle — bigger working area on demand */
.safir-chat-panel.is-expanded {
width: 420px;
max-height: min(86vh, 720px);
}

/* Minimizer — collapses to just the header strip, conversation state is preserved */
.safir-chat-panel.is-minimized {
height: auto; max-height: none; min-height: 0;
}
.safir-chat-panel.is-minimized .safir-chat-log,
.safir-chat-panel.is-minimized .safir-chat-footer,
.safir-chat-panel.is-minimized .safir-chat-input-bar {
display: none;
}
.safir-chat-panel.is-minimized .safir-chat-head { cursor: pointer; }

.safir-chat-head {
display: flex; align-items: flex-start; justify-content: space-between;
padding: 14px 16px 14px 18px;
background: linear-gradient(135deg, var(--navy) 0%, var(--navy3) 100%);
flex: 0 0 auto;
}
.safir-chat-avatar {
width: 34px; height: 34px; border-radius: 50%; flex: none;
background: var(--blue2);
display: flex; align-items: center; justify-content: center;
margin-right: 10px; margin-top: 1px;
font-family: var(--ff-head); font-weight: 700; font-size: 14px; color: #fff;
border: 2px solid rgba(255,255,255,0.2);
}
.safir-chat-avatar::after { content: 'S'; }
.safir-chat-title-wrap { display: flex; flex-direction: column; gap: 3px; flex: 1; }
.safir-chat-title { font-family: var(--ff-head); font-weight: 700; font-size: 15px; color: #fff; letter-spacing: -.01em; }
.safir-chat-status {
font-size: 11px; color: rgba(255,255,255,0.6);
font-family: var(--ff-body); font-weight: 400;
display: flex; align-items: center; gap: 5px;
}
.safir-chat-dot {
width: 7px; height: 7px; border-radius: 50%;
background: #4ade80; display: inline-block; flex: none;
box-shadow: 0 0 5px #4ade80;
}
.safir-chat-head-actions { display: flex; align-items: center; gap: 6px; flex: none; margin-top: 2px; }
.safir-chat-icon-btn {
width: 28px; height: 28px; border-radius: 50%; flex: none;
background: rgba(255,255,255,.08); border: 1px solid rgba(255,255,255,.12);
color: rgba(255,255,255,.7); cursor: pointer;
display: flex; align-items: center; justify-content: center;
transition: background .18s, color .18s;
}
.safir-chat-icon-btn:hover { background: rgba(255,255,255,.16); color: #fff; }
.safir-chat-icon-btn.is-active { background: rgba(255,255,255,.22); color: #fff; }

.safir-chat-log {
flex: 1 1 auto; min-height: 0; overflow-y: auto;
padding: 16px 18px; display: flex; flex-direction: column; gap: 14px;
background: var(--off);
}

.safir-chat-turn { display: flex; flex-direction: column; gap: 8px; }

.safir-chat-bubble {
max-width: 85%; padding: 10px 14px; border-radius: var(--radius-sm);
font-size: 13.5px; line-height: 1.5; font-family: var(--ff-body);
}
.safir-chat-bubble.bot { align-self: flex-start; background: var(--white); color: var(--text); border: 1px solid var(--card-border); }
.safir-chat-bubble.user { align-self: flex-end; background: var(--blue2); color: #fff; }

/* Typing indicator */
.safir-chat-typing {
align-self: flex-start;
display: flex; gap: 5px; align-items: center;
padding: 12px 16px;
background: var(--white); border: 1px solid var(--card-border);
border-radius: var(--radius-sm);
}
.safir-chat-typing span {
width: 7px; height: 7px; border-radius: 50%;
background: var(--muted);
animation: safir-bounce 1.2s ease-in-out infinite;
}
.safir-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.safir-chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes safir-bounce {
0%, 80%, 100% { transform: translateY(0);    opacity: 0.4; }
40%            { transform: translateY(-6px); opacity: 1;   }
}

.safir-chat-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.safir-chat-btn {
border: 1px solid var(--blue2); background: var(--white); color: var(--blue2);
border-radius: 999px; padding: 9px 16px; min-height: 38px;
font-size: 13px; font-weight: 500; font-family: var(--ff-body);
cursor: pointer; transition: background .15s, color .15s;
display: inline-flex; align-items: center; justify-content: center;
animation: safir-chip-in 200ms ease both;
animation-delay: calc(var(--i, 0) * 55ms);
}
@keyframes safir-chip-in {
from { opacity: 0; transform: translateY(6px); }
to   { opacity: 1; transform: translateY(0);   }
}
.safir-chat-btn:hover:not(:disabled) { background: var(--blue2); color: #fff; }
.safir-chat-btn:disabled { cursor: default; }
.safir-chat-btn-cta { border-color: var(--navy); color: var(--navy); }
.safir-chat-btn-cta:hover:not(:disabled) { background: var(--navy); color: #fff; }
.safir-chat-btn-back { border-color: var(--muted); color: var(--textm); }
.safir-chat-btn-back:hover:not(:disabled) { background: var(--muted); color: #fff; }

.safir-chat-buttons.is-inert { pointer-events: none; opacity: .45; }
.safir-chat-buttons.is-inert .safir-chat-btn { animation: none; }

.safir-chat-buttons-wrap { display: flex; flex-direction: column; }

/* Suggested-for-this-page label + highlighted root button */
.safir-chat-suggest-label {
font-size: 11px; color: var(--textm); font-style: italic;
margin: 0 0 6px 1px; font-family: var(--ff-body);
}
.safir-chat-btn-primary { background: var(--blue2); color: #fff; }
.safir-chat-btn-primary:hover:not(:disabled) { background: var(--blue3); }

/* Matched-via-keyword / live-data flag shown above a bot bubble */
.safir-chat-flag {
align-self: flex-start;
display: inline-flex; align-items: center; gap: 5px;
font-family: var(--ff-body); font-size: 10.5px; font-weight: 500;
color: var(--blue); background: rgba(0,119,245,0.08);
border: 1px solid rgba(0,99,204,0.18);
padding: 3px 9px; border-radius: 6px;
}

/* Restored-session note */
.safir-chat-note {
font-size: 10.5px; color: var(--muted); font-style: italic;
text-align: center; margin: 0 0 6px; font-family: var(--ff-body);
}

/* Inline lead-capture form (WPForms, styled to fit the panel) */
.safir-chat-lead-embed {
background: var(--white); border: 1px solid var(--card-border);
border-radius: var(--radius-sm); padding: 10px 12px;
}
.safir-chat-lead-embed .wpforms-container { margin: 0 !important; }
.safir-chat-lead-embed .wpforms-form { font-family: var(--ff-body) !important; }
.safir-chat-lead-embed .wpforms-field { padding: 0 0 8px !important; }
.safir-chat-lead-embed .wpforms-field-label { font-size: 11.5px !important; margin-bottom: 3px !important; }
.safir-chat-lead-embed input[type="text"],
.safir-chat-lead-embed input[type="email"] {
font-size: 12.5px !important; padding: 7px 10px !important;
border-radius: 8px !important; border-color: var(--card-border) !important;
}
.safir-chat-lead-embed .wpforms-submit {
background: var(--blue2) !important; border: none !important;
border-radius: 999px !important; font-size: 12.5px !important;
padding: 8px 18px !important; font-family: var(--ff-body) !important;
}
.safir-chat-lead-embed .wpforms-submit:hover { background: var(--blue3) !important; }

/* Empty state hint */
.safir-chat-empty-hint {
font-size: 12px; color: var(--textm); font-style: italic;
text-align: center; margin: 8px 0 0;
font-family: var(--ff-body); opacity: 0.75;
}

/* Input bar */
.safir-chat-input-bar {
display: flex; align-items: center; gap: 8px;
padding: 10px 14px;
border-top: 1px solid var(--card-border);
background: var(--white);
flex: 0 0 auto;
}
.safir-chat-input {
flex: 1; border: 1px solid var(--card-border);
border-radius: 999px; padding: 8px 14px;
font-size: 13px; font-family: var(--ff-body); color: var(--text);
background: var(--off); outline: none;
transition: border-color .15s;
}
.safir-chat-input:focus { border-color: var(--blue2); }
.safir-chat-send {
width: 34px; height: 34px; border-radius: 50%; flex: none;
background: var(--blue2); color: #fff; border: none;
display: flex; align-items: center; justify-content: center;
cursor: pointer; font-size: 14px;
transition: background .15s, transform .15s;
}
.safir-chat-send:hover { background: var(--blue3); transform: scale(1.08); }

.safir-chat-footer { flex: 0 0 auto; padding: 8px 18px 12px; border-top: 1px solid var(--card-border); background: var(--white); }
.safir-chat-restart {
width: 100%; border: none; background: transparent; color: var(--textm);
font-size: 12.5px; font-family: var(--ff-body); cursor: pointer; padding: 6px;
text-decoration: underline;
}
.safir-chat-restart[hidden] { display: none; }
.safir-chat-restart:hover { color: var(--text); }

@media (max-width: 600px) {
#safir-chatbot { right: 16px; bottom: 16px; }
#safir-chat-launcher { width: 52px; height: 52px; }
.safir-chat-panel,
.safir-chat-panel.is-expanded {
width: calc(100vw - 24px);
max-height: calc(100vh - 110px);
bottom: 64px;
}
.safir-chat-panel.is-minimized { max-height: none; }
}