/* Assistente IA flutuante — Saúde Abrigo Infantil */

.abrigo-ai-fab-wrap {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(88px, calc(72px + env(safe-area-inset-bottom)));
  z-index: 9500;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
}

.abrigo-ai-fab-wrap > * {
  pointer-events: auto;
}

.abrigo-ai-fab {
  position: relative;
  width: 64px;
  height: 64px;
  padding: 0;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: transparent;
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.45);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.abrigo-ai-fab:hover {
  transform: scale(1.06);
  box-shadow: 0 14px 36px rgba(167, 139, 250, 0.45);
}

.abrigo-ai-fab:focus-visible {
  outline: 3px solid rgba(99, 102, 241, 0.6);
  outline-offset: 3px;
}

.abrigo-ai-fab__ring {
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid rgba(167, 139, 250, 0.55);
  animation: abrigo-ai-ring 3.2s ease-out infinite;
  pointer-events: none;
}

.abrigo-ai-fab__avatar {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #fff;
}

/* —— Sol: avatar e balões de pensamento —— */

.abrigo-ai-lua-face {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}

.abrigo-ai-lua-face--full {
  object-position: center 8%;
  transform: scale(1.15);
  transform-origin: center top;
}

.abrigo-ai-lua-face--portrait {
  object-position: center 35%;
}

.abrigo-ai-lua-face--fab-hires {
  object-position: center 30%;
  transform: scale(1.04);
  image-rendering: auto;
}

.abrigo-ai-lua-face.is-smiling {
  animation: lua-smile-bob 2.8s ease-in-out infinite;
}

.abrigo-ai-lua-face--fab-hires.is-smiling {
  animation: lua-smile-bob-fab 2.8s ease-in-out infinite;
}

.abrigo-ai-lua-face.is-thinking {
  animation: lua-think-wiggle 0.9s ease-in-out infinite;
}

@keyframes lua-smile-bob {
  0%,
  100% {
    transform: scale(1.12) translateY(0);
  }
  50% {
    transform: scale(1.16) translateY(-2px);
  }
}

.abrigo-ai-lua-face--portrait.is-smiling {
  animation: lua-smile-bob-portrait 2.8s ease-in-out infinite;
}

@keyframes lua-smile-bob-portrait {
  0%,
  100% {
    transform: scale(1) translateY(0);
  }
  50% {
    transform: scale(1.04) translateY(-2px);
  }
}

@keyframes lua-smile-bob-fab {
  0%,
  100% {
    transform: scale(1.04) translateY(0);
  }
  50% {
    transform: scale(1.08) translateY(-2px);
  }
}

@keyframes lua-think-wiggle {
  0%,
  100% {
    transform: rotate(-2deg) scale(1.1);
  }
  50% {
    transform: rotate(2deg) scale(1.12);
  }
}

