:root {
  --bg: #f6f7fb;
  --panel: #000000;
  --bubble-bot: #000000;
  --bubble-user: #606060;
  --text: #ffffff;
  --muted: #f6f7fb;
  --accent: #ff0060;
  --shadow: 0 20px 60px rgba(17, 24, 39, 0.1);
  --radius: 16px;
  --font: "Inter", "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  font-family: var(--font);
  color: var(--text);
}

body.embed {
  background: transparent;
}

body.embed .page {
  position: static;
  width: 100%;
  height: auto;
  padding: 0;
  background: transparent;
}

body.embed .chat-shell {
  width: 100%;
  height: min(600px, calc(100vh - 120px));
  max-height: calc(100vh - 120px);
  border-radius: 16px;
  background: #536E7E;
  box-shadow: none;
}

.hidden {
  display: none;
}

.chat-toggle.hidden {
  display: none !important;
}

.chat-toggle {
  position: fixed;
  right: 24px;
  bottom: 24px;
  left: auto;
  top: auto;
  transform: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 1px solid #d1d5db;
  background: #ffffff;
  box-shadow: 0 5px 10px rgba(17, 24, 39, 0.2);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 8px;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
  z-index: 2147483647;
}

.chat-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 40px rgba(17, 24, 39, 0.24);
}

.chat-toggle:active {
  transform: none;
}

.header-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.chat-close {
  width: 36px;
  height: 36px;
  border-radius: 12px;
  border: none;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.chat-close:hover {
  background: rgba(255, 255, 255, 0.28);
}

.chat-close:active {
  transform: translateY(1px);
}

.page {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: min(420px, calc(100vw - 32px));
  display: block;
  z-index: 9000;
}

/* Force fixed positioning in embedded environments */
#chat-wrapper {
  position: fixed !important;
  bottom: 24px !important;
  right: 24px !important;
  width: min(420px, calc(100vw - 32px)) !important;
  max-width: calc(100vw - 32px) !important;
  left: auto !important;
  top: auto !important;
  z-index: 2147483646 !important;
  transform: none !important;
}

.page.hidden {
  display: none !important;
}

.chat-shell {
  width: min(420px, 100%);
  height: min(520px, calc(100vh - 200px));
  max-height: min(520px, calc(100vh - 200px));
  background: var(--panel);
  border-radius: 24px;
  box-shadow: var(--shadow);
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

.page {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 640px) {
  .page {
    left: 50% !important;
    right: auto !important;
    transform: translateX(-50%);
    width: min(360px, calc(100vw - 24px));
    bottom: 24px;
  }
  .chat-shell {
    width: calc(100% - 40px);
    margin: 0 auto;
    height: min(70vh, calc(100vh - 120px));
    max-height: calc(100vh - 120px);
  }
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid #e5e7eb;
}

.chat-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-title {
  margin: 0;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.brand-sub {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.status-pill {
  background: var(--accent);
  color: white;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 600;
  font-size: 13px;
}

.messages-container {
  padding: 24px;
  overflow-y: auto;
  background: linear-gradient(180deg, #f8f9fb 0%, #f2f4f8 100%);
}

.timestamp {
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 1.2px;
  margin: 12px 0 18px;
}

.message-row {
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 12px;
  margin-bottom: 14px;
  align-items: flex-start;
}

.message-row.user {
  grid-template-columns: 1fr 48px;
  justify-items: end;
}

.message-row.user .bubble {
  background: var(--bubble-user);
  border: 1px solid rgba(17, 24, 39, 0.06);
  justify-self: end;
  grid-column: 1 / 2;
}

.message-row.user .avatar-wrap {
  order: 2;
  grid-column: 2 / 3;
}

.downloads {
  margin-top: 10px;
  font-size: 13px;
}

.downloads ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.downloads a {
  color: #ffffff;
  text-decoration: none;
}

.downloads a:hover {
  text-decoration: underline;
}

.avatar {
  width: 36px;
  height: 36px;
  display: block;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #e5e7eb;
  padding: 4px;
}

.bubble {
  background: var(--bubble-bot);
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 14px;
  line-height: 1.5;
  border: 1px solid rgba(17, 24, 39, 0.05);
  box-shadow: 0 12px 30px rgba(17, 24, 39, 0.06);
  display: block;
  width: auto;
  max-width: 100%;
  overflow-wrap: anywhere;
  white-space: pre-line;
}

.bubble.loading {
  display: inline-flex;
  gap: 6px;
}

.suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}


.suggestion-btn {
  border: 1px solid #d1d5db;
  background: #000000;
  color: #ffffff;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.1s ease;
}

.suggestion-btn:hover {
  background: #111111;
  transform: translateY(-1px);
}

.suggestion-btn.contact-btn {
  background: #000000;
  color: #ffffff;
  border-color: #000000;
}

.suggestion-btn.contact-btn:hover {
  background: #111111;
}

.cta-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.pill-btn {
  border: none;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 6px 16px rgba(17, 24, 39, 0.15);
}

.pill-btn.ghost {
  background: #e5e7eb;
  color: #111827;
  box-shadow: none;
}
.dot {
  width: 8px;
  height: 8px;
  background: var(--muted);
  border-radius: 50%;
  animation: blink 1s infinite ease-in-out;
}

.dot:nth-child(2) {
  animation-delay: 0.2s;
}

.dot:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0%,
  80%,
  100% {
    opacity: 0.2;
  }
  40% {
    opacity: 1;
  }
}

.chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 18px 20px;
  border-top: 1px solid #e5e7eb;
  background: white;
}

.field-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.contact-cancel {
  border: 1px solid #111111;
  background: #ffffff;
  color: #111111;
  font-size: 16px;
  cursor: pointer;
  padding: 10px 12px;
  border-radius: 999px;
}

.contact-cancel:hover {
  background: #f3f4f6;
}

.contact-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
}

.contact-cancel-label {
  font-size: 12px;
  color: var(--text);
}

.extra-fields {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.extra-fields.hidden {
  display: none;
}

.chat-form input {
  border: 1px solid #d1d5db;
  border-radius: var(--radius);
  padding: 12px 14px;
  font-size: 15px;
  transition: border 0.2s ease, box-shadow 0.2s ease;
}

.chat-form input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(17, 24, 39, 0.12);
}

.chat-form button {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius);
  padding: 0 20px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.2s ease;
}

.chat-form button:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 30px rgba(17, 24, 39, 0.18);
}

.chat-form button:active {
  transform: translateY(0);
}

@media (max-width: 640px) {
  .page {
    padding: 16px;
  }
  .chat-shell {
    min-height: 80vh;
    border-radius: 18px;
  }
  .messages-container {
    padding: 16px;
  }
}
