/* ============================================================
   CIFRA — Chat Widget
   ============================================================ */

/* ── FAB ── */
.chat-fab {
  position: fixed; bottom: 28px; right: 28px; z-index: 9000;
  width: 62px; height: 62px; border-radius: 50%;
  background: var(--teal); color: #fff;
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 6px 24px rgba(15,182,168,.5);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), box-shadow .25s;
  animation: fabIn .65s 1.8s cubic-bezier(.34,1.56,.64,1) both;
}
.chat-fab:hover { transform: scale(1.1); box-shadow: 0 8px 32px rgba(15,182,168,.6); }
.chat-fab.open { background: var(--navy); box-shadow: 0 6px 24px rgba(11,31,58,.4); }
.chat-fab-icon { transition: transform .28s cubic-bezier(.34,1.56,.64,1); }
.chat-fab.open .chat-fab-icon { transform: rotate(90deg) scale(.9); }
@keyframes fabIn {
  from { transform: scale(0) translateY(16px); opacity: 0; }
  to   { transform: scale(1) translateY(0);    opacity: 1; }
}

/* Badge */
.chat-fab-badge {
  position: absolute; top: -3px; right: -3px;
  width: 21px; height: 21px;
  background: #ef4444; color: #fff;
  font-size: 11px; font-weight: 800; font-family: var(--font);
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  border: 2px solid #fff; animation: badgePulse 2.2s ease-in-out infinite;
  transition: transform .25s, opacity .25s;
}
.chat-fab-badge.gone { transform: scale(0); opacity: 0; pointer-events: none; }
@keyframes badgePulse {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.22); }
}

/* ── Panel ── */
.chat-panel {
  position: fixed; bottom: 102px; right: 28px; z-index: 8999;
  width: 368px; max-height: 580px;
  display: flex; flex-direction: column;
  background: #fff; border-radius: 22px;
  box-shadow: 0 24px 64px rgba(11,31,58,.22), 0 0 0 1px rgba(15,182,168,.15);
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(.88) translateY(16px);
  opacity: 0; pointer-events: none;
  transition: transform .38s cubic-bezier(.34,1.56,.64,1), opacity .28s ease;
}
.chat-panel.open {
  transform: scale(1) translateY(0);
  opacity: 1; pointer-events: all;
}

