/* ===========================
   Reset & Base
=========================== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family:
    "Inter",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  background-color: #f9fafb;
  min-height: 100vh;
  color: #1e293b;
}

/* ===========================
   Demo Page Content
=========================== */
.page-content {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px 24px;
}

.page-hero {
  text-align: center;
  max-width: 900px;
  width: 100%;
}

.page-hero h1 {
  font-size: 2.8rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 12px;
  letter-spacing: -0.5px;
}

.page-hero > p {
  font-size: 1.1rem;
  color: #64748b;
  margin-bottom: 48px;
}

.hero-cards {
  display: flex;
  gap: 20px;
  justify-content: center;
  flex-wrap: wrap;
}

.hero-card {
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  padding: 32px 28px;
  width: 220px;
  text-align: center;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.hero-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
}

.card-icon {
  font-size: 2.2rem;
  margin-bottom: 14px;
}

.hero-card h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #0f172a;
  margin-bottom: 8px;
}

.hero-card p {
  font-size: 0.85rem;
  color: #64748b;
  line-height: 1.5;
}

/* ===========================
   Floating Chat Widget
=========================== */
.chat-widget {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
}

/* ===========================
   Chat Toggle Button
=========================== */
.chat-toggle-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #155791 0%, #01a75a 100%);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(0, 231, 116, 0.45);
  transition:
    transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
    box-shadow 0.25s ease;
  position: relative;
  outline: none;
  flex-shrink: 0;
}

.chat-toggle-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 10px 28px rgba(0, 231, 116, 0.55);
}

.chat-toggle-btn:active {
  transform: scale(0.95);
}

.toggle-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  transition:
    opacity 0.2s,
    transform 0.2s;
}

/* Pulse ring animation on button */
.chat-toggle-btn::before {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(0, 231, 116, 0.35);
  animation: ring-pulse 2.5s ease-out infinite;
}

@keyframes ring-pulse {
  0% {
    transform: scale(0.85);
    opacity: 0.8;
  }
  70% {
    transform: scale(1.25);
    opacity: 0;
  }
  100% {
    transform: scale(1.25);
    opacity: 0;
  }
}

/* Stop pulse ring when chat is open */
.chat-toggle-btn.open::before {
  animation: none;
  opacity: 0;
}

/* ===========================
   Chat Box
=========================== */
.chat-box {
  width: 390px;
  height: 595px;
  background: white;
  border-radius: 16px;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.18),
    0 4px 16px rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 0.3s cubic-bezier(0.34, 1.2, 0.64, 1),
    opacity 0.25s ease;
  border: 1px solid #e2e8f0;
}

.chat-box.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ===========================
   Chat Header — WHITE
=========================== */
.chat-header {
  background: #ffffff;
  border-bottom: 1px solid #e8edf3;
  padding: 14px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-shrink: 0;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.06);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
  border: 1.5px solid #e2e8f0;
  overflow: hidden;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.header-logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: 50%;
}

.header-online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 10px;
  height: 10px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid white;
}

.header-info h2 {
  font-size: 15px;
  font-weight: 700;
  color: #0f172a;
  line-height: 1.2;
}

.header-status {
  font-size: 12px;
  color: #64748b;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.status-dot {
  width: 7px;
  height: 7px;
  background: #22c55e;
  border-radius: 50%;
  display: inline-block;
  animation: statusPulse 2s infinite;
  flex-shrink: 0;
}

@keyframes statusPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

.header-actions {
  display: flex;
  gap: 4px;
}

.header-btn {
  background: #f1f5f9;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
  color: #475569;
}

.header-btn:hover {
  background: #e2e8f0;
}

/* 3-dot dropdown menu */
.header-menu-wrap {
  position: relative;
}

.header-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: white;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.13);
  min-width: 148px;
  z-index: 100;
  overflow: hidden;
  animation: dropdownFade 0.15s ease-out;
}

.header-dropdown.open {
  display: block;
}

