/* ── Chat Widget ─────────────────────────────────────────────── */
#chatWidget {
  position: fixed;
  bottom: 96px;   /* stacked above .support-fab */
  right: 24px;
  z-index: 9000;
  font-family: inherit;
}
@media (max-width: 480px) {
  #chatWidget { bottom: 80px; right: 16px; }
}

#chatToggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #013861, #00a8e8);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(0,0,0,0.25);
  transition: transform 0.2s, box-shadow 0.2s;
  margin-left: auto;
}
#chatToggle:hover { transform: scale(1.08); box-shadow: 0 6px 24px rgba(0,0,0,0.35); }
#chatToggle svg { width: 26px; height: 26px; fill: white; transition: opacity 0.2s; }
#chatToggle .icon-close { display: none; }
#chatWidget.open #chatToggle .icon-chat  { display: none; }
#chatWidget.open #chatToggle .icon-close { display: block; }

#chatBubble {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 340px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.18);
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgba(0,0,0,0.06);
}
#chatWidget.open #chatBubble { display: flex; }

.chat-header {
  background: linear-gradient(135deg, #013861, #025a9e);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 10px;
}
.chat-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
}
.chat-header-info strong { display: block; font-size: 0.9rem; }
.chat-header-info span   { font-size: 0.75rem; opacity: 0.75; }
.chat-status-dot {
  width: 8px; height: 8px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  min-height: 200px;
}
.chat-msg {
  max-width: 85%;
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 0.875rem;
  line-height: 1.5;
  animation: chatFadeIn 0.2s ease;
}
@keyframes chatFadeIn { from { opacity:0; transform: translateY(6px); } to { opacity:1; transform: none; } }

