/* =========================================================
   Central de Atendimento - Corporação Ferraz
   ========================================================= */
.cf-at {
  --at-bg: #050f24;
  --at-surface: rgba(10, 28, 62, 0.9);
  --at-line: rgba(99, 210, 255, 0.22);
  --at-text: #f6fbff;
  --at-muted: #9fb7cc;
  --at-cyan: #23d7ff;
  --at-blue: #1467ff;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--at-text);
  line-height: 1.5;
}
.cf-at *, .cf-at *::before, .cf-at *::after { box-sizing: border-box; }

/* Botão flutuante */
.cf-at-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 90;
  width: 62px;
  height: 62px;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  display: grid;
  place-items: center;
  color: #021025;
  background: linear-gradient(135deg, var(--at-cyan), var(--at-blue));
  box-shadow: 0 14px 34px rgba(20, 103, 255, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.18) inset;
  transition: transform 200ms ease, box-shadow 200ms ease;
}
.cf-at-launcher:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 18px 40px rgba(35, 215, 255, 0.5); }
.cf-at-launcher:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.cf-at-launcher svg { width: 28px; height: 28px; transition: transform 250ms ease, opacity 200ms ease; }
.cf-at-launcher .cf-at-ico-close { position: absolute; opacity: 0; transform: rotate(-90deg) scale(0.6); }
.cf-at.is-open .cf-at-launcher .cf-at-ico-chat { opacity: 0; transform: rotate(90deg) scale(0.6); }
.cf-at.is-open .cf-at-launcher .cf-at-ico-close { opacity: 1; transform: none; }
.cf-at-launcher::after {
  content: "";
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(35, 215, 255, 0.55);
  animation: cf-at-pulse 2.6s ease-out infinite;
  pointer-events: none;
}
.cf-at.is-open .cf-at-launcher::after { display: none; }
@keyframes cf-at-pulse {
  0% { transform: scale(0.9); opacity: 0.9; }
  100% { transform: scale(1.35); opacity: 0; }
}

