/* Fydo chat widget — bottom-right launcher + panel */
.fy-chat-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 50%;
  background: var(--red, #ff2b2b);
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.8) translateY(12px);
  pointer-events: none;
  transition: opacity 0.35s ease, transform 0.35s ease, background 0.15s ease;
}

.fy-chat-launcher.is-visible {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: auto;
}

.fy-chat-launcher:hover {
  background: #e02424;
}

.fy-chat-launcher.is-pulsing {
  animation: fy-chat-launcher-pulse 0.8s ease-in-out;
}

@keyframes fy-chat-launcher-pulse {
  0%, 100% {
    transform: scale(1) translateY(0);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  }
  50% {
    transform: scale(1.1) translateY(0);
    box-shadow: 0 8px 32px rgba(255, 43, 43, 0.5);
  }
}

.fy-chat-launcher svg {
  width: 26px;
  height: 26px;
}

.fy-chat-panel {
  position: fixed;
  right: 20px;
  bottom: 88px;
  z-index: 9998;
  width: min(360px, calc(100vw - 40px));
  height: 50vh;
  max-height: 50vh;
  background: var(--bg, #111);
  border: 1px solid var(--line, rgba(255, 255, 255, 0.12));
  border-radius: 16px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

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

.fy-chat-header {
  flex-shrink: 0;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line, rgba(255, 255, 255, 0.1));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--bg-2, #1a1a1a);
}

.fy-chat-header strong {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
}

.fy-chat-close {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 50%;
  background: var(--red, #ff2b2b);
  color: #fff;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(255, 43, 43, 0.35);
  transition: background 0.15s ease, transform 0.15s ease;
}

.fy-chat-close svg {
  width: 16px;
  height: 16px;
}

.fy-chat-close:hover {
  background: #e02424;
  transform: scale(1.05);
}

.fy-chat-body {
  flex: 1 1 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.fy-chat-messages {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.fy-chat-bubble {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
}

.fy-chat-bubble--bot {
  align-self: flex-start;
  background: var(--bg-3, #252525);
  color: var(--fg, #fff);
  border-bottom-left-radius: 4px;
}

.fy-chat-bubble--user {
  align-self: flex-end;
  background: var(--red, #ff2b2b);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.fy-chat-actions {
  flex-shrink: 0;
  max-height: 42%;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line, rgba(255, 255, 255, 0.1));
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fy-chat-choice {
  border: 1px solid var(--line, rgba(255, 255, 255, 0.15));
  background: transparent;
  color: var(--fg, #fff);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.fy-chat-choice:hover {
  background: var(--bg-2, #1a1a1a);
  border-color: var(--red, #ff2b2b);
}

.fy-chat-choice--muted {
  font-size: 12px;
  opacity: 0.85;
}

.fy-chat-callback-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fy-chat-callback-form input {
  width: 100%;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.15));
  background: var(--bg-2, #1a1a1a);
  color: var(--fg, #fff);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
}

.fy-chat-terminal-btn--inline {
  display: block;
  width: 100%;
  text-align: center;
  margin-top: 4px;
}

.fy-chat-input-row {
  display: flex;
  gap: 8px;
}

.fy-chat-input-row input {
  flex: 1;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.15));
  background: var(--bg-2, #1a1a1a);
  color: var(--fg, #fff);
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 14px;
}

.fy-chat-input-row button {
  border: none;
  background: var(--red, #ff2b2b);
  color: #fff;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
}

.fy-chat-terminal-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px 16px;
  border-radius: 999px;
  background: var(--red, #ff2b2b);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  border: none;
  cursor: pointer;
}

.fy-chat-terminal-btn:hover {
  background: #e02424;
  color: #fff;
}

.fy-chat-kb-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.fy-chat-kb-link {
  font-size: 13px;
  padding: 10px 14px;
  white-space: normal;
  text-align: center;
  line-height: 1.35;
}

.fy-chat-status {
  font-size: 12px;
  color: var(--fg-4, #777);
  text-align: center;
  padding: 8px;
}

.fy-chat-panel.is-loading .fy-chat-actions {
  opacity: 0.5;
  pointer-events: none;
}

.fy-chat-typing-slot {
  flex-shrink: 0;
  padding: 0 16px 10px;
  min-height: 28px;
}

.fy-chat-typing-slot:empty {
  display: none;
}

.fy-chat-typing {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  background: transparent;
  padding: 2px 0 0 4px;
}

.fy-chat-wifi-bars {
  display: block;
  width: 20px;
  height: 20px;
  color: var(--fg-3, #999);
}

.fy-chat-typing--red .fy-chat-wifi-bars {
  color: var(--red, #ff2b2b);
}

.fy-chat-wifi-bars svg {
  display: block;
  width: 100%;
  height: 100%;
}

.fy-chat-wifi-dot {
  opacity: 1;
}

.fy-chat-wifi-arc {
  opacity: 0;
  animation-duration: 1s;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

.fy-chat-wifi-arc--1 {
  animation-name: fy-chat-wifi-arc-1;
}

.fy-chat-wifi-arc--2 {
  animation-name: fy-chat-wifi-arc-2;
}

.fy-chat-wifi-arc--3 {
  animation-name: fy-chat-wifi-arc-3;
}

@keyframes fy-chat-wifi-arc-1 {
  0%, 24.9% { opacity: 0; }
  25%, 99.9% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes fy-chat-wifi-arc-2 {
  0%, 49.9% { opacity: 0; }
  50%, 99.9% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes fy-chat-wifi-arc-3 {
  0%, 74.9% { opacity: 0; }
  75%, 99.9% { opacity: 1; }
  100% { opacity: 0; }
}

@media (max-width: 640px) {
  .fy-chat-panel {
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
  }

  .fy-chat-launcher.is-panel-open {
    opacity: 0;
    pointer-events: none;
  }
}

[data-theme="light"] .fy-chat-panel {
  background: #fff;
  border-color: rgba(0, 0, 0, 0.1);
}

[data-theme="light"] .fy-chat-header {
  background: #f8f8f8;
}

[data-theme="light"] .fy-chat-bubble--bot {
  background: #f0f0f0;
  color: #111;
}

[data-theme="light"] .fy-chat-choice {
  color: #111;
  border-color: rgba(0, 0, 0, 0.12);
}

[data-theme="light"] .fy-chat-input-row input,
[data-theme="light"] .fy-chat-callback-form input {
  background: #f8f8f8;
  color: #111;
}