/* ── Header ── */
.chat-header {
  background: var(--navy); padding: 14px 18px;
  display: flex; align-items: center; justify-content: space-between;
  flex-shrink: 0;
}
.chat-header-info { display: flex; align-items: center; gap: 11px; }
.chat-avatar {
  width: 42px; height: 42px;
  background: rgba(15,182,168,.12);
  border: 1.5px solid rgba(15,182,168,.3);
  border-radius: 13px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.chat-name { font-size: 14px; font-weight: 700; color: #fff; margin-bottom: 2px; }
.chat-status-line {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; color: rgba(255,255,255,.52);
}
.chat-status-line .live-dot { width: 6px; height: 6px; flex-shrink: 0; }
.chat-close {
  background: none; border: none; color: rgba(255,255,255,.55);
  cursor: pointer; padding: 5px; border-radius: 8px; line-height: 1;
  transition: color .2s, background .2s;
}
.chat-close:hover { color: #fff; background: rgba(255,255,255,.1); }

/* ── Suggested prompts ── */
.chat-prompts {
  display: flex; flex-wrap: wrap; gap: 7px;
  padding: 12px 14px 0; flex-shrink: 0;
}
.chat-prompt {
  background: var(--bg-light); border: 1px solid var(--border);
  color: var(--navy); font-size: 11.5px; font-weight: 600; font-family: var(--font);
  padding: 6px 11px; border-radius: 100px; cursor: pointer;
  transition: all .2s; white-space: nowrap;
}
.chat-prompt:hover { background: var(--teal-light); border-color: var(--teal); color: var(--teal-dark); }
.chat-prompts.hidden { display: none; }

/* ── Messages ── */
.chat-messages {
  flex: 1; overflow-y: auto; padding: 14px 14px 8px;
  display: flex; flex-direction: column; gap: 10px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

.chat-msg { display: flex; flex-direction: column; max-width: 88%; }
.chat-msg.user { align-self: flex-end; align-items: flex-end; }
.chat-msg.bot  { align-self: flex-start; align-items: flex-start; }

.chat-bubble {
  padding: 10px 14px; border-radius: 18px;
  font-size: 13.5px; line-height: 1.58;
  animation: msgIn .32s cubic-bezier(.22,1,.36,1);
}
.chat-msg.user .chat-bubble {
  background: var(--teal); color: #fff; border-bottom-right-radius: 5px;
}
.chat-msg.bot .chat-bubble {
  background: var(--bg-light); color: var(--navy);
  border: 1px solid var(--border); border-bottom-left-radius: 5px;
}
.chat-time { font-size: 10px; color: var(--text-light); margin-top: 4px; }

@keyframes msgIn {
  from { opacity: 0; transform: translateY(8px) scale(.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Typing dots ── */
.typing-bubble { display: flex; align-items: center; gap: 5px; padding: 12px 16px; }
.typing-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-light);
  animation: dotBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: .18s; }
.typing-dot:nth-child(3) { animation-delay: .36s; }
@keyframes dotBounce {
  0%,60%,100% { transform: translateY(0); opacity: .4; }
  30%          { transform: translateY(-7px); opacity: 1; }
}

/* ── Lead CTA ── */
.chat-lead {
  background: linear-gradient(145deg, #0B1F3A 0%, #0d2a4e 100%);
  border-top: 1px solid rgba(15,182,168,.22);
  padding: 15px 16px; flex-shrink: 0;
  animation: slideDown .4s cubic-bezier(.22,1,.36,1);
}
@keyframes slideDown {
  from { opacity: 0; transform: translateY(-14px); }
  to   { opacity: 1; transform: translateY(0); }
}
.chat-lead-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 5px;
}
.chat-lead-header .ms { font-size: 17px; color: var(--teal); }
.chat-lead-header strong { font-size: 13.5px; color: #fff; }
.chat-lead p {
  font-size: 12px; color: rgba(255,255,255,.58); margin-bottom: 12px; line-height: 1.55;
}
.chat-lead form { display: flex; flex-direction: column; gap: 7px; }
.chat-lead input {
  padding: 9px 12px; border-radius: 9px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.07); color: #fff;
  font-size: 13px; font-family: var(--font); outline: none;
  transition: border-color .2s, background .2s;
}
.chat-lead input::placeholder { color: rgba(255,255,255,.35); }
.chat-lead input:focus { border-color: var(--teal); background: rgba(255,255,255,.12); }
.chat-lead-submit {
  background: var(--teal); color: #fff; border: none;
  padding: 10px 16px; border-radius: 9px;
  font-size: 13px; font-weight: 700; font-family: var(--font);
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: background .2s, transform .2s; margin-top: 2px;
}
.chat-lead-submit:hover { background: var(--teal-dark); transform: translateY(-1px); }

/* Success state */
.chat-lead-success { text-align: center; padding: 6px 0; }
.chat-lead-success .ms { font-size: 30px; color: var(--teal); display: block; margin-bottom: 7px; }
.chat-lead-success p { font-size: 13px; color: rgba(255,255,255,.78); line-height: 1.55; }

/* ── Quota indicator ── */
.chat-quota {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 14px 0;
  font-size: 11px; font-weight: 600; color: var(--text-light);
  font-family: var(--font);
}
.chat-quota .ms { font-size: 13px; color: var(--teal); }
.chat-quota.quota-low { color: #d97706; }
.chat-quota.quota-low .ms { color: #d97706; }
.chat-quota.quota-empty { color: #dc2626; }
.chat-quota.quota-empty .ms { color: #dc2626; }

/* ── Disabled input state ── */
#chat-input:disabled {
  background: var(--bg-light);
  color: var(--text-light);
  cursor: not-allowed;
}
#chat-send:disabled { background: var(--border); cursor: not-allowed; transform: none; }

/* ── Input area ── */
.chat-input-area {
  display: flex; flex-direction: column;
  border-top: 1px solid var(--border); flex-shrink: 0; background: #fff;
  padding-bottom: 10px;
}
.chat-input-area > .chat-quota { padding: 8px 14px 4px; }
.chat-input-row {
  display: flex; align-items: flex-end; gap: 8px; padding: 0 12px;
}
#chat-input {
  flex: 1; border: 1px solid var(--border); border-radius: 14px;
  padding: 9px 13px; font-size: 13.5px; font-family: var(--font);
  color: var(--navy); resize: none; outline: none; line-height: 1.45;
  max-height: 88px; overflow-y: auto;
  transition: border-color .2s, box-shadow .2s;
}
#chat-input:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(15,182,168,.12); }
#chat-send {
  width: 38px; height: 38px; border-radius: 11px; flex-shrink: 0;
  background: var(--teal); color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .2s, transform .2s;
}
#chat-send:hover { background: var(--teal-dark); transform: scale(1.08); }
#chat-send:disabled { background: var(--border); cursor: not-allowed; transform: none; }

/* ── Mobile ── */
@media (max-width: 440px) {
  .chat-panel { right: 10px; left: 10px; width: auto; bottom: 90px; max-height: 72vh; }
  .chat-fab   { bottom: 18px; right: 14px; }
}
