/* Assistente IA Premium — Adrianna Nails
   Versão responsiva com minimizar, enquadramento desktop e área segura mobile. */
:root {
  --ai-rose: #b76e79;
  --ai-rose-dark: #8f5660;
  --ai-rose-soft: #fff0f3;
  --ai-text: #493336;
  --ai-muted: #7f686c;
  --ai-line: rgba(183, 110, 121, .18);
  --ai-bg: #fff7f8;
  --ai-whatsapp: #25d366;
  --ai-shadow: 0 24px 70px rgba(73, 51, 54, .18);
  --ai-mobile-bottom-clearance: 96px;
}

.ai-assistant-root,
.ai-assistant-root * {
  box-sizing: border-box;
}

.ai-assistant-root {
  position: relative;
  z-index: 2147483000;
  font-family: inherit;
}

.ai-launcher {
  position: fixed;
  right: 24px;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 2147483000;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  max-width: min(340px, calc(100vw - 32px));
  padding: 12px 17px 12px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--ai-rose), #d9a2aa);
  color: #fff;
  box-shadow: 0 18px 42px rgba(183, 110, 121, .34);
  font-family: inherit;
  transition: transform .18s ease, box-shadow .18s ease, opacity .18s ease, visibility .18s ease;
}

.ai-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 52px rgba(183, 110, 121, .40);
}

.ai-launcher:active { transform: scale(.98); }

.ai-launcher.is-hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transform: translateY(12px);
}

.ai-launcher-icon {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.22);
  border: 1px solid rgba(255,255,255,.28);
  font-size: 19px;
  flex: 0 0 auto;
}

.ai-launcher-copy {
  display: grid;
  min-width: 0;
  max-width: 250px;
  text-align: left;
  line-height: 1.12;
}

.ai-launcher-copy strong,
.ai-launcher-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-launcher-copy strong { font-size: 13px; letter-spacing: .01em; }
.ai-launcher-copy span { font-size: 11px; opacity: .88; }

.ai-pulse {
  position: absolute;
  right: -2px;
  top: -2px;
  width: 12px;
  height: 12px;
  border-radius: 999px;
  background: #25d366;
  box-shadow: 0 0 0 7px rgba(37,211,102,.14);
}

.ai-panel {
  position: fixed;
  right: 24px;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
  z-index: 2147483001;
  width: min(470px, calc(100vw - 32px));
  height: min(680px, calc(100dvh - 48px - env(safe-area-inset-bottom, 0px)));
  min-height: 520px;
  display: none;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
  border-radius: 30px;
  background: rgba(255,255,255,.98);
  border: 1px solid var(--ai-line);
  box-shadow: var(--ai-shadow);
  font-family: inherit;
  backdrop-filter: blur(14px);
}

.ai-panel.open {
  display: grid;
  animation: aiSlideIn .22s ease both;
}

@keyframes aiSlideIn {
  from { transform: translateY(18px) scale(.985); opacity: 0; }
  to { transform: translateY(0) scale(1); opacity: 1; }
}

.ai-header {
  background: linear-gradient(135deg, rgba(183,110,121,.98), rgba(242,203,210,.94));
  color: #fff;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ai-brand {
  display: flex;
  gap: 12px;
  align-items: center;
  min-width: 0;
  flex: 1 1 auto;
}

.ai-avatar {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(255,255,255,.22);
  border: 1px solid rgba(255,255,255,.28);
  font-size: 22px;
  flex: 0 0 auto;
}

.ai-brand-copy {
  display: grid;
  min-width: 0;
  gap: 2px;
}

.ai-brand-copy strong {
  font-size: 15px;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-brand-copy span {
  font-size: 12px;
  opacity: .88;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ai-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
}

.ai-minimize,
.ai-close {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.28);
  background: rgba(255,255,255,.16);
  color: #fff;
  cursor: pointer;
  font-size: 18px;
  font-weight: 800;
  display: grid;
  place-items: center;
  line-height: 1;
}

.ai-minimize:hover,
.ai-close:hover {
  background: rgba(255,255,255,.24);
}

