/* ============================================================
   ErrorVoid Chat Widget - Vercel-inspired Light Glass UI
   ============================================================ */

:root {
  --ev-chat-border: rgba(15, 23, 42, 0.08);
  --ev-chat-border-strong: rgba(15, 23, 42, 0.14);
  --ev-chat-shadow:
    0 24px 80px rgba(15, 23, 42, 0.18), 0 2px 16px rgba(15, 23, 42, 0.08);
  --ev-chat-panel: rgba(255, 255, 255, 0.96);
  --ev-chat-panel-soft: rgba(248, 250, 252, 0.92);
  --ev-chat-surface: #ffffff;
  --ev-chat-surface-soft: #f8fafc;
  --ev-chat-text: #0f172a;
  --ev-chat-muted: #64748b;
  --ev-chat-soft: #f8fafc;
  --ev-chat-soft-2: #eef2ff;
  --ev-chat-accent: #111827;
  --ev-chat-accent-soft: rgba(17, 24, 39, 0.08);
  --ev-chat-accent-ring: rgba(15, 23, 42, 0.12);
  --ev-chat-link: #2563eb;
  --ev-chat-user-text: #ffffff;
  --ev-chat-user-bg: linear-gradient(180deg, #111827 0%, #0f172a 100%);
  --ev-chat-launcher-bg: rgba(255, 255, 255, 0.86);
  --ev-chat-launcher-text: #0f172a;
  --ev-chat-launcher-icon-bg: linear-gradient(180deg, #111827 0%, #0f172a 100%);
  --ev-chat-launcher-border: rgba(255, 255, 255, 0.75);
}

:root[data-theme="dark"] {
  --ev-chat-border: rgba(255, 255, 255, 0.1);
  --ev-chat-border-strong: rgba(255, 255, 255, 0.18);
  --ev-chat-shadow:
    0 26px 80px rgba(0, 0, 0, 0.42), 0 2px 16px rgba(0, 0, 0, 0.22);
  --ev-chat-text: #f8fafc;
  --ev-chat-muted: rgba(248, 250, 252, 0.68);
  --ev-chat-soft: rgba(255, 255, 255, 0.04);
  --ev-chat-soft-2: rgba(255, 255, 255, 0.06);
  --ev-chat-accent: #ffffff;
  --ev-chat-accent-soft: rgba(255, 255, 255, 0.08);
  --ev-chat-accent-ring: rgba(255, 255, 255, 0.14);
  --ev-chat-link: #93c5fd;
  --ev-chat-panel: rgba(15, 23, 42, 0.94);
  --ev-chat-panel-soft: rgba(15, 23, 42, 0.88);
  --ev-chat-surface: rgba(15, 23, 42, 0.94);
  --ev-chat-surface-soft: rgba(15, 23, 42, 0.88);
  --ev-chat-user-text: #0f172a;
  --ev-chat-user-bg: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  --ev-chat-launcher-bg: rgba(15, 23, 42, 0.82);
  --ev-chat-launcher-text: #f8fafc;
  --ev-chat-launcher-icon-bg: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  --ev-chat-launcher-border: rgba(255, 255, 255, 0.12);
  --ev-chat-scrollbar-thumb: rgba(255, 255, 255, 0.16);
}

:root[data-theme="light"] {
  --ev-chat-border: rgba(15, 23, 42, 0.08);
  --ev-chat-border-strong: rgba(15, 23, 42, 0.14);
  --ev-chat-shadow:
    0 24px 80px rgba(15, 23, 42, 0.18), 0 2px 16px rgba(15, 23, 42, 0.08);
  --ev-chat-panel: rgba(255, 255, 255, 0.96);
  --ev-chat-panel-soft: rgba(248, 250, 252, 0.92);
  --ev-chat-surface: #ffffff;
  --ev-chat-surface-soft: #f8fafc;
  --ev-chat-text: #0f172a;
  --ev-chat-muted: #64748b;
  --ev-chat-soft: #f8fafc;
  --ev-chat-soft-2: #eef2ff;
  --ev-chat-accent: #111827;
  --ev-chat-accent-soft: rgba(17, 24, 39, 0.08);
  --ev-chat-accent-ring: rgba(15, 23, 42, 0.12);
  --ev-chat-link: #2563eb;
  --ev-chat-user-text: #ffffff;
  --ev-chat-user-bg: linear-gradient(180deg, #111827 0%, #0f172a 100%);
  --ev-chat-launcher-bg: rgba(255, 255, 255, 0.86);
  --ev-chat-launcher-text: #0f172a;
  --ev-chat-launcher-icon-bg: linear-gradient(180deg, #111827 0%, #0f172a 100%);
  --ev-chat-launcher-border: rgba(255, 255, 255, 0.75);
}

.chat-widget-container {
  position: fixed;
  right: 24px;
  bottom: 80px;
  width: min(368px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 112px));
  max-height: calc(100vh - 112px);
  display: flex;
  flex-direction: column;
  border-radius: 28px;
  overflow: hidden;
  border: 1px solid var(--ev-chat-border);
  background: linear-gradient(
    180deg,
    var(--ev-chat-panel) 0%,
    var(--ev-chat-panel-soft) 100%
  );
  box-shadow: var(--ev-chat-shadow);
  z-index: 99998;
  font-family:
    "DM Sans",
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  backdrop-filter: blur(22px) saturate(170%);
  -webkit-backdrop-filter: blur(22px) saturate(170%);
  animation: chatOpen 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.chat-widget-container::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  background:
    radial-gradient(
      circle at top left,
      rgba(37, 99, 235, 0.1),
      transparent 38%
    ),
    radial-gradient(
      circle at top right,
      rgba(15, 23, 42, 0.05),
      transparent 34%
    );
}

@keyframes chatOpen {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.chat-header {
  position: relative;
  background: linear-gradient(
    180deg,
    var(--ev-chat-panel) 0%,
    var(--ev-chat-panel-soft) 100%
  );
  border-bottom: 1px solid var(--ev-chat-border);
  padding: 14px 14px 12px;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  z-index: 1;
}

.chat-header::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: -1px;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(37, 99, 235, 0.45),
    transparent
  );
  opacity: 0.7;
}

.chat-header-content {
  flex: 1;
  min-width: 0;
}

.chat-header-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
  padding: 4px 9px;
  border: 1px solid var(--ev-chat-border);
  border-radius: 999px;
  background: var(--ev-chat-surface);
  color: var(--ev-chat-muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.chat-header-title {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--ev-chat-text);
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.chat-header-subtitle {
  margin: 5px 0 0 0;
  font-size: 12px;
  color: var(--ev-chat-muted);
  line-height: 1.45;
}

.chat-close-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--ev-chat-border);
  border-radius: 12px;
  background: var(--ev-chat-surface);
  color: var(--ev-chat-text);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease;
  flex-shrink: 0;
}

.chat-close-btn:hover {
  transform: translateY(-1px);
  background: var(--ev-chat-surface);
  border-color: var(--ev-chat-border-strong);
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.08);
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background:
    radial-gradient(circle at top, rgba(37, 99, 235, 0.04), transparent 28%),
    linear-gradient(
      180deg,
      var(--ev-chat-surface) 0%,
      var(--ev-chat-surface-soft) 100%
    );
  position: relative;
  z-index: 1;
}