.abrigo-ai-lua-frame {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(180deg, #fdf4ff 0%, #e0e7ff 100%);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.85);
}

.abrigo-ai-lua-frame--fab {
  width: 60px;
  height: 60px;
  box-shadow:
    0 0 0 3px rgba(167, 139, 250, 0.35),
    0 8px 24px rgba(15, 23, 42, 0.35);
}

.abrigo-ai-fab__avatar {
  position: relative;
  z-index: 1;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(180deg, #fdf4ff, #e0e7ff);
}

.abrigo-ai-fab__avatar svg {
  width: 28px;
  height: 28px;
}

.abrigo-ai-panel__avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: linear-gradient(180deg, #fdf4ff, #e0e7ff);
  box-shadow: 0 4px 14px rgba(99, 102, 241, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.5);
}

.abrigo-ai-panel__avatar svg {
  width: 24px;
  height: 24px;
}

.abrigo-ai-msg__row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  max-width: 100%;
}

.abrigo-ai-msg__avatar--lua {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  background: linear-gradient(180deg, #fdf4ff, #e0e7ff);
  border: 2px solid rgba(255, 255, 255, 0.35);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.abrigo-ai-msg--assistant {
  max-width: 100%;
}

.abrigo-ai-lua-opener {
  margin: 0 0 8px;
  font-size: 13px;
  font-weight: 700;
  color: #c4b5fd;
}

.abrigo-ai-lua-opener--happy {
  color: #86efac;
}

.abrigo-ai-reply--empty .abrigo-ai-summary {
  color: #d1fae5;
}

.abrigo-ai-msg--empty .abrigo-ai-msg__bubble {
  border-color: rgba(34, 197, 94, 0.35);
  background: linear-gradient(145deg, rgba(20, 83, 45, 0.35), rgba(30, 41, 59, 0.92));
}

.abrigo-ai-empty-badge {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(34, 197, 94, 0.15);
  border: 1px solid rgba(34, 197, 94, 0.3);
  font-size: 13px;
  font-weight: 600;
  color: #bbf7d0;
  text-align: center;
}

.abrigo-ai-summary {
  margin: 0 0 8px;
}

.abrigo-ai-list {
  margin: 8px 0 0;
  padding-left: 18px;
  font-size: 12px;
  color: #cbd5e1;
}

.abrigo-ai-period {
  font-size: 11px;
  color: #64748b;
  margin: 8px 0 0;
}

.abrigo-ai-lua-face.is-happy {
  animation: lua-happy-bounce 1.6s ease-in-out infinite;
}

@keyframes lua-happy-bounce {
  0%,
  100% {
    transform: scale(1.02);
  }
  50% {
    transform: scale(1.08) translateY(-3px);
  }
}

.abrigo-ai-thought {
  position: relative;
  opacity: 0;
  transform: translateY(6px) scale(0.96);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.abrigo-ai-thought.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.abrigo-ai-thought__bubble {
  position: relative;
  padding: 8px 12px;
  border-radius: 14px;
  background: #fff;
  color: #334155;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.35;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
  max-width: 220px;
}

.abrigo-ai-thought__bubble::after {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  background: #fff;
  transform: rotate(45deg);
}

.abrigo-ai-thought--fab {
  position: absolute;
  right: 0;
  bottom: calc(100% + 10px);
  z-index: 2;
}

.abrigo-ai-thought--fab .abrigo-ai-thought__bubble {
  max-width: 210px;
  background: linear-gradient(135deg, #fdf4ff, #ede9fe);
  border: 1px solid rgba(167, 139, 250, 0.4);
  color: #5b21b6;
  animation: thought-float 3s ease-in-out infinite;
}

.abrigo-ai-fab-wrap:hover .abrigo-ai-thought--fab .abrigo-ai-thought__bubble,
.abrigo-ai-fab-wrap:focus-within .abrigo-ai-thought--fab .abrigo-ai-thought__bubble {
  border-color: rgba(45, 212, 191, 0.72);
  box-shadow: 0 20px 46px rgba(45, 212, 191, 0.2), 0 12px 30px rgba(2, 6, 23, 0.2);
}

.abrigo-ai-thought--fab .abrigo-ai-thought__bubble::after {
  right: 22px;
  bottom: -5px;
}

.abrigo-ai-thought--inline .abrigo-ai-thought__bubble {
  background: #f8fafc;
  border: 1px solid rgba(148, 163, 184, 0.25);
  animation: thought-pulse 1.4s ease-in-out infinite;
}

.abrigo-ai-thought--inline .abrigo-ai-thought__bubble::after {
  left: 14px;
  bottom: -5px;
  background: #f8fafc;
  border-right: 1px solid rgba(148, 163, 184, 0.2);
  border-bottom: 1px solid rgba(148, 163, 184, 0.2);
}

.abrigo-ai-typing-bubble {
  padding: 8px 10px;
  min-width: 120px;
}

.abrigo-ai-panel__thought-bar {
  padding: 0 14px 8px;
  flex-shrink: 0;
}

.abrigo-ai-thought--bar .abrigo-ai-thought__bubble {
  width: 100%;
  max-width: none;
  text-align: center;
  background: linear-gradient(135deg, #fdf4ff, #ede9fe);
  border: 1px solid rgba(167, 139, 250, 0.35);
  color: #5b21b6;
}

.abrigo-ai-thought--bar .abrigo-ai-thought__bubble::after {
  display: none;
}

@keyframes thought-float {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-4px);
  }
}

@keyframes thought-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(167, 139, 250, 0.2);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(167, 139, 250, 0);
  }
}

.abrigo-ai-fab__label {
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  white-space: nowrap;
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.88);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 700;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  backdrop-filter: blur(8px);
}

.abrigo-ai-fab:hover .abrigo-ai-fab__label,
.abrigo-ai-fab:focus-visible .abrigo-ai-fab__label {
  opacity: 1;
  transform: translateY(-50%) translateX(-4px);
}

@keyframes abrigo-ai-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(99, 102, 241, 0.4), 0 12px 32px rgba(15, 23, 42, 0.35);
  }
  50% {
    box-shadow: 0 0 0 12px rgba(99, 102, 241, 0), 0 14px 36px rgba(14, 165, 233, 0.35);
  }
}

