:root {
  --apex-ai-primary: #1a1a6e;
  --apex-ai-accent: #00c2ff;
  --apex-ai-bg: #ffffff;
  --apex-ai-text: #172033;
  --apex-ai-muted: #6b7280;
  --apex-ai-border: rgba(15, 23, 42, 0.12);
  --apex-ai-shadow: 0 24px 70px rgba(2, 8, 23, 0.22);
}

.apex-ai-chatbot * {
  box-sizing: border-box;
}

.apex-ai-floating {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 999999;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.apex-ai-inline {
  position: relative;
  max-width: 420px;
  margin: 20px auto;
  font-family: Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.apex-ai-launcher {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  border: 0;
  border-radius: 999px;
  padding: 14px 18px;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(135deg, var(--apex-ai-primary), var(--apex-ai-accent));
  box-shadow: 0 15px 35px rgba(26, 26, 110, 0.25);
  font-weight: 700;
  font-size: 15px;
  transition: transform .2s ease, box-shadow .2s ease;
}

.apex-ai-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 42px rgba(26, 26, 110, 0.35);
}

.apex-ai-launcher-icon {
  font-size: 20px;
  line-height: 1;
}

.apex-ai-window {
  width: 370px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 100px);
  background: var(--apex-ai-bg);
  color: var(--apex-ai-text);
  border: 1px solid var(--apex-ai-border);
  border-radius: 24px;
  box-shadow: var(--apex-ai-shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.apex-ai-floating .apex-ai-window {
  position: absolute;
  right: 0;
  bottom: 72px;
}

.apex-ai-inline .apex-ai-window {
  position: relative;
  width: 100%;
  height: 620px;
  max-height: none;
  box-shadow: 0 20px 55px rgba(2, 8, 23, 0.14);
}

.apex-ai-header {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 72px;
  padding: 14px 16px;
  color: #fff;
  background: radial-gradient(circle at top right, var(--apex-ai-accent), transparent 32%), linear-gradient(135deg, var(--apex-ai-primary), #0b114c);
}

.apex-ai-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--apex-ai-primary);
  background: #fff;
  font-weight: 900;
  font-size: 13px;
  box-shadow: inset 0 0 0 3px rgba(0, 194, 255, 0.22);
}

.apex-ai-header strong {
  display: block;
  font-size: 16px;
  line-height: 1.2;
}

.apex-ai-header span {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  opacity: .9;
}

.apex-ai-close {
  margin-left: auto;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .14);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}

.apex-ai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  background:
    radial-gradient(circle at 20% 0, rgba(0, 194, 255, .08), transparent 30%),
    linear-gradient(180deg, #f8fbff 0%, #fff 100%);
}

.apex-ai-message {
  display: flex;
  margin: 10px 0;
  animation: apexAiFadeIn .22s ease-out;
}

.apex-ai-message.user {
  justify-content: flex-end;
}

.apex-ai-bubble {
  max-width: 85%;
  padding: 11px 13px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-line;
  word-wrap: break-word;
}

.apex-ai-message.bot .apex-ai-bubble {
  border-top-left-radius: 5px;
  background: #fff;
  color: var(--apex-ai-text);
  border: 1px solid var(--apex-ai-border);
  box-shadow: 0 8px 18px rgba(15, 23, 42, .06);
}

.apex-ai-message.user .apex-ai-bubble {
  border-top-right-radius: 5px;
  color: #fff;
  background: linear-gradient(135deg, var(--apex-ai-primary), #28319c);
}

.apex-ai-card {
  background: #fff;
  border: 1px solid var(--apex-ai-border);
  border-radius: 18px;
  padding: 13px;
  margin-top: 8px;
  box-shadow: 0 8px 18px rgba(15, 23, 42, .06);
}

.apex-ai-card strong {
  display: block;
  margin-bottom: 6px;
}

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

.apex-ai-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 999px;
  padding: 9px 12px;
  color: #fff !important;
  background: linear-gradient(135deg, var(--apex-ai-primary), var(--apex-ai-accent));
  text-decoration: none !important;
  font-weight: 700;
  font-size: 13px;
}

.apex-ai-quick-actions {
  display: flex;
  gap: 8px;
  padding: 11px 12px;
  overflow-x: auto;
  border-top: 1px solid var(--apex-ai-border);
  background: #fff;
}

.apex-ai-quick-actions button {
  flex: 0 0 auto;
  border: 1px solid rgba(26, 26, 110, .16);
  background: rgba(26, 26, 110, .05);
  color: var(--apex-ai-primary);
  border-radius: 999px;
  padding: 8px 11px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.apex-ai-input-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: #fff;
  border-top: 1px solid var(--apex-ai-border);
}

.apex-ai-input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--apex-ai-border);
  border-radius: 999px;
  padding: 12px 14px;
  color: var(--apex-ai-text);
  outline: none;
  font-size: 14px;
}

.apex-ai-input:focus {
  border-color: var(--apex-ai-accent);
  box-shadow: 0 0 0 3px rgba(0, 194, 255, .12);
}

.apex-ai-input-form button {
  border: 0;
  border-radius: 999px;
  padding: 0 15px;
  color: #fff;
  background: var(--apex-ai-primary);
  cursor: pointer;
  font-weight: 800;
}

.apex-ai-lead-form {
  display: grid;
  gap: 8px;
  margin-top: 10px;
}

.apex-ai-lead-form input,
.apex-ai-lead-form textarea {
  width: 100%;
  border: 1px solid var(--apex-ai-border);
  border-radius: 12px;
  padding: 10px 11px;
  font: inherit;
  outline: none;
}

.apex-ai-lead-form textarea {
  min-height: 78px;
  resize: vertical;
}

.apex-ai-lead-form button {
  border: 0;
  border-radius: 12px;
  padding: 11px 12px;
  color: #fff;
  background: linear-gradient(135deg, var(--apex-ai-primary), var(--apex-ai-accent));
  font-weight: 800;
  cursor: pointer;
}

.apex-ai-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 13px;
  border-radius: 15px;
  background: #fff;
  border: 1px solid var(--apex-ai-border);
}

.apex-ai-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--apex-ai-muted);
  animation: apexAiTyping 1s infinite ease-in-out;
}

.apex-ai-typing i:nth-child(2) { animation-delay: .12s; }
.apex-ai-typing i:nth-child(3) { animation-delay: .24s; }

@keyframes apexAiTyping {
  0%, 80%, 100% { transform: translateY(0); opacity: .45; }
  40% { transform: translateY(-4px); opacity: 1; }
}

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

@media (max-width: 640px) {
  .apex-ai-floating {
    right: 14px;
    bottom: 14px;
  }

  .apex-ai-window {
    width: calc(100vw - 24px);
    height: min(620px, calc(100vh - 92px));
    border-radius: 20px;
  }

  .apex-ai-floating .apex-ai-window {
    right: -2px;
    bottom: 68px;
  }

  .apex-ai-launcher-text {
    display: none;
  }
}
