/* ── Chat Widget ── */

/* ── Toggle button — always fixed, always visible ── */
.chat-widget-toggle {
  position: fixed !important;
  right: 24px !important;
  bottom: 24px !important;
  top: auto !important;
  left: auto !important;
  z-index: 2147483647 !important;
  display: flex !important;
  visibility: visible !important;
  opacity: 1 !important;
  width: 60px !important;
  height: 60px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, #1e3a5f, #38bdf8) !important;
  border: 2px solid #7dd3fc !important;
  box-shadow: 0 4px 20px rgba(56, 189, 248, 0.5) !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  color: #fff !important;
  font-size: 24px !important;
  line-height: 1 !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: visible !important;
  pointer-events: auto !important;
  transform: none;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.chat-widget-toggle:hover {
  transform: scale(1.1) !important;
  box-shadow: 0 6px 28px rgba(56, 189, 248, 0.7) !important;
}

/* ── Panel ── */
.chat-widget-panel {
  position: fixed;
  right: 24px;
  bottom: 96px;
  z-index: 2147483646;
  width: 380px;
  height: 520px;
  background: #111d33;
  border: 1px solid rgba(147, 197, 253, 0.28);
  border-radius: 18px;
  box-shadow: 0 20px 48px rgba(4, 11, 24, 0.7);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transition: transform 0.22s ease, opacity 0.22s ease, visibility 0.22s;
}

.chat-widget-panel--hidden {
  transform: scale(0.9) translateY(16px);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.chat-widget-panel:not(.chat-widget-panel--hidden) {
  transform: scale(1) translateY(0);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* ── Header ── */
.chat-widget-header {
  background: linear-gradient(135deg, #0d1e36, #1a3552);
  border-bottom: 1px solid rgba(147, 197, 253, 0.28);
  padding: 14px 16px 12px;
  flex-shrink: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.chat-widget-header strong {
  display: block;
  font-size: 14px;
  font-weight: 700;
  color: #7dd3fc;
  letter-spacing: 0.02em;
}

.chat-widget-header p {
  margin: 2px 0 0;
  font-size: 12px;
  color: #94a3b8;
  line-height: 1.4;
}

.chat-widget-close {
  background: none !important;
  border: none !important;
  color: #94a3b8 !important;
  font-size: 22px !important;
  cursor: pointer !important;
  padding: 0 !important;
  line-height: 1 !important;
  margin-left: 8px;
  flex-shrink: 0;
  opacity: 0.7;
  transition: opacity 0.15s;
}

.chat-widget-close:hover {
  opacity: 1 !important;
  color: #e5e7eb !important;
}

/* ── Messages ── */
.chat-widget-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(125, 211, 252, 0.25) transparent;
}

.chat-widget-messages::-webkit-scrollbar { width: 4px; }
.chat-widget-messages::-webkit-scrollbar-track { background: transparent; }
.chat-widget-messages::-webkit-scrollbar-thumb {
  background: rgba(125, 211, 252, 0.25);
  border-radius: 4px;
}

/* ── Bubbles ── */
.chat-message {
  max-width: 88%;
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
  white-space: pre-wrap;
}

.chat-message-user {
  align-self: flex-end;
  background: #1e4a72;
  color: #e0f2fe;
  border-bottom-right-radius: 4px;
  border: 1px solid rgba(56, 189, 248, 0.3);
}

.chat-message-assistant {
  align-self: flex-start;
  background: rgba(207, 232, 255, 0.1);
  color: #e5e7eb;
  border: 1px solid rgba(147, 197, 253, 0.2);
  border-bottom-left-radius: 4px;
}

.chat-message-error {
  align-self: flex-start;
  background: rgba(185, 28, 28, 0.18);
  color: #fca5a5;
  border: 1px solid rgba(248, 113, 113, 0.3);
  border-bottom-left-radius: 4px;
  font-size: 13px;
}

/* ── Loading dots ── */
.chat-message-loading {
  align-self: flex-start;
  background: rgba(207, 232, 255, 0.1);
  border: 1px solid rgba(147, 197, 253, 0.2);
  border-bottom-left-radius: 4px;
  padding: 9px 14px;
  border-radius: 14px;
  color: #94a3b8;
  font-size: 13px;
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-dots span {
  display: inline-block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #7dd3fc;
  animation: cwBounce 1.1s infinite ease-in-out;
}
.chat-dots span:nth-child(2) { animation-delay: 0.18s; }
.chat-dots span:nth-child(3) { animation-delay: 0.36s; }

@keyframes cwBounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.5; }
  40%            { transform: translateY(-5px); opacity: 1; }
}

/* ── Input form ── */
.chat-widget-form {
  border-top: 1px solid rgba(147, 197, 253, 0.28);
  background: #16233b;
  padding: 10px 12px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  margin: 0;
}

.chat-widget-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.06) !important;
  border: 1px solid rgba(125, 211, 252, 0.3) !important;
  border-radius: 12px !important;
  padding: 8px 12px !important;
  color: #e5e7eb !important;
  font-size: 13.5px;
  font-family: inherit;
  outline: none !important;
  height: 38px;
  min-width: 0;
}

.chat-widget-input::placeholder { color: #94a3b8; }

.chat-widget-input:focus {
  border-color: #38bdf8 !important;
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.15) !important;
}

.chat-widget-submit {
  flex-shrink: 0;
  width: 38px !important;
  height: 38px !important;
  border-radius: 10px !important;
  background: linear-gradient(135deg, #1e4a72, #38bdf8) !important;
  border: 1px solid #7dd3fc !important;
  color: #fff !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  cursor: pointer !important;
  font-size: 16px;
  padding: 0 !important;
  transition: opacity 0.18s, transform 0.15s;
}

.chat-widget-submit:hover:not(:disabled) { transform: scale(1.08); }
.chat-widget-submit:disabled { opacity: 0.4 !important; cursor: not-allowed !important; }

/* ── Mobile ── */
@media (max-width: 480px) {
  .chat-widget-panel {
    right: 8px;
    left: 8px;
    bottom: 88px;
    width: auto;
    height: 72vh;
    max-height: 520px;
  }

  .chat-widget-toggle {
    bottom: 16px !important;
    right: 16px !important;
  }
}
