/* AI Dynamics chatbot — floating widget */

.aid-chat {
  position: fixed;
  right: clamp(16px, 3vw, 28px);
  bottom: clamp(16px, 3vw, 28px);
  z-index: 9000;
  font-family: var(--wp--preset--font-family--sans, Inter, system-ui, sans-serif);
}

.aid-chat-fab {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: var(--wp--preset--color--accent, #22D3EE);
  color: var(--wp--preset--color--bg, #0A0A0B);
  border: 0;
  border-radius: 999px;
  padding: 0.7rem 1.15rem 0.7rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0;
  cursor: pointer;
  box-shadow: 0 0 0 1px rgba(34,211,238,0.35), 0 12px 28px rgba(0,0,0,0.45), 0 0 28px rgba(34,211,238,0.25);
  transition: transform 220ms cubic-bezier(.2,.7,.3,1), box-shadow 220ms ease;
  animation: aid-chat-pulse 2.6s ease-in-out infinite;
}
.aid-chat-fab:hover {
  transform: translateY(-2px) scale(1.02);
  box-shadow: 0 0 0 1px rgba(34,211,238,0.55), 0 18px 38px rgba(0,0,0,0.5), 0 0 40px rgba(34,211,238,0.45);
  animation-play-state: paused;
}
.aid-chat-fab:active { transform: translateY(0) scale(0.98); }
.aid-chat-fab svg { flex-shrink: 0; display: block; }
.aid-chat-fab-icon {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: var(--wp--preset--color--bg, #0A0A0B);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}
.aid-chat-fab-icon::after {
  content: "";
  position: absolute;
  top: 1px;
  right: 1px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #4ade80;
  border: 2px solid var(--wp--preset--color--accent, #22D3EE);
  animation: aid-chat-dot 2s ease-in-out infinite;
}
.aid-chat-fab-icon svg { color: var(--wp--preset--color--accent, #22D3EE); }
.aid-chat[data-open="true"] .aid-chat-fab { display: none !important; }

@keyframes aid-chat-pulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(34,211,238,0.35), 0 12px 28px rgba(0,0,0,0.45), 0 0 28px rgba(34,211,238,0.25); }
  50%      { box-shadow: 0 0 0 1px rgba(34,211,238,0.5),  0 12px 28px rgba(0,0,0,0.45), 0 0 44px rgba(34,211,238,0.5); }
}
@keyframes aid-chat-dot {
  0%, 100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(1.15); opacity: 0.7; }
}

.aid-chat-panel[hidden] { display: none !important; }

@media (max-width: 480px) {
  .aid-chat-fab-label { display: none; }
  .aid-chat-fab { padding: 0.85rem; }
}

.aid-chat-panel {
  position: fixed;
  right: clamp(12px, 3vw, 28px);
  bottom: clamp(12px, 3vw, 28px);
  width: min(380px, calc(100vw - 24px));
  height: min(620px, calc(100vh - 80px));
  background: var(--wp--preset--color--surface, #121214);
  border: 1px solid var(--wp--preset--color--border, #26262B);
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0,0,0,0.55), 0 0 0 1px rgba(34,211,238,0.08);
  color: var(--wp--preset--color--text, #EDEDED);
  animation: aid-chat-pop 220ms cubic-bezier(.2,.7,.3,1);
}
@media (max-width: 520px) {
  .aid-chat-panel {
    right: 0; bottom: 0; left: 0; top: 0;
    width: 100%; height: 100%;
    border-radius: 0;
    border: 0;
    max-height: 100dvh;
  }
}
@keyframes aid-chat-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.aid-chat-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.1rem 0.85rem;
  border-bottom: 1px solid var(--wp--preset--color--border, #26262B);
  background: linear-gradient(180deg, rgba(34,211,238,0.06), transparent 60%);
}
.aid-chat-eyebrow {
  font-family: var(--wp--preset--font-family--mono, ui-monospace, monospace);
  font-size: 0.7rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--wp--preset--color--accent, #22D3EE);
  display: block;
  margin-bottom: 0.15rem;
}
.aid-chat-title {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--wp--preset--color--text-strong, #FFF);
  letter-spacing: -0.01em;
}
.aid-chat-sub {
  margin: 0.2rem 0 0;
  font-size: 0.8rem;
  color: var(--wp--preset--color--muted, #8A8A93);
  line-height: 1.4;
}
.aid-chat-close {
  background: transparent;
  border: 1px solid var(--wp--preset--color--border, #26262B);
  color: var(--wp--preset--color--muted, #8A8A93);
  width: 28px;
  height: 28px;
  border-radius: 8px;
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  transition: color 180ms, border-color 180ms;
  flex-shrink: 0;
}
.aid-chat-close:hover {
  color: var(--wp--preset--color--text-strong, #FFF);
  border-color: var(--wp--preset--color--accent, #22D3EE);
}

.aid-chat-log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem 1rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  scroll-behavior: smooth;
}
.aid-chat-log::-webkit-scrollbar { width: 6px; }
.aid-chat-log::-webkit-scrollbar-thumb { background: var(--wp--preset--color--border, #26262B); border-radius: 3px; }

.aid-chat-msg { display: flex; }
.aid-chat-msg--bot  { justify-content: flex-start; }
.aid-chat-msg--user { justify-content: flex-end; }
.aid-chat-bubble {
  max-width: 86%;
  padding: 0.65rem 0.85rem;
  border-radius: 12px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.aid-chat-msg--bot .aid-chat-bubble {
  background: var(--wp--preset--color--surface-2, #1A1A1D);
  border: 1px solid var(--wp--preset--color--border, #26262B);
  border-top-left-radius: 4px;
  color: var(--wp--preset--color--text, #EDEDED);
}
.aid-chat-msg--user .aid-chat-bubble {
  background: rgba(34, 211, 238, 0.12);
  border: 1px solid rgba(34, 211, 238, 0.3);
  border-top-right-radius: 4px;
  color: var(--wp--preset--color--text-strong, #FFF);
}
.aid-chat-bubble a {
  color: var(--wp--preset--color--accent, #22D3EE);
  text-decoration: underline;
}

.aid-chat-typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 0.65rem 0.85rem;
}
.aid-chat-typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--wp--preset--color--muted, #8A8A93);
  animation: aid-chat-bounce 1.2s infinite ease-in-out;
}
.aid-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.aid-chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes aid-chat-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

.aid-chat-error {
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.35);
  color: var(--wp--preset--color--text, #EDEDED);
  font-size: 0.85rem;
  margin: 0 0.25rem;
}

.aid-chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.7rem 0.85rem 0.6rem;
  border-top: 1px solid var(--wp--preset--color--border, #26262B);
  background: var(--wp--preset--color--bg, #0A0A0B);
  position: relative;
}
.aid-chat-form .aid-hp {
  position: absolute !important;
  left: -10000px !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
}
.aid-chat-input {
  flex: 1 1 auto;
  background: var(--wp--preset--color--surface, #121214);
  border: 1px solid var(--wp--preset--color--border, #26262B);
  color: var(--wp--preset--color--text-strong, #FFF);
  border-radius: 10px;
  padding: 0.6rem 0.8rem;
  font-family: inherit;
  font-size: 16px; /* prevent iOS zoom on focus */
  line-height: 1.4;
  resize: none;
  max-height: 140px;
  transition: border-color 180ms, box-shadow 180ms;
}
@media (min-width: 600px) {
  .aid-chat-input { font-size: 0.92rem; }
}
.aid-chat-input:focus {
  outline: none;
  border-color: var(--wp--preset--color--accent, #22D3EE);
  box-shadow: 0 0 0 3px rgba(34, 211, 238, 0.15);
}
.aid-chat-input::placeholder { color: var(--wp--preset--color--muted, #8A8A93); }

.aid-chat-send {
  flex-shrink: 0;
  background: var(--wp--preset--color--accent, #22D3EE);
  color: var(--wp--preset--color--bg, #0A0A0B);
  border: 0;
  border-radius: 10px;
  width: 40px; height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 180ms, transform 180ms;
  align-self: flex-end;
}
.aid-chat-send:hover { background: var(--wp--preset--color--text-strong, #FFF); transform: translateY(-1px); }
.aid-chat-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.aid-chat-disclaimer {
  margin: 0;
  padding: 0.55rem 0.85rem 0.85rem;
  font-size: 0.72rem;
  color: var(--wp--preset--color--muted, #8A8A93);
  line-height: 1.4;
  border-top: 1px solid var(--wp--preset--color--border, #26262B);
  background: var(--wp--preset--color--bg, #0A0A0B);
}