@keyframes dropdownFade {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.dropdown-item {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 10px 14px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 13.5px;
  font-family: inherit;
  color: #374151;
  text-align: left;
  transition: background 0.14s;
}

.dropdown-item:hover {
  background: #f8fafc;
  color: #0f172a;
}

.dropdown-item:last-child {
  border-top: 1px solid #f1f5f9;
  color: #ef4444;
}

.dropdown-item:last-child:hover {
  background: #fff5f5;
  color: #dc2626;
}

/* ===========================
   Chat Messages
=========================== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background: #f8fafc;
  scroll-behavior: smooth;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.chat-messages::-webkit-scrollbar {
  width: 5px;
}
.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}
.chat-messages::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

.message {
  display: flex;
  gap: 10px;
  animation: msgSlide 0.28s ease-out;
}

@keyframes msgSlide {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-avatar {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  margin-top: auto;
  align-self: flex-end;
}

.bot-avatar {
  background: #ffffff;
  border: 1.5px solid #e2e8f0;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  overflow: hidden;
  padding: 2px;
}

.user-avatar {
  background: linear-gradient(135deg, #155791 0%, #01a75a 100%);
}

.message-content {
  max-width: 78%;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.message-content p {
  padding: 10px 14px;
  border-radius: 14px;
  line-height: 1.55;
  font-size: 14px;
  word-wrap: break-word;
}

.bot-message .message-content p {
  background: white;
  color: #1e293b;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
}

.user-message {
  flex-direction: row-reverse;
}

.user-message .message-content {
  align-items: flex-end;
}

.user-message .message-content p {
  background: linear-gradient(135deg, #155791 0%, #01a75a 100%);
  color: white;
  border-bottom-right-radius: 4px;
}

.message-sender-name {
  font-size: 11px;
  font-weight: 400;
  color: #94a3b8;
  margin-bottom: 2px;
}

.message-time {
  font-size: 10.5px;
  color: #94a3b8;
  padding: 0 4px;
}

/* ===========================
   Typing Indicator
=========================== */
.typing-indicator {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 0 16px 10px;
  background: #f8fafc;
}

.typing-indicator.active {
  display: flex;
}

.typing-avatar {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.typing-dots {
  background: white;
  border-radius: 12px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 4px;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.08);
}

.typing-dots span {
  width: 7px;
  height: 7px;
  background: #94a3b8;
  border-radius: 50%;
  animation: typingBounce 1.4s infinite;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typingBounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
    opacity: 0.6;
  }
  30% {
    transform: translateY(-8px);
    opacity: 1;
  }
}

/* ===========================
   Chat Input
=========================== */
.chat-input-container {
  padding: 12px 14px 10px;
  background: white;
  border-top: 1px solid #e8edf3;
  flex-shrink: 0;
}

.chat-input-form {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-input {
  flex: 1;
  padding: 10px 14px;
  border: 1.5px solid #e2e8f0;
  border-radius: 22px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
  background: #f8fafc;
  color: #1e293b;
  transition: all 0.2s;
}

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

.chat-input:focus {
  border-color: #01a75a;
  background: white;
  box-shadow: 0 0 0 3px rgba(0, 82, 204, 0.09);
}

.send-btn {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #155791 0%, #01a75a 100%);
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease;
}

.send-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(0, 82, 204, 0.38);
}

.send-btn:active {
  transform: scale(0.94);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.input-footer {
  font-size: 10.5px;
  color: #94a3b8;
  text-align: center;
  margin-top: 6px;
}

/* Attachment button */
.attach-btn {
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #94a3b8;
  border-radius: 50%;
  transition:
    background 0.18s ease,
    color 0.18s ease;
  padding: 0;
}

.attach-btn:hover {
  background: #f1f5f9;
  color: #01a75a;
}

.attach-btn:active {
  background: #e2e8f0;
}

/* active state when files are pending */
.attach-btn.has-files {
  color: #01a75a;
  background: #eff6ff;
}

/* ===========================
   File Preview Strip
=========================== */
.file-preview-strip {
  display: none;
  flex-direction: row;
  gap: 8px;
  padding: 8px 2px 6px;
  overflow-x: auto;
  flex-wrap: nowrap;
  border-bottom: 1px solid #f1f5f9;
  margin-bottom: 8px;
}

.file-preview-strip::-webkit-scrollbar {
  height: 3px;
}
.file-preview-strip::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.file-preview-strip.visible {
  display: flex;
}

.preview-item {
  position: relative;
  flex-shrink: 0;
  border-radius: 10px;
  overflow: hidden;
  background: #f1f5f9;
  border: 1.5px solid #e2e8f0;
}

/* Image preview thumbnail */
.preview-item img {
  width: 64px;
  height: 64px;
  object-fit: cover;
  display: block;
}

/* Non-image file badge */
.preview-file-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 64px;
  height: 64px;
  padding: 6px;
  text-align: center;
}