.chat-messages::-webkit-scrollbar {
  width: 7px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: var(--ev-chat-scrollbar-thumb);
  border-radius: 999px;
}

.chat-message {
  display: flex;
  animation: chatMsgIn 0.22s ease;
}

@keyframes chatMsgIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.chat-message.user {
  justify-content: flex-end;
}

.chat-message.ai {
  justify-content: flex-start;
}

.chat-message-bubble {
  max-width: min(84%, 310px);
  padding: 11px 13px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--ev-chat-text);
  position: relative;
  word-break: break-word;
  letter-spacing: -0.01em;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.05);
}

.chat-message.ai .chat-message-bubble {
  background: var(--ev-chat-surface);
  border: 1px solid var(--ev-chat-border);
  border-top-left-radius: 7px;
}

.chat-message.user .chat-message-bubble {
  background: var(--ev-chat-user-bg);
  color: var(--ev-chat-user-text);
  border: 1px solid var(--ev-chat-border);
  border-top-right-radius: 7px;
}

.chat-message.ai .chat-message-bubble::before,
.chat-message.user .chat-message-bubble::before {
  content: "";
  position: absolute;
  top: 0;
  width: 10px;
  height: 10px;
  transform: skewY(-20deg);
}

.chat-message.ai .chat-message-bubble::before {
    top: 2px;
  left: -7px;
  background: var(--ev-chat-surface);
  border-left: 1px solid var(--ev-chat-border);
  border-top: 1px solid var(--ev-chat-border);
  border-top-left-radius: 2px;
  border-bottom-left-radius: 20px;
  transform: skewY(-8deg);

  
}