@keyframes abrigo-ai-ring {
  0% {
    transform: scale(0.95);
    opacity: 0.7;
  }
  70% {
    transform: scale(1.15);
    opacity: 0;
  }
  100% {
    opacity: 0;
  }
}

.abrigo-ai-panel {
  position: fixed;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  width: min(420px, calc(100vw - 24px));
  height: min(720px, calc(100vh - 24px));
  max-height: calc(100dvh - 24px);
  z-index: 9499;
  display: flex;
  flex-direction: column;
  border-radius: 20px;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.92);
  border: 1px solid rgba(148, 163, 184, 0.2);
  box-shadow: 0 32px 64px rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(20px);
  color: #e2e8f0;
  transform: translateY(16px) scale(0.96);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.22s ease, visibility 0.22s;
}

.abrigo-ai-panel.is-open {
  transform: translateY(0) scale(1);
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.abrigo-ai-panel__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.15);
  background: linear-gradient(180deg, rgba(99, 102, 241, 0.2), transparent);
}

.abrigo-ai-panel__meta {
  flex: 1;
  min-width: 0;
}

.abrigo-ai-panel__meta h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: #f8fafc;
}

.abrigo-ai-panel__status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  font-size: 12px;
  color: #86efac;
}

.abrigo-ai-panel__status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  animation: abrigo-ai-status 1.6s ease-in-out infinite;
}

.abrigo-ai-progress {
  display: grid;
  grid-template-columns: minmax(76px, 1fr) auto;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
  max-width: 210px;
}

.abrigo-ai-progress__bar {
  display: block;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.abrigo-ai-progress__bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2dd4bf, #38bdf8, #a78bfa);
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.45);
}

.abrigo-ai-progress small {
  color: #c4b5fd;
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.abrigo-ai-panel__dev-note {
  margin: 7px 0 0;
  max-width: 320px;
  color: rgba(253, 230, 138, 0.92);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.35;
}

@keyframes abrigo-ai-status {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.4;
  }
}

.abrigo-ai-panel__close {
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.14);
  color: #f8fafc;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}

.abrigo-ai-panel__close svg,
.abrigo-ai-panel__close i {
  width: 20px;
  height: 20px;
  stroke-width: 2.25;
}

.abrigo-ai-panel__close:hover {
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.45);
  color: #fff;
}

.abrigo-ai-panel__messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

.abrigo-ai-msg {
  max-width: 92%;
  animation: abrigo-ai-msg-in 0.3s ease-out;
}

@keyframes abrigo-ai-msg-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.abrigo-ai-msg--user {
  align-self: flex-end;
}

.abrigo-ai-msg--assistant {
  align-self: flex-start;
}

.abrigo-ai-msg__bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
}

.abrigo-ai-msg--user .abrigo-ai-msg__bubble {
  background: linear-gradient(135deg, #6366f1, #4f46e5);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.abrigo-ai-msg--assistant .abrigo-ai-msg__bubble {
  background: rgba(30, 41, 59, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.15);
  border-bottom-left-radius: 4px;
}

.abrigo-ai-msg__bubble h4 {
  margin: 0 0 6px;
  font-size: 14px;
  color: #f8fafc;
}

.abrigo-ai-msg__bubble p {
  margin: 0 0 8px;
}

.abrigo-ai-msg__metrics {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: 10px 0;
}

.abrigo-ai-metric {
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.12);
}

.abrigo-ai-metric span {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #94a3b8;
}

.abrigo-ai-metric strong {
  font-size: 15px;
  color: #f1f5f9;
}

.abrigo-ai-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 8px;
}

