/* GuissoBot — widget de chat integrado ao tema (ciano com moderação). */
.chat {
  --chat-bg: #0b0a18;
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 1100;
  font-family: var(--font-body, system-ui, sans-serif);
}

.chat-fab {
  display: grid;
  place-items: center;
  width: 3.5rem;
  height: 3.5rem;
  padding: 0;
  border: 1px solid rgba(94, 231, 231, 0.5);
  border-radius: 50%;
  background: var(--accent, #5ee7e7);
  color: var(--accent-ink, #04201f);
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
  transition: transform 0.2s ease, background-color 0.2s;
}
.chat-fab svg {
  width: 1.5rem;
  height: 1.5rem;
}
@media (hover: hover) {
  .chat-fab:hover {
    background: var(--accent-bright, #7df9ff);
    transform: translateY(-2px);
  }
}
.chat-fab:focus-visible,
.chat-close:focus-visible,
.chat-chip:focus-visible,
.chat-send:focus-visible,
.chat-input:focus-visible {
  outline: 2px solid var(--accent-bright, #7df9ff);
  outline-offset: 2px;
}

.chat-panel {
  position: absolute;
  right: 0;
  bottom: 4.5rem;
  display: flex;
  flex-direction: column;
  width: min(22.5rem, calc(100vw - 2rem));
  height: min(32.5rem, calc(100vh - 8rem));
  height: min(32.5rem, calc(100dvh - 8rem));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: var(--chat-bg);
  color: var(--text, #f1f1f6);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
  overflow: hidden;
}
.chat-panel:not([hidden]) {
  animation: chat-in 0.18s ease-out;
}
@keyframes chat-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
}

.chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.03);
}
.chat-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
}
.chat-sub {
  margin: 0.1rem 0 0;
  color: var(--muted, #b4b4c7);
  font-size: 0.74rem;
  line-height: 1.35;
}
.chat-close {
  flex: none;
  width: 2.25rem;
  height: 2.25rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted, #b4b4c7);
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
@media (hover: hover) {
  .chat-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
  }
}

.chat-log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  padding: 1rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(94, 231, 231, 0.45) transparent;
}
.chat-msg {
  max-width: 88%;
  padding: 0.6rem 0.8rem;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
  white-space: pre-line;
}
.chat-msg.bot {
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  background: rgba(255, 255, 255, 0.07);
}
.chat-msg.user {
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  background: rgba(94, 231, 231, 0.16);
  border: 1px solid rgba(94, 231, 231, 0.3);
}
.chat-msg.error {
  align-self: flex-start;
  border: 1px solid rgba(255, 140, 140, 0.45);
  background: rgba(255, 90, 90, 0.1);
}
.chat-msg a {
  color: var(--accent-bright, #7df9ff);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.chat-links {
  display: grid;
  gap: 0.2rem;
  margin-top: 0.5rem;
}

.chat-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.7rem 0.85rem;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
}
.chat-typing i {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 50%;
  background: var(--muted, #b4b4c7);
  animation: chat-dot 1s infinite ease-in-out;
}
.chat-typing i:nth-child(2) {
  animation-delay: 0.15s;
}
.chat-typing i:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes chat-dot {
  0%,
  80%,
  100% {
    opacity: 0.3;
  }
  40% {
    opacity: 1;
  }
}

.chat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0 1rem 0.75rem;
}
.chat-suggestions:empty {
  display: none;
}
.chat-chip {
  min-height: 2.25rem;
  padding: 0.3rem 0.85rem;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: transparent;
  color: var(--text, #f1f1f6);
  font: 500 0.8rem/1.2 inherit;
  font-family: inherit;
  cursor: pointer;
  transition: border-color 0.2s, background-color 0.2s;
}
@media (hover: hover) {
  .chat-chip:hover {
    border-color: rgba(94, 231, 231, 0.5);
    background: rgba(94, 231, 231, 0.08);
  }
}

.chat-form {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem 1rem 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.chat-input {
  flex: 1;
  min-width: 0;
  min-height: 2.75rem;
  padding: 0 0.9rem;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  color: #fff;
  font: inherit;
  font-size: 1rem; /* evita zoom automático no iOS */
}
.chat-input::placeholder {
  color: #8d8da3;
}
.chat-send {
  min-height: 2.75rem;
  padding: 0 1.1rem;
  border: 0;
  border-radius: 999px;
  background: var(--accent, #5ee7e7);
  color: var(--accent-ink, #04201f);
  font: 600 0.9rem/1 inherit;
  font-family: inherit;
  cursor: pointer;
}
.chat-send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

@media (max-width: 520px) {
  .chat-panel {
    position: fixed;
    inset: auto max(0.75rem, env(safe-area-inset-right)) calc(5rem + env(safe-area-inset-bottom)) max(0.75rem, env(safe-area-inset-left));
    width: auto;
    height: min(34rem, calc(100vh - 7rem));
    height: min(34rem, calc(100dvh - 7rem));
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-panel:not([hidden]),
  .chat-typing i {
    animation: none;
  }
}