.chat-message.user .chat-message-bubble::before {
  right: -5px;
  background: var(--ev-chat-user-bg);
  border-right: 1px solid var(--ev-chat-border);
  border-top: 1px solid var(--ev-chat-border);
  border-top-right-radius: 2px;
  border-bottom-right-radius: 12px;
  

}

.chat-message-bubble strong {
  font-weight: 700;
  color: inherit;
}

.chat-message-bubble a {
  color: var(--ev-chat-link);
  text-decoration: none;
  font-weight: 600;
}

.chat-message-bubble a:hover {
  text-decoration: underline;
}

.chat-message.ai .chat-message-bubble.loading {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 56px;
  padding: 14px 16px;
}

.chat-typing-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: chatTyping 1.05s infinite ease-in-out;
}

.chat-typing-dot:nth-child(2) {
  animation-delay: 0.14s;
}

.chat-typing-dot:nth-child(3) {
  animation-delay: 0.28s;
}

@keyframes chatTyping {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.45;
  }
  40% {
    transform: translateY(-6px);
    opacity: 1;
  }
}

.chat-visitor-form,
.chat-input-area {
  position: relative;
  z-index: 1;
  background: var(--ev-chat-panel);
  border-top: 1px solid var(--ev-chat-border);
  padding: 12px;
}

.chat-visitor-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-form-header {
  font-size: 14px;
  font-weight: 700;
  color: var(--ev-chat-text);
  letter-spacing: -0.01em;
}

.chat-form-group {
  display: flex;
  flex-direction: column;
}

.chat-form-input,
.chat-input-field {
  width: 100%;
  border: 1px solid var(--ev-chat-border);
  border-radius: 12px;
  background: var(--ev-chat-surface);
  color: var(--ev-chat-text);
  font-size: 14px;
  line-height: 1.4;
  padding: 11px 13px;
  outline: none;
  transition:
    border-color 0.18s ease,
    box-shadow 0.18s ease,
    transform 0.18s ease;
}

.chat-form-input::placeholder,
.chat-input-field::placeholder {
  color: #94a3b8;
}

.chat-form-input:focus,
.chat-input-field:focus {
  border-color: rgba(37, 99, 235, 0.38);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

.chat-input-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.chat-suggestions {
  display: flex !important;
  flex-wrap: wrap;
  gap: 8px;
}

.chat-suggestion-btn {
  flex: 1;
  min-width: 112px;
  padding: 9px 11px;
  border: 1px solid var(--ev-chat-border);
  border-radius: 999px;
  background: linear-gradient(
    180deg,
    var(--ev-chat-surface) 0%,
    var(--ev-chat-surface-soft) 100%
  );
  color: var(--ev-chat-text);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-suggestion-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.06);
  border-color: rgba(37, 99, 235, 0.24);
  background: var(--ev-chat-surface);
}

.chat-input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.chat-input-field {
  resize: none;
  max-height: 110px;
  min-height: 46px;
}

.chat-send-btn {
  width: 42px;
  height: 42px;
  border: 1px solid var(--ev-chat-border);
  border-radius: 12px;
  background: var(--ev-chat-user-bg);
  color: var(--ev-chat-user-text);
  font-weight: 700;
  font-size: 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition:
    transform 0.18s ease,
    box-shadow 0.18s ease,
    opacity 0.18s ease;
  flex-shrink: 0;
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.12);
}

.chat-send-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 14px 26px rgba(15, 23, 42, 0.16);
}

.chat-send-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#start-chat-btn.chat-send-btn {
  width: 100%;
  border-radius: 12px;
  height: 42px;
  color: var(--ev-chat-user-text);
  font-size: 14px;
}

/* ============================================================
   FLOATING LAUNCHER
   ============================================================ */

