/* ==========================================================================
   FairTech AI Chat Widget — sitewide floating assistant (footer.php JS +
   header.php markup). Dark glass + blue glow, same family as the hero and
   product cards. Bottom-right corner, so it never collides with the
   vertically-centered .ds-side-repair-btn on the right edge.
   ========================================================================== */

.ds-ai-chat {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 900;
  font-family: "Poppins", sans-serif;
}

.ds-ai-chat__toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, var(--ds-accent, #3d8bff) 0%, var(--ds-accent-strong, #0066ff) 100%);
  color: #ffffff;
  box-shadow: var(--ds-shadow-lg, 0 24px 60px rgba(2, 6, 16, 0.35)), 0 0 24px rgba(61, 139, 255, 0.45);
  cursor: pointer;
  transition: transform 260ms var(--ds-ease-out, cubic-bezier(0.16, 1, 0.3, 1)),
              box-shadow 260ms var(--ds-ease-out, cubic-bezier(0.16, 1, 0.3, 1));
}

.ds-ai-chat__toggle .material-symbols-outlined {
  font-size: 26px;
}

@media (hover: hover) and (pointer: fine) {
  .ds-ai-chat__toggle:hover {
    transform: translateY(-3px) scale(1.04);
    box-shadow: var(--ds-shadow-lg, 0 24px 60px rgba(2, 6, 16, 0.35)), 0 0 32px rgba(61, 139, 255, 0.65);
  }
}

.ds-ai-chat__toggle:active {
  transform: scale(0.94);
}

.ds-ai-chat__toggle:focus-visible {
  outline: 2px solid #ffffff;
  outline-offset: 3px;
}

.ds-ai-chat__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #0ea968;
  border: 2px solid var(--ds-bg-base, #060b16);
}

.ds-ai-chat__panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 500px;
  max-height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  background: var(--ds-surface-glass-strong, rgba(18, 27, 48, 0.92));
  backdrop-filter: blur(18px) saturate(150%);
  -webkit-backdrop-filter: blur(18px) saturate(150%);
  border: 1px solid var(--ds-border-subtle, rgba(255, 255, 255, 0.1));
  border-radius: var(--radius-lg, 20px);
  box-shadow: var(--ds-shadow-lg, 0 24px 60px rgba(2, 6, 16, 0.55)), 0 0 40px rgba(61, 139, 255, 0.12);
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity 220ms var(--ds-ease-out, cubic-bezier(0.16, 1, 0.3, 1)),
              transform 220ms var(--ds-ease-out, cubic-bezier(0.16, 1, 0.3, 1));
}

.ds-ai-chat.is-open .ds-ai-chat__panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* The panel sits 20px in from the edge, so the vertically-centered repair
   button (flush at right:0) would otherwise peek out from behind it. */
body.ds-ai-chat-is-open .ds-side-repair-btn {
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease;
}

.ds-ai-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--ds-border-subtle, rgba(255, 255, 255, 0.08));
  background: rgba(61, 139, 255, 0.08);
}

.ds-ai-chat__header-title {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ds-ai-chat__header-title strong {
  color: var(--ds-text-primary, #f3f6fc);
  font-size: 14px;
}

.ds-ai-chat__header-title span {
  color: var(--ds-text-muted, #7c869c);
  font-size: 11.5px;
}

.ds-ai-chat__close {
  background: none;
  border: none;
  color: var(--ds-text-secondary, #aab4c8);
  cursor: pointer;
  display: flex;
  padding: 4px;
  border-radius: 8px;
  transition: color 180ms ease, background 180ms ease;
}

.ds-ai-chat__close:hover {
  color: var(--ds-text-primary, #f3f6fc);
  background: rgba(255, 255, 255, 0.06);
}

.ds-ai-chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ds-ai-chat__msg {
  max-width: 85%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.ds-ai-chat__msg--assistant {
  align-self: flex-start;
  background: var(--ds-surface-2, #121b30);
  color: var(--ds-text-secondary, #aab4c8);
  border: 1px solid var(--ds-border-subtle, rgba(255, 255, 255, 0.08));
  border-bottom-left-radius: 4px;
}

.ds-ai-chat__msg--user {
  align-self: flex-end;
  background: linear-gradient(180deg, var(--ds-accent, #3d8bff) 0%, var(--ds-accent-strong, #0066ff) 100%);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.ds-ai-chat__msg--typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  padding: 12px;
}

.ds-ai-chat__msg--typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ds-text-muted, #7c869c);
  animation: ds-ai-typing 1.1s ease-in-out infinite;
}

.ds-ai-chat__msg--typing span:nth-child(2) { animation-delay: 0.15s; }
.ds-ai-chat__msg--typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes ds-ai-typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

.ds-ai-chat__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--ds-border-subtle, rgba(255, 255, 255, 0.08));
}

.ds-ai-chat__input {
  flex: 1;
  resize: none;
  max-height: 90px;
  background: var(--ds-surface-1, #0d1526);
  border: 1px solid var(--ds-border-subtle, rgba(255, 255, 255, 0.16));
  border-radius: 12px;
  color: var(--ds-text-primary, #f3f6fc);
  font-family: inherit;
  font-size: 13px;
  padding: 9px 12px;
  line-height: 1.4;
}

.ds-ai-chat__input::placeholder {
  color: var(--ds-text-muted, #7c869c);
}

.ds-ai-chat__input:focus {
  outline: none;
  border-color: var(--ds-accent, #3d8bff);
  box-shadow: 0 0 0 3px rgba(61, 139, 255, 0.15);
}

.ds-ai-chat__send {
  width: 38px;
  height: 38px;
  flex: none;
  border-radius: 10px;
  border: none;
  background: linear-gradient(180deg, var(--ds-accent, #3d8bff) 0%, var(--ds-accent-strong, #0066ff) 100%);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 180ms ease, opacity 180ms ease;
}

.ds-ai-chat__send:hover {
  transform: scale(1.06);
}

.ds-ai-chat__send:active {
  transform: scale(0.94);
}

.ds-ai-chat__send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.ds-ai-chat__send .material-symbols-outlined {
  font-size: 18px;
}

@media only screen and (max-width: 480px) {
  .ds-ai-chat {
    right: 12px;
    bottom: 12px;
  }
  .ds-ai-chat__panel {
    width: calc(100vw - 24px);
    height: min(70vh, 560px);
    bottom: 68px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .ds-ai-chat__toggle,
  .ds-ai-chat__panel {
    transition-duration: 1ms;
  }
  .ds-ai-chat__msg--typing span {
    animation-duration: 1ms;
  }
}
