/* =============================================
   DMARS Chatbot Widget — chatbot.css
   Append to or replace existing chatbot.css
   ============================================= */

/* ── FAB (floating action button) ───────────── */
.chat-fab {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 20px;
  background: #0057ff;
  color: #fff;
  border: none;
  border-radius: 50px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 24px rgba(0, 87, 255, 0.38);
  transition: background 0.2s, transform 0.18s, box-shadow 0.2s;
  white-space: nowrap;
}

.chat-fab:hover {
  background: #0046cc;
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0, 87, 255, 0.44);
}

.chat-fab:focus-visible {
  outline: 3px solid #0057ff;
  outline-offset: 3px;
}

.chat-fab__label {
  line-height: 1;
}

@media (max-width: 480px) {
  .chat-fab__label {
    display: none;
  }

  .chat-fab {
    padding: 15px;
    border-radius: 50%;
  }
}

/* ── Container ───────────────────────────────── */
#chatbot-container {
  position: fixed;
  bottom: 96px;
  right: 28px;
  z-index: 9998;
  width: 380px;
  max-width: calc(100vw - 32px);
  max-height: calc(100vh - 120px);
  display: flex;
  flex-direction: column;
}

#chatbot-container[hidden] {
  display: none;
}

/* ── Panel ───────────────────────────────────── */
.chatbot-panel {
  display: flex;
  flex-direction: column;
  height: 520px;
  max-height: calc(100vh - 140px);
  background: #0f1117;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  overflow: hidden;
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(0, 87, 255, 0.12);
  animation: chatbot-slide-in 0.22s cubic-bezier(0.2, 0.9, 0.2, 1) both;
}

@keyframes chatbot-slide-in {
  from {
    opacity: 0;
    transform: translateY(16px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ── Header ──────────────────────────────────── */
.chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: #0057ff;
  flex-shrink: 0;
}

.chatbot-header__info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.chatbot-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  flex-shrink: 0;
}

.chatbot-header__name {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.chatbot-header__status {
  margin: 0;
  font-size: 0.72rem;
  color: rgba(255, 255, 255, 0.82);
  display: flex;
  align-items: center;
  gap: 5px;
  line-height: 1;
}

.chatbot-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.3);
  animation: chatbot-pulse 2s ease-in-out infinite;
}

@keyframes chatbot-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.3); }
  50%       { box-shadow: 0 0 0 5px rgba(74, 222, 128, 0.08); }
}

.chatbot-header__actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chatbot-icon-btn {
  background: transparent;
  border: none;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}

.chatbot-icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.chatbot-icon-btn:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.6);
  outline-offset: 2px;
}

/* ── Messages area ───────────────────────────── */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
  width: 4px;
}

.chatbot-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

/* ── Message rows ────────────────────────────── */
.chatbot-msg {
  display: flex;
  max-width: 88%;
}

.chatbot-msg--user {
  align-self: flex-end;
  justify-content: flex-end;
}

.chatbot-msg--bot {
  align-self: flex-start;
  justify-content: flex-start;
}

/* ── Bubbles ─────────────────────────────────── */
.chatbot-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.855rem;
  line-height: 1.55;
  word-break: break-word;
  animation: chatbot-bubble-in 0.18s ease both;
}

@keyframes chatbot-bubble-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.chatbot-msg--user .chatbot-bubble {
  background: #0057ff;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chatbot-msg--bot .chatbot-bubble {
  background: #1a1d27;
  color: #e2e4ec;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-bottom-left-radius: 4px;
}

/* ── Typing indicator ────────────────────────── */
.chatbot-bubble--typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  min-width: 52px;
}

.chatbot-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  animation: chatbot-typing 1.3s ease-in-out infinite;
  display: inline-block;
}

.chatbot-dot:nth-child(2) { animation-delay: 0.2s; }
.chatbot-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatbot-typing {
  0%, 80%, 100% {
    transform: translateY(0);
    background: rgba(255, 255, 255, 0.3);
  }
  40% {
    transform: translateY(-5px);
    background: rgba(255, 255, 255, 0.75);
  }
}

/* ── Form ────────────────────────────────────── */
.chatbot-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  background: #0f1117;
  flex-shrink: 0;
}

.chatbot-input {
  flex: 1;
  background: #1a1d27;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #e2e4ec;
  font-size: 0.855rem;
  font-family: inherit;
  padding: 10px 14px;
  outline: none;
  transition: border-color 0.18s;
  min-width: 0;
}

.chatbot-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
}

.chatbot-input:focus {
  border-color: #0057ff;
}

.chatbot-send {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  background: #0057ff;
  border: none;
  border-radius: 10px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s, transform 0.15s;
}

.chatbot-send:hover:not(:disabled) {
  background: #0046cc;
  transform: scale(1.05);
}

.chatbot-send:disabled {
  background: #1a1d27;
  cursor: not-allowed;
  opacity: 0.5;
}

.chatbot-send:focus-visible {
  outline: 2px solid #0057ff;
  outline-offset: 2px;
}

/* ── Footer ──────────────────────────────────── */
.chatbot-footer {
  text-align: center;
  font-size: 0.7rem;
  color: rgba(255, 255, 255, 0.22);
  padding: 6px 14px 10px;
  margin: 0;
  background: #0f1117;
  flex-shrink: 0;
}

.chatbot-footer a {
  color: rgba(255, 255, 255, 0.35);
  text-decoration: none;
}

.chatbot-footer a:hover {
  color: rgba(255, 255, 255, 0.6);
}

/* ── Mobile ──────────────────────────────────── */
@media (max-width: 480px) {
  #chatbot-container {
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    max-width: 100%;
    max-height: 92vh;
    border-radius: 0;
  }

  .chatbot-panel {
    height: 92vh;
    max-height: 92vh;
    border-radius: 16px 16px 0 0;
  }
}

/* ── Reduced motion ──────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .chatbot-panel,
  .chatbot-bubble,
  .chatbot-dot,
  .chatbot-status-dot,
  .chat-fab {
    animation: none;
    transition: none;
  }
}
