/* Mira — floating assistant on the Shopify app sites. Colors follow the site theme. */
.mira {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 80;
  font-family: Inter, system-ui, sans-serif;
  color: rgb(var(--slate-900));
}

.mira__launcher {
  position: relative;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.25rem;
  height: 3.25rem;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgb(var(--accent-600));
  color: #fff;
  box-shadow: 0 10px 28px rgb(4 120 87 / 0.28);
  cursor: pointer;
}

.mira__launcher:hover,
.mira__launcher:focus-visible {
  background: rgb(var(--accent-700));
  outline: 2px solid rgb(var(--accent-600));
  outline-offset: 3px;
}

.mira__launcher svg {
  width: 1.45rem;
  height: 1.45rem;
  display: block;
}

.mira__hint {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.65rem);
  margin: 0;
  max-width: 12rem;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  background: rgb(var(--surface));
  color: rgb(var(--slate-900));
  border: 1px solid rgb(var(--slate-200));
  box-shadow: 0 8px 20px rgb(15 23 42 / 0.12);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
  animation: mira-bob 1.6s ease-in-out infinite;
}

.mira__hint[hidden] {
  display: none;
}

.mira__hint::after {
  content: "";
  position: absolute;
  right: 1.15rem;
  bottom: -5px;
  width: 8px;
  height: 8px;
  background: rgb(var(--surface));
  border-right: 1px solid rgb(var(--slate-200));
  border-bottom: 1px solid rgb(var(--slate-200));
  transform: rotate(45deg);
}

.mira__backdrop {
  display: none;
}

.mira__panel {
  position: absolute;
  right: 0;
  bottom: calc(100% + 0.75rem);
  display: flex;
  flex-direction: column;
  width: min(23.5rem, calc(100vw - 2rem));
  height: min(36rem, calc(100dvh - 6.5rem));
  background: rgb(var(--surface));
  border: 1px solid rgb(var(--slate-200));
  border-radius: 1.125rem;
  box-shadow: 0 18px 50px rgb(15 23 42 / 0.16);
  overflow: hidden;
  transform-origin: bottom right;
}

.mira__panel[hidden] {
  display: none;
}

.mira__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 0.9rem 0.35rem;
}

.mira__title {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.95rem;
}

.mira__dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: rgb(var(--accent-500));
  box-shadow: 0 0 0 4px rgb(var(--accent-100));
}

.mira__close {
  border: 0;
  background: transparent;
  color: rgb(var(--slate-500));
  font-size: 1.4rem;
  line-height: 1;
  padding: 0.15rem 0.35rem;
  cursor: pointer;
  border-radius: 0.4rem;
}

.mira__close:hover,
.mira__close:focus-visible {
  color: rgb(var(--slate-900));
  background: rgb(var(--slate-100));
}

.mira__disclaimer {
  margin: 0;
  padding: 0 0.95rem 0.55rem;
  color: rgb(var(--slate-500));
  font-size: 0.75rem;
}

.mira__messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.35rem 0.85rem 0.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.mira__bubble {
  max-width: 92%;
  padding: 0.65rem 0.75rem;
  border-radius: 0.9rem;
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.mira__bubble--assistant {
  align-self: flex-start;
  background: rgb(var(--slate-50));
  border: 1px solid rgb(var(--slate-100));
}

.mira__bubble--user {
  align-self: flex-end;
  background: rgb(var(--accent-600));
  color: #fff;
}

.mira__bubble a {
  color: rgb(var(--accent-700));
  text-decoration: underline;
  text-underline-offset: 2px;
}

.mira__bubble--user a {
  color: #fff;
}

.mira__bubble.is-streaming::after {
  content: "";
  display: inline-block;
  width: 0.35rem;
  height: 0.9em;
  margin-left: 0.12rem;
  vertical-align: text-bottom;
  background: currentColor;
  opacity: 0.55;
  animation: mira-caret 1s steps(1) infinite;
}

.mira__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: -0.15rem 0 0.15rem;
}

.mira__action {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 0.35rem 0.7rem;
  background: rgb(var(--accent-600));
  color: #fff;
  font-size: 0.75rem;
  font-weight: 600;
  text-decoration: none;
}

.mira__action:hover,
.mira__action:focus-visible {
  background: rgb(var(--accent-700));
  color: #fff;
}

.mira__presets {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0 0.85rem 0.55rem;
}

.mira__preset {
  text-align: left;
  border: 1px solid rgb(var(--slate-200));
  background: rgb(var(--surface));
  color: rgb(var(--slate-800));
  border-radius: 0.75rem;
  padding: 0.45rem 0.65rem;
  font: inherit;
  font-size: 0.8rem;
  line-height: 1.35;
  cursor: pointer;
}

.mira__preset:hover,
.mira__preset:focus-visible {
  border-color: rgb(var(--accent-300));
  color: rgb(var(--accent-700));
}

.mira__footer {
  padding: 0.35rem 0.75rem 0.75rem;
  border-top: 1px solid rgb(var(--slate-100));
}

.mira__field {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  border: 1px solid rgb(var(--slate-200));
  border-radius: 999px;
  padding: 0.2rem 0.2rem 0.2rem 0.85rem;
  background: rgb(var(--surface));
}

.mira__field:focus-within {
  border-color: rgb(var(--accent-400));
  box-shadow: 0 0 0 3px rgb(var(--accent-100));
}

.mira__input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: transparent;
  color: rgb(var(--slate-900));
  font: inherit;
  font-size: 16px;
  padding: 0.45rem 0;
}

.mira__input:focus {
  outline: none;
}

.mira__send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.15rem;
  height: 2.15rem;
  border: 0;
  border-radius: 999px;
  background: rgb(var(--accent-600));
  color: #fff;
  cursor: pointer;
}

.mira__send:disabled {
  opacity: 0.45;
  cursor: default;
}

.mira__send svg {
  width: 1.05rem;
  height: 1.05rem;
}

body.mira-lock {
  overflow: hidden;
  touch-action: none;
}

@media (max-width: 640px) {
  .mira.is-open .mira__backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgb(15 23 42 / 0.35);
  }

  .mira__panel {
    position: fixed;
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: min(78dvh, 40rem);
    border-radius: 1.125rem 1.125rem 0 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .mira__bubble.is-streaming::after,
  .mira__hint {
    animation: none;
  }
}

@media print {
  .mira {
    display: none !important;
  }
}

@keyframes mira-caret {
  50% { opacity: 0; }
}

@keyframes mira-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
