/* ── CHAT SUPPORT WIDGET ── */
.cw-root {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9999;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  color: #0F172A;
}

/* Launcher button */
.cw-launcher {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #10B981 0%, #059669 100%);
  color: #fff;
  box-shadow: 0 12px 30px rgba(16, 185, 129, .38), 0 4px 10px rgba(11, 30, 63, .12);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .2s ease, box-shadow .2s ease;
  position: relative;
}
.cw-launcher:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 16px 36px rgba(16, 185, 129, .45); }
.cw-launcher:focus-visible { outline: 3px solid #0B1E3F; outline-offset: 3px; }
.cw-launcher svg { width: 26px; height: 26px; }

.cw-launcher .cw-icon-close { display: none; }
.cw-root.cw-open .cw-launcher .cw-icon-chat { display: none; }
.cw-root.cw-open .cw-launcher .cw-icon-close { display: block; }

/* Pulse dot */
.cw-pulse {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  background: #EF4444;
  border: 2px solid #fff;
  border-radius: 50%;
}
.cw-pulse::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  background: rgba(239, 68, 68, .45);
  animation: cw-pulse 1.8s ease-out infinite;
}
@keyframes cw-pulse {
  0%   { transform: scale(.6); opacity: .9; }
  80%  { transform: scale(1.6); opacity: 0; }
  100% { transform: scale(1.6); opacity: 0; }
}
.cw-root.cw-open .cw-pulse,
.cw-root.cw-seen .cw-pulse { display: none; }

/* Panel */
.cw-panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 120px);
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 24px 70px rgba(11, 30, 63, .22), 0 4px 14px rgba(11, 30, 63, .08);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  animation: cw-open .22s cubic-bezier(.2, .9, .3, 1.1);
  border: 1px solid #E2E8F0;
}
.cw-root.cw-open .cw-panel { display: flex; }

@keyframes cw-open {
  from { opacity: 0; transform: translateY(10px) scale(.96); }
  to   { opacity: 1; transform: translateY(0)    scale(1);  }
}

/* Header */
.cw-header {
  background: linear-gradient(135deg, #0B1E3F 0%, #13294D 100%);
  color: #fff;
  padding: 18px 20px 20px;
  flex-shrink: 0;
}
.cw-header-top {
  display: flex;
  align-items: center;
  gap: 12px;
}
.cw-avatar {
  width: 40px;
  height: 40px;
  background: #10B981;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 0 3px rgba(16, 185, 129, .25);
  position: relative;
}
.cw-avatar svg { width: 22px; height: 22px; }
.cw-avatar::after {
  content: '';
  position: absolute;
  right: -1px;
  bottom: -1px;
  width: 11px;
  height: 11px;
  background: #22C55E;
  border: 2px solid #0B1E3F;
  border-radius: 50%;
}
.cw-header-text { flex: 1; min-width: 0; }
.cw-header-text strong {
  display: block;
  font-size: 0.98rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}
.cw-header-text span {
  display: block;
  font-size: 0.78rem;
  color: #94A3B8;
  margin-top: 2px;
}
.cw-header-text span::before {
  content: '';
  display: inline-block;
  width: 6px;
  height: 6px;
  background: #22C55E;
  border-radius: 50%;
  margin-right: 6px;
  vertical-align: middle;
}

/* Messages area */
.cw-body {
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px 8px;
  background: #F8FAFC;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.cw-body::-webkit-scrollbar { width: 6px; }
.cw-body::-webkit-scrollbar-thumb { background: #CBD5E1; border-radius: 3px; }

.cw-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
  animation: cw-msg-in .25s ease;
}
@keyframes cw-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0);  }
}
.cw-msg-bot {
  background: #fff;
  color: #0F172A;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  border: 1px solid #E2E8F0;
}
.cw-msg-user {
  background: #0B1E3F;
  color: #fff;
  border-bottom-right-radius: 4px;
  align-self: flex-end;
}
.cw-msg-bot a {
  color: #059669;
  font-weight: 600;
  text-decoration: underline;
}

.cw-typing {
  display: inline-flex;
  gap: 4px;
  padding: 4px 0;
}
.cw-typing span {
  width: 7px;
  height: 7px;
  background: #94A3B8;
  border-radius: 50%;
  animation: cw-bounce 1.2s infinite ease-in-out;
}
.cw-typing span:nth-child(2) { animation-delay: .15s; }
.cw-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes cw-bounce {
  0%, 80%, 100% { transform: scale(.7); opacity: .5; }
  40%           { transform: scale(1);  opacity: 1;  }
}

/* Quick replies */
.cw-quick {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0 6px;
  align-self: stretch;
  animation: cw-msg-in .3s ease;
}
.cw-quick button {
  background: #fff;
  border: 1px solid #CBD5E1;
  color: #0B1E3F;
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 500;
  font-family: inherit;
  text-align: left;
  transition: background .15s, border-color .15s, transform .1s;
}
.cw-quick button:hover {
  background: #ECFDF5;
  border-color: #10B981;
  color: #059669;
}
.cw-quick button:active { transform: scale(.98); }

/* Footer / input */
.cw-footer {
  border-top: 1px solid #E2E8F0;
  background: #fff;
  padding: 10px 12px;
  flex-shrink: 0;
}
.cw-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.cw-input {
  flex: 1;
  border: 1px solid #E2E8F0;
  background: #F8FAFC;
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-family: inherit;
  color: #0F172A;
  outline: none;
  transition: border-color .15s, background .15s;
}
.cw-input:focus { border-color: #10B981; background: #fff; }
.cw-send {
  width: 40px;
  height: 40px;
  background: #0B1E3F;
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .1s;
}
.cw-send:hover { background: #13294D; }
.cw-send:active { transform: scale(.94); }
.cw-send:disabled { background: #CBD5E1; cursor: not-allowed; }
.cw-send svg { width: 18px; height: 18px; }

.cw-legal {
  text-align: center;
  font-size: 0.7rem;
  color: #94A3B8;
  margin-top: 8px;
}
.cw-legal a { color: #64748B; text-decoration: none; }
.cw-legal a:hover { color: #0B1E3F; text-decoration: underline; }

/* Responsive */
@media (max-width: 480px) {
  .cw-root { right: 16px; bottom: 16px; }
  .cw-launcher { width: 56px; height: 56px; }
  .cw-panel {
    width: calc(100vw - 32px);
    height: calc(100vh - 100px);
    bottom: 72px;
  }
}