.preview-file-badge svg {
  flex-shrink: 0;
  color: #01a75a;
}

.preview-file-badge span {
  font-size: 9px;
  color: #475569;
  word-break: break-all;
  line-height: 1.2;
  max-width: 56px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
}

/* Remove button */
.preview-remove-btn {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 11px;
  line-height: 1;
  padding: 0;
  transition: background 0.15s;
}

.preview-remove-btn:hover {
  background: #ef4444;
}

/* ===========================
   Pre-Chat Screen
=========================== */
.prechat-screen {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
  background: white;
  animation: fadeInUp 0.3s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.prechat-body {
  flex: 1;
  padding: 28px 22px 16px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}

/* Greeting */
.prechat-greeting {
  text-align: center;
  padding-bottom: 4px;
}

.prechat-wave {
  font-size: 2.4rem;
  display: block;
  margin-bottom: 8px;
  animation: waveHand 1.5s ease-in-out 0.4s 2;
  transform-origin: 70% 70%;
}

@keyframes waveHand {
  0% {
    transform: rotate(0deg);
  }
  15% {
    transform: rotate(18deg);
  }
  30% {
    transform: rotate(-10deg);
  }
  45% {
    transform: rotate(14deg);
  }
  60% {
    transform: rotate(-8deg);
  }
  75% {
    transform: rotate(10deg);
  }
  100% {
    transform: rotate(0deg);
  }
}

.prechat-greeting h3 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #0f172a;
  margin-bottom: 6px;
  letter-spacing: -0.2px;
}

.prechat-greeting p {
  font-size: 0.875rem;
  color: #64748b;
  line-height: 1.5;
  max-width: 260px;
  margin: 0 auto;
}

/* Fields */
.prechat-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-group {
  position: relative;
}

.prechat-input {
  width: 100%;
  padding: 13px 16px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  font-family: inherit;
  color: #1e293b;
  background: white;
  outline: none;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

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

.prechat-input:focus {
  border-color: #01a75a;
  box-shadow: 0 0 0 3px rgba(0, 231, 116, 0.09);
}

.prechat-terms {
  font-size: 13px;
  color: #01a75a;
  text-decoration: none;
  display: block;
  margin-top: 2px;
  transition: color 0.15s;
}

.prechat-terms:hover {
  color: #005e32;
  text-decoration: underline;
}

/* Continue button */
.prechat-continue-btn {
  width: 100%;
  padding: 13px;
  background: #01a75a;
  color: white;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition:
    background 0.2s ease,
    transform 0.15s ease,
    box-shadow 0.2s ease;
  letter-spacing: 0.2px;
}

.prechat-continue-btn:hover {
  background: #01a75a;
  box-shadow: 0 4px 14px rgba(0, 231, 116, 0.35);
  transform: translateY(-1px);
}

.prechat-continue-btn:active {
  transform: translateY(0);
}

/* OR Divider */
.prechat-or {
  display: flex;
  align-items: center;
  gap: 10px;
}

.prechat-or span {
  flex: 1;
  height: 1px;
  background: #e2e8f0;
}

.prechat-or p {
  font-size: 12px;
  font-weight: 600;
  color: #94a3b8;
  letter-spacing: 0.5px;
}

/* Guest button */
.prechat-guest-btn {
  width: 100%;
  padding: 12px;
  background: #f1f5f9;
  color: #334155;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    transform 0.15s ease;
}

.prechat-guest-btn:hover {
  background: #e8edf3;
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.prechat-guest-btn:active {
  transform: translateY(0);
}

/* Powered by footer */
.prechat-footer {
  border-top: 1px solid #f1f5f9;
  padding: 10px 22px;
  text-align: center;
}

.prechat-footer p {
  font-size: 11.5px;
  color: #94a3b8;
}

.prechat-footer strong {
  color: #64748b;
  font-weight: 600;
}

/* Chat section flex layout */
.chat-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ===========================
   Responsive
=========================== */
@media (max-width: 480px) {
  .chat-widget {
    bottom: 16px;
    right: 16px;
  }

  .chat-box {
    width: calc(100vw - 32px);
    height: 595px;
  }
}
