/* ==========================================================================
   Chat Widget — Floating AI Assistant
   ========================================================================== */

/* ── Toggle Button ── */
.chat-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00E5FF, #00B8D4);
  color: #0A0A0A;
  border: none;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(0,229,255,.4);
  z-index: 9997;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .3s cubic-bezier(.4,0,.2,1);
}
.chat-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(0,229,255,.5);
}
.chat-toggle.open .chat-icon-open { display: none; }
.chat-toggle.open .chat-icon-close { display: flex !important; }

/* ── Notification Pulse ── */
.chat-toggle::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(0,229,255,.4);
  animation: chat-pulse 2s ease-out infinite;
}
.chat-toggle.open::after { display: none; }

@keyframes chat-pulse {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* ── Chat Panel ── */
.chat-panel {
  position: fixed;
  bottom: 96px;
  right: 24px;
  width: 380px;
  max-height: 520px;
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.18);
  z-index: 9998;
  display: none;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid #E4E4E7;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: opacity .25s cubic-bezier(.4,0,.2,1), transform .25s cubic-bezier(.4,0,.2,1);
}
.chat-panel.open {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ── Panel Header ── */
.chat-panel-header {
  background: linear-gradient(135deg, #0A0A0A, #1E1E1E);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.chat-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #00E5FF, #00B8D4);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.chat-header-info {
  flex: 1;
  min-width: 0;
}
.chat-header-name {
  color: #fff;
  font-weight: 600;
  font-size: 14px;
}
.chat-header-status {
  color: rgba(255,255,255,.5);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.chat-online-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  display: inline-block;
  animation: chat-dot-pulse 2s infinite;
}
@keyframes chat-dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .5; }
}
.chat-close-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,.5);
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  transition: color .2s;
}
.chat-close-btn:hover { color: #fff; }

/* ── Messages ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 340px;
  scroll-behavior: smooth;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-thumb { background: #D4D4D8; border-radius: 4px; }

/* ── Message Bubbles ── */
.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-wrap: break-word;
  animation: chat-msg-in .2s ease-out;
}
@keyframes chat-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.chat-msg-user {
  align-self: flex-end;
  background: #0A0A0A;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg-bot {
  align-self: flex-start;
  background: #F4F4F5;
  color: #333;
  border-bottom-left-radius: 4px;
}
.chat-msg-bot a {
  color: #00B8D4;
  text-decoration: underline;
}
.chat-msg-user a {
  color: #80F0FF;
  text-decoration: underline;
}

/* ── Typing Indicator ── */
.chat-typing {
  align-self: flex-start;
  display: none;
  gap: 4px;
  padding: 12px 16px;
  background: #F4F4F5;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.chat-typing span {
  width: 6px;
  height: 6px;
  background: #A1A1AA;
  border-radius: 50%;
  animation: chat-bounce .6s infinite alternate;
}
.chat-typing span:nth-child(2) { animation-delay: .2s; }
.chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes chat-bounce {
  to { transform: translateY(-4px); opacity: .5; }
}

/* ── Input Area ── */
.chat-input-area {
  padding: 12px 14px;
  border-top: 1px solid #E4E4E7;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: #fff;
}
.chat-input {
  flex: 1;
  border: 1px solid #E4E4E7;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  resize: none;
  max-height: 80px;
  outline: none;
  transition: border-color .2s;
  line-height: 1.4;
}
.chat-input:focus { border-color: #00E5FF; }
.chat-input::placeholder { color: #A1A1AA; }
.chat-send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #00E5FF;
  color: #0A0A0A;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .2s;
}
.chat-send:hover { background: #00B8D4; transform: scale(1.05); }
.chat-send:disabled { opacity: .4; cursor: not-allowed; transform: none; }

/* ── Powered By ── */
.chat-powered {
  text-align: center;
  padding: 6px 0;
  font-size: 11px;
  color: #A1A1AA;
  background: #FAFAFA;
  border-top: 1px solid #F4F4F5;
  flex-shrink: 0;
}

/* ── Mobile ── */
@media (max-width: 480px) {
  .chat-panel {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-height: 85vh;
    border-radius: 16px 16px 0 0;
  }
  .chat-messages { max-height: calc(85vh - 160px); }
  .chat-toggle { bottom: 16px; right: 16px; width: 52px; height: 52px; }
}