.chat-toggle-btn {
  position: fixed;
  right: 24px;
  bottom: 24px;
  min-width: 210px;
  height: 58px;
  border: 1px solid rgba(255, 255, 255, 0.75);
  border-radius: 18px;
  background: var(--ev-chat-launcher-bg);
  box-shadow:
    0 14px 40px rgba(15, 23, 42, 0.16),
    0 0 0 1px rgba(255, 255, 255, 0.5) inset;
  backdrop-filter: blur(18px) saturate(160%);
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 18px;
  gap: 12px;
  z-index: 99999;
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    border-color 0.2s ease,
    background 0.2s ease;
  color: var(--ev-chat-text);
}

.chat-toggle-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(15, 23, 42, 0.12);
  background: var(--ev-chat-launcher-bg);
  box-shadow:
    0 18px 48px rgba(15, 23, 42, 0.2),
    0 0 0 1px rgba(255, 255, 255, 0.65) inset;
}

.chat-logo-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
}

.chat-toggle-icon-wrap {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: var(--ev-chat-launcher-icon-bg);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.16);
}

.chat-logo {
  width: 20px;
  height: 20px;
  filter: brightness(1.05);
}

.chat-toggle-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1px;
  min-width: 0;
  text-align: left;
}

.chat-toggle-kicker {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ev-chat-muted);
  line-height: 1.1;
}

.chat-toggle-title {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ev-chat-text);
  line-height: 1.2;
}

.chat-toggle-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  border-radius: 999px;
  border: 2px solid var(--ev-chat-surface);
  background: #ef4444;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  z-index: 10;
  box-shadow: 0 6px 14px rgba(239, 68, 68, 0.28);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 2px solid rgba(37, 99, 235, 0.45);
  outline-offset: 2px;
}

@media (max-width: 600px) {
  .chat-widget-container {
    width: 100%;
    height: calc(100vh - 12px);
    max-height: none;
    right: 0;
    bottom: 0;
    border-radius: 20px 20px 0 0;
    border: 1px solid var(--ev-chat-border);
    border-bottom: none;
  }

  .chat-toggle-btn {
    min-width: auto;
    width: auto;
    height: 54px;
    right: 16px;
    bottom: 16px;
    padding: 0 12px 0 10px;
    border-radius: 16px;
  }

  .chat-toggle-copy {
    display: none;
  }

  .chat-toggle-icon-wrap {
    width: 34px;
    height: 34px;
  }

  .chat-message-bubble {
    max-width: 90%;
  }

  .chat-header {
    padding: 13px 12px 11px;
  }

  .chat-messages,
  .chat-visitor-form,
  .chat-input-area {
    padding-left: 10px;
    padding-right: 10px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-widget-container,
  .chat-message,
  .chat-typing-dot,
  .chat-toggle-btn,
  .chat-close-btn,
  .chat-send-btn,
  .chat-suggestion-btn {
    animation: none !important;
    transition: none !important;
  }
}

@media print {
  .chat-widget-container,
  .chat-toggle-btn {
    display: none !important;
  }
}
/* --- Responsive chat widget --- */

/* Base: desktop floating */
.chat-widget-container {
  position: fixed;
  bottom: 90px;
  right: 24px;
  width: 380px;
  max-height: 600px;
}

/* Tablet */
@media (max-width: 768px) {
  .chat-widget-container {
    width: calc(100vw - 32px);
    right: 16px;
    bottom: 80px;
  }
  .chat-toggle-btn {
    right: 16px;
    bottom: 16px;
  }
}

/* Mobile: full-screen takeover */
@media (max-width: 494px) {
  .chat-widget-container {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }
  /* Hide the label text, keep icon only */
  .chat-toggle-copy {
    display: none;
  }
  .chat-toggle-btn {
    padding: 0;
    width: 52px;
    height: 52px;
    border-radius: 50%;
    justify-content: center;
  }
  .chat-toggle-icon-wrap {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    margin-left: 7px;
  }
}
@media (max-width: 502px) {
  .chat-widget-container {
    position: fixed;
    margin: 70px 20px 0px 70px;
    width: auto;
    max-height: 80%;
    border-radius: 18px;
    border: none;
    margin-bottom: 1rem;
  }

}
#ev-chat-widget.dark-mode .chat-widget-container {
    background: #000000;
    color: #f1f5f9;
    /* …and so on for headers, bubbles, inputs */
}