/* Balão "Precisa de ajuda?" */
.cf-at-teaser {
  position: fixed;
  right: 96px;
  bottom: 34px;
  z-index: 90;
  max-width: 230px;
  padding: 10px 34px 10px 14px;
  border: 1px solid var(--at-line);
  border-radius: 14px 14px 4px 14px;
  background: var(--at-surface);
  backdrop-filter: blur(14px);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.35);
  font-size: 14px;
  cursor: pointer;
  animation: cf-at-in 300ms ease both;
}
.cf-at-teaser b { color: var(--at-cyan); }
.cf-at-teaser button {
  position: absolute;
  top: 4px;
  right: 6px;
  border: 0;
  background: none;
  color: var(--at-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

/* Painel */
.cf-at-panel {
  position: fixed;
  right: 22px;
  bottom: 96px;
  z-index: 90;
  width: 380px;
  height: min(620px, calc(100vh - 130px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--at-line);
  border-radius: 18px;
  background:
    radial-gradient(circle at 0% 0%, rgba(35, 215, 255, 0.14), transparent 16rem),
    radial-gradient(circle at 100% 0%, rgba(20, 103, 255, 0.18), transparent 16rem),
    var(--at-bg);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(255, 255, 255, 0.04) inset;
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 220ms ease, transform 220ms ease, visibility 0s linear 220ms;
}
.cf-at.is-open .cf-at-panel {
  opacity: 1;
  visibility: visible;
  transform: none;
  transition: opacity 220ms ease, transform 220ms ease;
}

.cf-at-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(2, 8, 23, 0.55);
}
.cf-at-avatar {
  position: relative;
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: rgba(35, 215, 255, 0.1);
  border: 1px solid var(--at-line);
}
.cf-at-avatar img { width: 28px; height: 28px; object-fit: contain; filter: drop-shadow(0 0 8px rgba(35, 215, 255, 0.5)); }
.cf-at-avatar::after {
  content: "";
  position: absolute;
  right: -3px;
  bottom: -3px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #2ee59d;
  border: 2px solid var(--at-bg);
}
.cf-at-title { flex: 1; min-width: 0; }
.cf-at-title strong { display: block; font-size: 15px; letter-spacing: 0.01em; }
.cf-at-title span { display: block; font-size: 12px; color: var(--at-muted); }
.cf-at-iconbtn {
  flex: none;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 10px;
  background: none;
  color: var(--at-muted);
  cursor: pointer;
}
.cf-at-iconbtn:hover { color: var(--at-text); border-color: var(--at-line); background: rgba(35, 215, 255, 0.06); }
.cf-at-iconbtn:focus-visible { outline: 2px solid var(--at-cyan); }
.cf-at-iconbtn svg { width: 18px; height: 18px; }

/* Mensagens */
.cf-at-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(35, 215, 255, 0.3) transparent;
}
.cf-at-msg {
  max-width: 86%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14px;
  overflow-wrap: anywhere;
  animation: cf-at-in 240ms ease both;
}
.cf-at-msg p { margin: 0 0 6px; }
.cf-at-msg p:last-child { margin-bottom: 0; }
.cf-at-msg ul { margin: 4px 0 6px; padding-left: 18px; }
.cf-at-msg li { margin: 2px 0; }
.cf-at-msg a { color: var(--at-cyan); text-decoration: underline; text-underline-offset: 2px; }
.cf-at-msg strong { color: #fff; }
.cf-at-bot {
  align-self: flex-start;
  background: var(--at-surface);
  border: 1px solid rgba(99, 210, 255, 0.14);
  border-bottom-left-radius: 4px;
}
.cf-at-user {
  align-self: flex-end;
  color: #021025;
  font-weight: 500;
  background: linear-gradient(135deg, var(--at-cyan), #5aa0ff);
  border-bottom-right-radius: 4px;
}
.cf-at-user a { color: #021025; }
.cf-at-note {
  align-self: center;
  font-size: 12px;
  color: var(--at-muted);
  text-align: center;
  padding: 2px 8px;
}
@keyframes cf-at-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.cf-at-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.cf-at-typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--at-cyan);
  opacity: 0.4;
  animation: cf-at-dot 1.2s infinite ease-in-out;
}
.cf-at-typing i:nth-child(2) { animation-delay: 0.15s; }
.cf-at-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes cf-at-dot {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-4px); }
}

/* Botões de atalho */
.cf-at-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 2px;
  animation: cf-at-in 240ms ease both;
}
.cf-at-chip {
  border: 1px solid var(--at-line);
  border-radius: 999px;
  padding: 7px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--at-text);
  background: rgba(35, 215, 255, 0.06);
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}
.cf-at-chip:hover { background: rgba(35, 215, 255, 0.16); border-color: rgba(35, 215, 255, 0.5); }
.cf-at-chip:focus-visible { outline: 2px solid var(--at-cyan); }
.cf-at-chip-strong {
  border-color: rgba(35, 215, 255, 0.55);
  background: rgba(35, 215, 255, 0.14);
}