.ai-messages {
  min-height: 0;
  background:
    radial-gradient(circle at top left, rgba(183,110,121,.10), transparent 22rem),
    linear-gradient(180deg, #fffafa 0%, #fff 100%);
  overflow: auto;
  padding: 18px 16px 14px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.ai-message {
  display: flex;
  margin: 0 0 12px;
}

.ai-message.user { justify-content: flex-end; }

.ai-bubble {
  max-width: 88%;
  padding: 12px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--ai-text);
  background: #fff;
  border: 1px solid rgba(183,110,121,.12);
  box-shadow: 0 8px 20px rgba(73,51,54,.06);
  overflow-wrap: anywhere;
  word-break: normal;
}

.ai-message.bot .ai-bubble { border-top-left-radius: 8px; }

.ai-message.user .ai-bubble {
  background: var(--ai-rose);
  color: #fff;
  border-color: var(--ai-rose);
  border-top-right-radius: 8px;
}

.ai-bubble a {
  color: var(--ai-rose-dark);
  font-weight: 800;
  text-decoration: none;
}

.ai-message.user .ai-bubble a {
  color: #fff;
  text-decoration: underline;
}

.ai-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.ai-action {
  border: 1px solid rgba(183,110,121,.28);
  background: #fff;
  color: var(--ai-rose-dark);
  border-radius: 999px;
  padding: 9px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
  text-align: center;
  min-height: 36px;
}

.ai-action.primary {
  background: var(--ai-rose);
  color: #fff;
  border-color: var(--ai-rose);
}

.ai-action.whatsapp {
  background: var(--ai-whatsapp);
  color: #fff;
  border-color: var(--ai-whatsapp);
}

.ai-footer {
  min-width: 0;
  background: #fff;
}

.ai-quick {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 10px 14px 12px;
  border-top: 1px solid rgba(183,110,121,.10);
  background: #fffafb;
  scrollbar-width: thin;
  -webkit-overflow-scrolling: touch;
}

.ai-quick button {
  white-space: nowrap;
  border: 1px solid rgba(183,110,121,.20);
  color: var(--ai-rose-dark);
  background: #fff;
  border-radius: 999px;
  padding: 9px 12px;
  font: inherit;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.ai-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px 14px 14px;
  background: #fff;
  border-top: 1px solid rgba(183,110,121,.12);
}

.ai-form input {
  min-height: 46px;
  width: 100%;
  min-width: 0;
  border: 1px solid rgba(183,110,121,.20);
  border-radius: 999px;
  padding: 0 15px;
  outline: none;
  font: inherit;
  color: var(--ai-text);
  background: #fffafb;
}

.ai-form input:focus {
  border-color: var(--ai-rose);
  box-shadow: 0 0 0 3px rgba(183,110,121,.10);
}

.ai-send {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  border: 0;
  cursor: pointer;
  background: var(--ai-rose);
  color: #fff;
  font-size: 18px;
  display: grid;
  place-items: center;
}

.ai-send:disabled {
  opacity: .55;
  cursor: wait;
}

.ai-typing { display: inline-flex; gap: 4px; align-items: center; }
.ai-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ai-rose); opacity: .45; animation: aiBlink 1s infinite ease-in-out; }
.ai-dot:nth-child(2){ animation-delay: .15s; }
.ai-dot:nth-child(3){ animation-delay: .3s; }

@keyframes aiBlink {
  0%,80%,100% { transform: translateY(0); opacity: .35; }
  40% { transform: translateY(-3px); opacity: 1; }
}

@media (max-width: 760px) {
  .ai-launcher {
    right: 14px;
    left: auto;
    bottom: calc(var(--ai-mobile-bottom-clearance) + env(safe-area-inset-bottom, 0px));
    width: 58px;
    height: 58px;
    padding: 0;
    justify-content: center;
    border-radius: 22px;
  }

  .ai-launcher-icon {
    width: 42px;
    height: 42px;
    font-size: 20px;
  }

  .ai-launcher-copy { display: none; }
  .ai-pulse { right: 5px; top: 5px; }

  .ai-panel {
    left: 10px;
    right: 10px;
    top: max(12px, env(safe-area-inset-top, 0px));
    bottom: calc(var(--ai-mobile-bottom-clearance) + env(safe-area-inset-bottom, 0px));
    width: auto;
    height: auto;
    min-height: 0;
    max-height: none;
    border-radius: 26px;
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .ai-header {
    padding: 14px;
    gap: 10px;
  }

  .ai-avatar {
    width: 40px;
    height: 40px;
    border-radius: 14px;
    font-size: 20px;
  }

  .ai-brand-copy strong { font-size: 14px; }
  .ai-brand-copy span { font-size: 11px; max-width: calc(100vw - 172px); }

  .ai-minimize,
  .ai-close {
    width: 36px;
    height: 36px;
    border-radius: 13px;
  }

  .ai-messages { padding: 14px 12px 10px; }
  .ai-bubble { max-width: 94%; font-size: 13.5px; }

  .ai-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  .ai-action {
    width: 100%;
    min-height: 42px;
    padding: 11px 13px;
  }

  .ai-quick { padding: 9px 12px 10px; }
  .ai-quick button { padding: 9px 11px; font-size: 11.5px; }
  .ai-form { padding: 10px 12px 12px; }
  .ai-form input { min-height: 46px; font-size: 16px; }
}

@media (max-width: 380px) {
  .ai-panel {
    left: 8px;
    right: 8px;
    border-radius: 22px;
  }

  .ai-header-actions { gap: 6px; }
  .ai-minimize,
  .ai-close { width: 34px; height: 34px; }
  .ai-brand { gap: 9px; }
  .ai-brand-copy span { display: none; }
}

/* Fase 3 — botões de ação do pré-agendamento dentro do chat */
button.ai-action {
  appearance: none;
  font-family: inherit;
}
.ai-action.secondary {
  background: #fff;
  color: var(--ai-rose-dark);
  border-color: rgba(183,110,121,.28);
}
.ai-action.danger {
  background: #fff;
  color: #b04a58;
  border-color: rgba(176,74,88,.28);
}
.ai-action.danger:hover,
.ai-action.secondary:hover {
  background: #fff7f8;
}