.abrigo-ai-card {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(99, 102, 241, 0.25);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  text-align: left;
  width: 100%;
  color: inherit;
  font: inherit;
}

.abrigo-ai-card:hover {
  border-color: rgba(14, 165, 233, 0.5);
  background: rgba(30, 41, 59, 0.8);
}

.abrigo-ai-card strong {
  display: block;
  font-size: 13px;
  color: #f8fafc;
}

.abrigo-ai-card span {
  display: block;
  font-size: 12px;
  color: #94a3b8;
  margin-top: 2px;
}

.abrigo-ai-insight {
  margin: 8px 0 0;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(34, 197, 94, 0.12);
  border: 1px solid rgba(34, 197, 94, 0.25);
  font-size: 12px;
  color: #bbf7d0;
}

.abrigo-ai-next {
  margin-top: 10px;
  padding: 9px 11px;
  border: 1px solid rgba(94, 234, 212, 0.24);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.28);
}

.abrigo-ai-next strong {
  display: block;
  margin-bottom: 5px;
  font-size: 12px;
  color: #a7f3d0;
}

.abrigo-ai-next ul {
  margin: 0;
  padding-left: 16px;
}

.abrigo-ai-next li {
  margin: 3px 0;
  font-size: 12px;
  line-height: 1.35;
}

.abrigo-ai-typing {
  display: flex;
  gap: 5px;
  padding: 12px 16px;
}

.abrigo-ai-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: abrigo-ai-dot 1.2s ease-in-out infinite;
}

.abrigo-ai-typing span:nth-child(2) {
  animation-delay: 0.15s;
}

.abrigo-ai-typing span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes abrigo-ai-dot {
  0%,
  80%,
  100% {
    transform: scale(0.7);
    opacity: 0.4;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

.abrigo-ai-panel__chips-wrap {
  flex-shrink: 0;
  padding: 0 0 8px;
  background: transparent;
  border: 0;
}

.abrigo-ai-panel__chips-label {
  margin: 0 0 6px;
  padding: 0 2px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: #94a3b8;
}

.abrigo-ai-panel__chips {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  padding: 0 0 2px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
}

.abrigo-ai-panel__chips::-webkit-scrollbar {
  height: 4px;
}

.abrigo-ai-chip {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(30, 41, 59, 0.8);
  color: #e2e8f0;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.abrigo-ai-chip--more {
  min-width: 44px;
  padding-inline: 12px;
  border-style: dashed;
  color: #7dd3fc;
}

.abrigo-ai-chip:hover {
  border-color: rgba(99, 102, 241, 0.6);
  background: rgba(99, 102, 241, 0.2);
}

.abrigo-ai-past {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.2);
}

.abrigo-ai-past__title {
  margin: 0 0 8px;
  font-size: 12px;
  font-weight: 700;
  color: #a5b4fc;
}

.abrigo-ai-past__list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.abrigo-ai-past-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(99, 102, 241, 0.35);
  background: rgba(99, 102, 241, 0.12);
  color: #e2e8f0;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.abrigo-ai-past-item:hover {
  border-color: rgba(14, 165, 233, 0.6);
  background: rgba(14, 165, 233, 0.15);
}

.abrigo-ai-past-item strong {
  font-size: 13px;
  color: #f8fafc;
}

.abrigo-ai-past-item span {
  font-size: 11px;
  color: #94a3b8;
}

.abrigo-ai-hints {
  margin-top: 10px;
}

.abrigo-ai-hints__label {
  margin: 0 0 6px;
  font-size: 11px;
  color: #64748b;
}

.abrigo-ai-hints__row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.abrigo-ai-chip--inline {
  font-size: 10px;
  padding: 5px 10px;
}

.abrigo-ai-panel__composer {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px 12px 14px;
  border-top: 1px solid rgba(148, 163, 184, 0.15);
  background: rgba(15, 23, 42, 0.95);
}

