/*
 * AI Intralogistics Chat — estilos del widget flotante.
 * Todo prefijado con `aic-` y con !important en lo crítico para resistir temas
 * agresivos. z-index alto pero por debajo del máximo absoluto para no tapar
 * banners legales/cookies del sitio.
 */

.aic-root {
  position: fixed !important;
  bottom: 20px;
  z-index: 999999;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.aic-root.aic-pos-right { right: 20px; }
.aic-root.aic-pos-left  { left: 20px; }

/* --- Burbuja ------------------------------------------------------------- */
.aic-bubble {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 62px;
  height: 62px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 50%;
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(37, 39, 40, 0.28);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  -webkit-appearance: none;
  appearance: none;
}

.aic-bubble:hover {
  transform: scale(1.06);
  box-shadow: 0 8px 26px rgba(37, 39, 40, 0.34);
}

.aic-bubble:focus-visible {
  outline: 3px solid rgba(122, 201, 67, 0.6);
  outline-offset: 2px;
}

/* Tema sobrio: burbuja carbón con anillo verde de marca permanente (mantiene
   un toque de color de marca sobre el gris). */
.aic-sober .aic-bubble {
  box-shadow: 0 0 0 3px #7ac943, 0 6px 20px rgba(37, 39, 40, 0.28);
}
.aic-sober .aic-bubble:hover {
  box-shadow: 0 0 0 3px #7ac943, 0 8px 26px rgba(37, 39, 40, 0.34);
}

/* Isotipo de marca pintado en blanco con CSS mask (independiente del color
   propio del PNG). isotipo.png está en esta misma carpeta (assets/). */
.aic-bubble-logo {
  display: block;
  width: 26px;
  height: 32px;
  background-color: #ffffff;
  -webkit-mask: url("isotipo.png") center / contain no-repeat;
  mask: url("isotipo.png") center / contain no-repeat;
}

/* --- Globo de saludo ----------------------------------------------------- */
.aic-greeting {
  position: absolute;
  bottom: 78px;
  display: none;
  align-items: center;
  gap: 10px;
  width: 300px;
  max-width: calc(100vw - 48px);
  padding: 12px 14px;
  background: #ffffff;
  color: #252728;
  border-radius: 16px;
  box-shadow: 0 14px 40px rgba(37, 39, 40, 0.24);
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.22s ease, transform 0.22s ease;
}

/* Avatar de marca dentro del globo. */
.aic-greeting-avatar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
}
.aic-greeting-avatar-mark {
  display: block;
  width: 18px;
  height: 22px;
  background-color: #ffffff;
  -webkit-mask: url("isotipo.png") center / contain no-repeat;
  mask: url("isotipo.png") center / contain no-repeat;
}

.aic-pos-right .aic-greeting { right: 4px; }
.aic-pos-left  .aic-greeting { left: 4px; }

.aic-root.aic-greeting-visible .aic-greeting {
  display: flex;
  opacity: 1;
  transform: translateY(0);
}

/* Colita del globo apuntando a la burbuja. */
.aic-greeting::after {
  content: "";
  position: absolute;
  bottom: -6px;
  width: 12px;
  height: 12px;
  background: #ffffff;
  transform: rotate(45deg);
  box-shadow: 3px 3px 8px rgba(37, 39, 40, 0.10);
}
.aic-pos-right .aic-greeting::after { right: 22px; }
.aic-pos-left  .aic-greeting::after { left: 22px; }

.aic-greeting-text {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: none;
  background: none;
  font-size: 13.5px;
  line-height: 1.4;
  color: #252728;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
}

.aic-greeting-close {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin: -2px -2px 0 0;
  padding: 0;
  border: none;
  border-radius: 6px;
  background: rgba(37, 39, 40, 0.06);
  color: rgba(37, 39, 40, 0.55);
  font-size: 16px;
  line-height: 18px;
  cursor: pointer;
  font-family: inherit;
}
.aic-greeting-close:hover { background: rgba(37, 39, 40, 0.12); }

/* --- Panel --------------------------------------------------------------- */
.aic-panel {
  position: absolute;
  bottom: 78px;
  width: 420px;
  max-width: calc(100vw - 40px);
  height: 700px;
  max-height: calc(100vh - 110px);
  background: #ffffff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 70px rgba(37, 39, 40, 0.30);
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.aic-pos-right .aic-panel { right: 0; transform-origin: bottom right; }
.aic-pos-left  .aic-panel { left: 0;  transform-origin: bottom left; }

.aic-root.aic-open .aic-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.aic-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  color: #ffffff;
  flex: 0 0 auto;
}

.aic-panel-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  color: #ffffff;
}

.aic-panel-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  cursor: pointer;
  -webkit-appearance: none;
  appearance: none;
}

.aic-panel-close:hover { background: rgba(255, 255, 255, 0.28); }

.aic-iframe-wrap {
  flex: 1 1 auto;
  min-height: 0;
  background: #ffffff;
}

.aic-iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
}

/* --- Mobile: panel casi full-screen ------------------------------------- */
@media (max-width: 480px) {
  .aic-root { bottom: 16px; }
  .aic-root.aic-pos-right { right: 16px; }
  .aic-root.aic-pos-left  { left: 16px; }

  .aic-greeting { max-width: calc(100vw - 96px); }

  .aic-panel {
    position: fixed;
    bottom: 88px;
    left: 8px;
    right: 8px;
    width: auto;
    max-width: none;
    height: auto;
    top: 8px;
    max-height: none;
  }
}

/* Respetar usuarios que prefieren menos movimiento. */
@media (prefers-reduced-motion: reduce) {
  .aic-bubble,
  .aic-panel,
  .aic-greeting { transition: none; }
}