/* Formulários dentro do chat */
.cf-at-form {
  align-self: stretch;
  padding: 14px;
  border: 1px solid var(--at-line);
  border-radius: 14px;
  background: rgba(8, 25, 55, 0.75);
  display: grid;
  gap: 8px;
  animation: cf-at-in 240ms ease both;
}
.cf-at-form h4 { margin: 0 0 2px; font-size: 14px; }
.cf-at-form p.cf-at-sub { margin: 0 0 4px; font-size: 12px; color: var(--at-muted); }
.cf-at-form label { font-size: 12px; color: var(--at-muted); display: grid; gap: 4px; }
.cf-at-form input[type="text"],
.cf-at-form input[type="email"],
.cf-at-form textarea {
  width: 100%;
  font: inherit;
  font-size: 14px;
  color: var(--at-text);
  padding: 9px 11px;
  border: 1px solid rgba(99, 210, 255, 0.2);
  border-radius: 10px;
  background: rgba(2, 8, 23, 0.6);
  resize: vertical;
}
.cf-at-form input:focus, .cf-at-form textarea:focus { outline: none; border-color: var(--at-cyan); box-shadow: 0 0 0 3px rgba(35, 215, 255, 0.15); }
.cf-at-form .cf-at-check { display: flex; align-items: flex-start; gap: 8px; font-size: 12px; }
.cf-at-form .cf-at-check input { margin-top: 2px; accent-color: var(--at-cyan); }
.cf-at-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
.cf-at-stars { display: flex; gap: 4px; }
.cf-at-stars button {
  border: 0;
  background: none;
  padding: 2px;
  font-size: 24px;
  line-height: 1;
  color: rgba(173, 196, 216, 0.35);
  cursor: pointer;
  transition: transform 120ms ease, color 120ms ease;
}
.cf-at-stars button.on { color: #ffcc4d; }
.cf-at-stars button:hover { transform: scale(1.15); }
.cf-at-stars button:focus-visible { outline: 2px solid var(--at-cyan); border-radius: 4px; }
.cf-at-form-actions { display: flex; gap: 8px; margin-top: 4px; }
.cf-at-btn {
  flex: 1;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  color: #021025;
  background: linear-gradient(135deg, var(--at-cyan), var(--at-blue));
}
.cf-at-btn[disabled] { opacity: 0.6; cursor: wait; }
.cf-at-btn-ghost { flex: 0 0 auto; color: var(--at-muted); background: none; border: 1px solid var(--at-line); font-weight: 500; }
.cf-at-form-status { font-size: 12px; color: #ff8b8b; min-height: 0; margin: 0; }
.cf-at-form-status:empty { display: none; }

/* Campo de digitação */
.cf-at-compose {
  padding: 10px 12px 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  background: rgba(2, 8, 23, 0.5);
}
.cf-at-compose form { display: flex; align-items: flex-end; gap: 8px; }
.cf-at-compose textarea {
  flex: 1;
  min-height: 42px;
  max-height: 120px;
  resize: none;
  font: inherit;
  font-size: 14px;
  color: var(--at-text);
  padding: 10px 12px;
  border: 1px solid rgba(99, 210, 255, 0.2);
  border-radius: 12px;
  background: rgba(8, 25, 55, 0.7);
}
.cf-at-compose textarea:focus { outline: none; border-color: var(--at-cyan); box-shadow: 0 0 0 3px rgba(35, 215, 255, 0.15); }
.cf-at-compose textarea::placeholder { color: rgba(173, 196, 216, 0.6); }
.cf-at-send {
  flex: none;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 12px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #021025;
  background: linear-gradient(135deg, var(--at-cyan), var(--at-blue));
}
.cf-at-send[disabled] { opacity: 0.45; cursor: default; }
.cf-at-send svg { width: 18px; height: 18px; }
.cf-at-disclaimer { margin: 6px 2px 0; font-size: 11px; color: rgba(173, 196, 216, 0.7); text-align: center; }

/* Celular: painel ocupa a tela */
@media (max-width: 520px) {
  .cf-at-launcher { right: 16px; bottom: 16px; width: 56px; height: 56px; }
  .cf-at-teaser { right: 82px; bottom: 24px; }
  .cf-at-panel {
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    border-radius: 0;
    border: 0;
  }
  .cf-at.is-open .cf-at-launcher { display: none; }
  .cf-at-compose textarea { font-size: 16px; } /* evita zoom no iPhone */
}

@media (prefers-reduced-motion: reduce) {
  .cf-at *, .cf-at *::before, .cf-at *::after { animation: none !important; transition: none !important; }
}