.abrigo-ai-composer {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.abrigo-ai-composer textarea {
  flex: 1;
  min-height: 44px;
  max-height: 120px;
  resize: none;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  background: rgba(30, 41, 59, 0.9);
  color: #f8fafc;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
}

.abrigo-ai-composer textarea::placeholder {
  color: #64748b;
}

.abrigo-ai-composer textarea:focus {
  outline: none;
  border-color: rgba(99, 102, 241, 0.6);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.abrigo-ai-send {
  width: 44px;
  height: 44px;
  border: none;
  border-radius: 14px;
  background: linear-gradient(135deg, #6366f1, #0ea5e9);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.abrigo-ai-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.abrigo-ai-send svg {
  width: 20px;
  height: 20px;
}

body.abrigo-ai-panel-open .abrigo-ai-fab-wrap {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.9);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

body.abrigo-ai-panel-open {
  overflow: hidden;
}

@media (max-width: 520px) {
  .abrigo-ai-panel {
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    max-height: 100dvh;
    border-radius: 0;
  }

  .abrigo-ai-fab-wrap {
    bottom: max(76px, calc(64px + env(safe-area-inset-bottom)));
  }
}

@media print {
  .abrigo-ai-fab-wrap,
  .abrigo-ai-panel {
    display: none !important;
  }
}

/* Visual 2026: Sol analítica, responsiva e sem rolagem horizontal */
.abrigo-ai-fab-wrap {
  right: max(18px, env(safe-area-inset-right));
  bottom: max(86px, calc(76px + env(safe-area-inset-bottom)));
}

.abrigo-ai-fab {
  width: 72px;
  height: 72px;
  filter: drop-shadow(0 18px 34px rgba(14, 165, 233, 0.22));
}

.abrigo-ai-fab::before {
  content: "IA";
  position: absolute;
  right: -2px;
  top: -6px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.5);
  background: linear-gradient(135deg, #2dd4bf, #2563eb);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.4);
}

.abrigo-ai-fab__ring {
  inset: -7px;
  border: 1px solid rgba(45, 212, 191, 0.5);
  box-shadow: 0 0 32px rgba(45, 212, 191, 0.26);
}

.abrigo-ai-fab__avatar,
.abrigo-ai-lua-frame--fab {
  width: 68px;
  height: 68px;
}

.abrigo-ai-lua-frame {
  background:
    radial-gradient(circle at 48% 22%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0.18) 34%, transparent 35%),
    linear-gradient(145deg, #ecfeff, #ddd6fe 48%, #a7f3d0);
}

.abrigo-ai-panel {
  right: max(18px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  width: min(486px, calc(100vw - 36px));
  height: min(760px, calc(100dvh - 36px));
  border-radius: 28px;
  border: 1px solid rgba(125, 211, 252, 0.22);
  overflow: hidden;
  background:
    radial-gradient(circle at 16% -8%, rgba(45, 212, 191, 0.24), transparent 34%),
    radial-gradient(circle at 92% 10%, rgba(99, 102, 241, 0.28), transparent 28%),
    linear-gradient(180deg, rgba(15, 23, 42, 0.98), rgba(2, 6, 23, 0.96));
  box-shadow:
    0 34px 90px rgba(0, 0, 0, 0.54),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.abrigo-ai-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(148, 163, 184, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(148, 163, 184, 0.045) 1px, transparent 1px);
  background-size: 26px 26px;
  mask-image: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent 62%);
}

.abrigo-ai-panel__head {
  position: relative;
  z-index: 1;
  align-items: center;
  gap: 14px;
  padding: 18px;
  min-height: 88px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.14);
  background:
    linear-gradient(135deg, rgba(30, 41, 59, 0.86), rgba(15, 23, 42, 0.45)),
    linear-gradient(90deg, rgba(45, 212, 191, 0.1), rgba(99, 102, 241, 0.14));
}

.abrigo-ai-panel__avatar {
  width: 62px;
  height: 62px;
  border: 1px solid rgba(255, 255, 255, 0.58);
  box-shadow:
    0 16px 34px rgba(45, 212, 191, 0.16),
    0 0 0 6px rgba(45, 212, 191, 0.08);
}

.abrigo-ai-panel__meta h2 {
  margin-top: 2px;
  font-size: 22px;
  line-height: 1.05;
  letter-spacing: 0;
}

.abrigo-ai-panel__eyebrow {
  display: block;
  color: #67e8f9;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.abrigo-ai-panel__status {
  color: #a7f3d0;
  font-weight: 750;
}

.abrigo-ai-panel__brain {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 16px;
  border: 1px solid rgba(125, 211, 252, 0.28);
  background: linear-gradient(135deg, rgba(45, 212, 191, 0.22), rgba(99, 102, 241, 0.2));
  color: #bfdbfe;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.abrigo-ai-panel__brain::before {
  content: "✦";
  color: #bfdbfe;
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.abrigo-ai-panel__brain > * {
  display: none;
}

.abrigo-ai-panel__brain svg {
  width: 19px;
  height: 19px;
}

.abrigo-ai-panel__close {
  width: 42px;
  height: 42px;
  border-radius: 16px;
  border-color: rgba(248, 113, 113, 0.26);
  background: rgba(127, 29, 29, 0.2);
  color: #fecaca;
}

.abrigo-ai-panel__close::before {
  content: "×";
  color: #fecaca;
  font-size: 24px;
  font-weight: 850;
  line-height: 1;
}

.abrigo-ai-panel__close > * {
  display: none;
}

.abrigo-ai-panel__messages {
  position: relative;
  z-index: 1;
  padding: 18px;
  gap: 14px;
  overflow-x: hidden;
}

.abrigo-ai-msg {
  max-width: min(96%, 390px);
}

.abrigo-ai-msg--user {
  max-width: min(88%, 360px);
}

.abrigo-ai-msg__row {
  align-items: flex-start;
  gap: 11px;
}

.abrigo-ai-msg__avatar--lua {
  width: 42px;
  height: 42px;
  margin-top: 3px;
  border-color: rgba(255, 255, 255, 0.52);
}

.abrigo-ai-msg__bubble {
  width: fit-content;
  max-width: 100%;
  padding: 13px 15px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.abrigo-ai-msg--assistant .abrigo-ai-msg__bubble {
  background:
    linear-gradient(180deg, rgba(30, 41, 59, 0.96), rgba(15, 23, 42, 0.92));
  border: 1px solid rgba(125, 211, 252, 0.18);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.16);
}

.abrigo-ai-msg--user .abrigo-ai-msg__bubble {
  background: linear-gradient(135deg, #14b8a6, #2563eb 54%, #7c3aed);
  box-shadow: 0 16px 32px rgba(37, 99, 235, 0.28);
}

.abrigo-ai-msg__bubble h4 {
  font-size: 15px;
  line-height: 1.25;
}

.abrigo-ai-mini-note {
  margin: 9px 0 0 !important;
  padding: 9px 10px;
  border-radius: 13px;
  border: 1px solid rgba(45, 212, 191, 0.22);
  background: rgba(20, 184, 166, 0.1);
  color: #ccfbf1;
  font-size: 12px;
}

.abrigo-ai-dev-alert {
  margin: 8px 0 10px !important;
  padding: 9px 10px;
  border-radius: 13px;
  border: 1px solid rgba(251, 191, 36, 0.28);
  background: rgba(251, 191, 36, 0.1);
  color: #fde68a;
  font-size: 12px;
  line-height: 1.45;
}

.abrigo-ai-lua-opener {
  color: #5eead4;
}

.abrigo-ai-msg__metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 9px;
}

.abrigo-ai-metric {
  border: 1px solid rgba(125, 211, 252, 0.16);
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.78), rgba(30, 41, 59, 0.68));
}

.abrigo-ai-metric strong {
  color: #e0f2fe;
  font-size: 17px;
}

.abrigo-ai-metrics-text {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 13px;
  border: 1px solid rgba(125, 211, 252, 0.16);
  background: rgba(15, 23, 42, 0.48);
  color: #dbeafe;
  font-size: 13px;
  line-height: 1.45;
}

.abrigo-ai-card,
.abrigo-ai-past-item {
  border-color: rgba(45, 212, 191, 0.22);
  background: rgba(8, 47, 73, 0.34);
}

.abrigo-ai-card:hover,
.abrigo-ai-past-item:hover {
  border-color: rgba(45, 212, 191, 0.55);
  background: rgba(20, 184, 166, 0.16);
  transform: translateY(-1px);
}

.abrigo-ai-panel__chips-wrap {
  position: relative;
  z-index: 1;
  padding: 0 0 8px;
  background: transparent;
  border: 0;
  backdrop-filter: none;
}

.abrigo-ai-panel__chips-label {
  margin: 0 0 6px;
  padding: 0 2px;
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
  text-transform: none;
  color: #94a3b8;
}

.abrigo-ai-panel__chips {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 8px;
  max-height: none;
  padding: 0 0 2px;
  overflow-x: auto;
  overflow-y: hidden;
  white-space: nowrap;
  scrollbar-width: thin;
}

.abrigo-ai-panel__chips::-webkit-scrollbar {
  height: 4px;
}

.abrigo-ai-chip {
  min-height: 0;
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 999px;
  border-color: rgba(125, 211, 252, 0.2);
  background: rgba(15, 23, 42, 0.78);
  color: #dbeafe;
  transition: border-color 0.18s ease, background 0.18s ease;
}

.abrigo-ai-chip--more {
  min-width: 44px;
  padding-inline: 12px;
  border-style: dashed;
  color: #7dd3fc;
}

.abrigo-ai-chip:hover {
  transform: none;
  border-color: rgba(45, 212, 191, 0.55);
  background: rgba(20, 184, 166, 0.14);
}

.abrigo-ai-panel__composer {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 8px 16px 16px;
  background: rgba(2, 6, 23, 0.88);
  border-top-color: rgba(125, 211, 252, 0.14);
}

.abrigo-ai-composer {
  padding: 6px;
  border-radius: 22px;
  border: 1px solid rgba(125, 211, 252, 0.16);
  background: rgba(15, 23, 42, 0.82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.abrigo-ai-composer:focus-within {
  border-color: rgba(45, 212, 191, 0.55);
  box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.1);
}

.abrigo-ai-composer textarea {
  min-height: 46px;
  border: none;
  background: transparent;
  padding: 12px 13px;
  box-shadow: none !important;
}

.abrigo-ai-composer textarea:focus {
  border-color: transparent;
  box-shadow: none;
}

.abrigo-ai-send {
  width: 48px;
  height: 48px;
  border-radius: 17px;
  background: linear-gradient(135deg, #2dd4bf, #3b82f6 52%, #7c3aed);
  box-shadow: 0 12px 28px rgba(59, 130, 246, 0.3);
  transition: transform 0.16s ease, filter 0.16s ease;
}

.abrigo-ai-send:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.abrigo-ai-send:active {
  transform: scale(0.96);
}

@media (min-width: 900px) {
  .abrigo-ai-panel {
    width: min(520px, calc(100vw - 48px));
  }
}

@media (max-width: 720px) {
  .abrigo-ai-panel {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
    height: min(760px, calc(100dvh - 20px));
    border-radius: 24px;
  }

  .abrigo-ai-panel__head {
    padding: 15px;
  }

  .abrigo-ai-panel__brain {
    display: none;
  }

  .abrigo-ai-panel__chips {
    flex-wrap: nowrap;
    overflow-x: auto;
    overflow-y: hidden;
    max-height: none;
    scrollbar-width: none;
  }
}

@media (max-width: 520px) {
  .abrigo-ai-fab {
    width: 64px;
    height: 64px;
  }

  .abrigo-ai-fab__avatar,
  .abrigo-ai-lua-frame--fab {
    width: 60px;
    height: 60px;
  }

  .abrigo-ai-panel {
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .abrigo-ai-panel__head {
    padding: calc(12px + env(safe-area-inset-top)) 12px 12px;
    min-height: 78px;
  }

  .abrigo-ai-panel__avatar {
    width: 52px;
    height: 52px;
  }

  .abrigo-ai-panel__meta h2 {
    font-size: 19px;
  }

  .abrigo-ai-panel__status {
    font-size: 11px;
  }

  .abrigo-ai-panel__messages {
    padding: 13px 12px 8px;
  }

  .abrigo-ai-msg,
  .abrigo-ai-msg--user {
    max-width: 100%;
  }

  .abrigo-ai-msg__avatar--lua {
    width: 34px;
    height: 34px;
  }

  .abrigo-ai-msg__bubble {
    font-size: 13px;
    padding: 11px 12px;
  }

  .abrigo-ai-msg__metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .abrigo-ai-panel__composer {
    padding: 10px 10px max(12px, env(safe-area-inset-bottom));
  }
}