.chat-msg.bot {
  background: #f1f5f9;
  color: #1e293b;
  border-bottom-left-radius: 3px;
  align-self: flex-start;
}
.chat-msg.bot strong { color: #013861; font-weight: 700; }
.chat-msg.bot em { font-style: italic; }
.chat-msg.bot code {
  background: rgba(1,56,97,.08); color: #013861;
  padding: 1px 5px; border-radius: 4px;
  font-family: 'JetBrains Mono', monospace; font-size: .82em;
}
.chat-msg.bot ul { margin: 6px 0 4px; padding-left: 18px; }
.chat-msg.bot li { margin: 2px 0; }
.chat-msg.bot a { color: #025a9e; text-decoration: underline; word-break: break-word; }
.chat-msg.bot a:hover { color: #013861; }
.chat-msg.bot p { margin: 0 0 .5rem; }
.chat-msg.bot p:last-child { margin-bottom: 0; }
.chat-msg.user {
  background: linear-gradient(135deg, #013861, #025a9e);
  color: #fff;
  border-bottom-right-radius: 3px;
  align-self: flex-end;
}
.chat-msg.typing {
  background: #f1f5f9;
  align-self: flex-start;
  padding: 10px 14px;
}
.typing-dots { display: flex; gap: 4px; align-items: center; height: 16px; }
.typing-dots span {
  width: 6px; height: 6px;
  background: #94a3b8;
  border-radius: 50%;
  animation: typingBounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30%           { transform: translateY(-6px); }
}

.chat-footer {
  border-top: 1px solid #e2e8f0;
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  background: #fafafa;
}
.chat-footer--locked {
  display: block;
  background: linear-gradient(180deg, #f0fdf4 0%, #ecfdf5 100%);
  border-top-color: #bbf7d0;
}
.chat-locked-notice {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  font-size: 0.82rem; color: #166534; line-height: 1.45;
}
.chat-locked-notice i { color: #16a34a; font-size: 1rem; }
.chat-locked-reload {
  background: #013861; color: #fff; border: 0;
  padding: 4px 10px; border-radius: 6px;
  font-size: 0.78rem; font-weight: 600; cursor: pointer;
  margin: 0 2px;
}
.chat-locked-reload:hover { background: #025a9e; }
#chatInput {
  flex: 1;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 0.875rem;
  resize: none;
  max-height: 80px;
  outline: none;
  line-height: 1.4;
  font-family: inherit;
  background: #fff;
}
#chatInput:focus { border-color: #00a8e8; }
#chatSend {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  background: linear-gradient(135deg, #013861, #00a8e8);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.2s;
}
#chatSend:disabled { opacity: 0.5; cursor: not-allowed; }
#chatSend svg { width: 16px; height: 16px; fill: white; }

/* ── Proactive teaser bubble (next to chat toggle) ────────── */
.chat-teaser {
  position: absolute; bottom: 70px; right: 0;
  width: max-content;
  min-width: 400px;
  max-width: min(440px, calc(100vw - 3rem));
  display: flex; align-items: stretch; gap: 0;
  background: #fff; color: #0f172a;
  border: 1px solid #e2e8f0; border-radius: 14px;
  box-shadow: 0 12px 28px rgba(1,56,97,.22);
  opacity: 0; transform: translateY(8px) scale(.96);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  overflow: hidden;
}
.chat-teaser.open { opacity: 1; transform: none; pointer-events: auto; }
.chat-teaser::after {
  content: ''; position: absolute; bottom: -7px; right: 22px;
  width: 14px; height: 14px; background: #fff;
  border-right: 1px solid #e2e8f0; border-bottom: 1px solid #e2e8f0;
  transform: rotate(45deg);
}
.chat-teaser-body {
  flex: 1; display: flex; align-items: center; gap: 10px;
  padding: 10px 12px 10px 14px; background: transparent;
  border: 0; cursor: pointer; text-align: left;
  font-family: inherit; font-size: 0.85rem; line-height: 1.4;
  color: #0f172a;
}
.chat-teaser-body:hover { background: #f8fafc; }
.chat-teaser-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: linear-gradient(135deg, #013861, #00a8e8);
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 16px; flex-shrink: 0;
}
.chat-teaser-text { font-weight: 500; }
.chat-teaser-close {
  background: transparent; border: 0; color: #94a3b8;
  font-size: 18px; cursor: pointer; padding: 4px 8px;
  align-self: flex-start; line-height: 1;
  position: absolute; top: 4px; right: 4px;
}
.chat-teaser-close:hover { color: #ef4444; }
@media (max-width: 480px) {
  .chat-teaser { min-width: 0; max-width: calc(100vw - 1.5rem); bottom: 64px; }
}

.chat-contact {
  background: #fff; border-top: 1px solid #e2e8f0;
  padding: 14px 16px;
  max-height: 0; opacity: 0; overflow: hidden;
  transition: max-height .3s ease, opacity .2s ease, padding .3s ease;
}
.chat-contact.open { max-height: 480px; opacity: 1; }
.chat-contact-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
  color: #013861;
}
.chat-contact-head i { color: #00a8e8; }
.chat-contact-head strong { font-size: 0.92rem; flex: 1; }
.chat-contact-close {
  background: none; border: 0; font-size: 1.25rem; cursor: pointer;
  color: #94a3b8; line-height: 1; padding: 0 4px;
}
.chat-contact-close:hover { color: #ef4444; }
.chat-contact-sub { margin: 0 0 10px; font-size: 0.78rem; color: #64748b; line-height: 1.4; }
.chat-contact form { display: flex; flex-direction: column; gap: 8px; }
.chat-contact input, .chat-contact textarea {
  padding: 8px 10px; font-size: 0.85rem; font-family: inherit;
  background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 8px;
  color: #0f172a; outline: none; resize: vertical; min-height: 0;
}
.chat-contact input:focus, .chat-contact textarea:focus { border-color: #00a8e8; background: #fff; }
.chat-contact button[type="submit"] {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  background: linear-gradient(135deg, #013861, #025a9e);
  color: #fff; border: 0; padding: 9px 14px; border-radius: 8px;
  font-size: 0.85rem; font-weight: 600; cursor: pointer;
  transition: opacity .15s;
}
.chat-contact button[type="submit"]:disabled { opacity: .6; cursor: not-allowed; }
.chat-contact-msg {
  margin-top: 6px; padding: 8px 10px; border-radius: 6px;
  font-size: 0.8rem; line-height: 1.4;
}
.chat-contact-msg--ok  { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.chat-contact-msg--err { background: #fef2f2; color: #991b1b; border: 1px solid #fecaca; }

.chat-disclaimer {
  text-align: center;
  font-size: 0.7rem;
  color: #94a3b8;
  padding: 6px 12px 10px;
  background: #fafafa;
}
.chat-banned {
  padding: 16px;
  text-align: center;
  color: #ef4444;
  font-size: 0.875rem;
  background: #fef2f2;
  border-top: 1px solid #fecaca;
}

@media (max-width: 480px) {
  #chatBubble { width: calc(100vw - 32px); right: 0; }
  #chatWidget { right: 16px; bottom: 16px; }
}
