/**
 * Aura – flydende AI-kundeservicewidget
 * Bygger på Auroa Design System v9 tokens. Falder tilbage til hardcodede
 * værdier hvis et token mangler, så widgeten også virker uden for sitets CSS.
 *
 * @version 1.0.0
 */

/* ---------------------------------------------------------------- Root */
.c-aura {
  position: fixed;
  right: clamp(16px, 4vw, 28px);
  bottom: clamp(16px, 4vw, 28px);
  z-index: var(--z-overlay, 1000);
  font-family: var(--font-sans, system-ui, sans-serif);
}

/* ---------------------------------------------------- Minimeret skjold */
.c-aura__launcher {
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  padding: 0;
  border: none;
  border-radius: var(--r-pill, 999px);
  background: linear-gradient(135deg,
    var(--accent, #2F6BFF), var(--accent-2, #00D3A7));
  box-shadow: var(--shadow, 0 14px 40px rgba(0 0 0 / .35));
  cursor: pointer;
  transition: transform .25s var(--ease, ease), box-shadow .25s ease;
}
.c-aura__launcher:hover { transform: translateY(-2px) scale(1.04); }
.c-aura__launcher:focus-visible {
  outline: 2px solid var(--accent, #2F6BFF);
  outline-offset: 3px;
}

/* Pulserende ring */
.c-aura__pulse {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 0 rgba(47 107 255 / .55);
  animation: aura-pulse 2.4s cubic-bezier(.4, 0, .2, 1) infinite;
  pointer-events: none;
}
@keyframes aura-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(47 107 255 / .55); }
  70%  { box-shadow: 0 0 0 18px rgba(47 107 255 / 0); }
  100% { box-shadow: 0 0 0 0 rgba(47 107 255 / 0); }
}

/* Når åbent: skjul launcher */
.c-aura[data-state="open"] .c-aura__launcher { display: none; }

/* --------------------------------------------------------- Chat-panel */
.c-aura__panel {
  display: none;
  flex-direction: column;
  width: min(380px, calc(100vw - 32px));
  height: min(560px, calc(100vh - 120px));
  border: 1px solid var(--border, rgba(234 240 255 / .12));
  border-radius: var(--r-lg, 16px);
  background: var(--bg-page, #0b0f17);
  box-shadow: var(--shadow-lg, 0 24px 60px rgba(0 0 0 / .50));
  overflow: hidden;
}
.c-aura[data-state="open"] .c-aura__panel { display: flex; }

/* Titelbjælke */
.c-aura__bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s3, 12px) var(--s4, 16px);
  background: linear-gradient(135deg,
    var(--accent, #2F6BFF), var(--accent-2, #00D3A7));
  color: #fff;
}
.c-aura__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--s2, 8px);
  font-weight: 600;
  font-size: var(--fs-md, 1.0625rem);
}
.c-aura__min {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border: none;
  border-radius: var(--r-sm, 8px);
  background: rgba(255 255 255 / .18);
  color: #fff;
  font-size: 20px;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  flex: 0 0 auto;
}
.c-aura__min:hover { background: rgba(255 255 255 / .30); }

/* Beskedlog */
.c-aura__log {
  flex: 1;
  overflow-y: auto;
  padding: var(--s4, 16px);
  display: flex;
  flex-direction: column;
  gap: var(--s3, 12px);
}
.c-aura__msg {
  max-width: 85%;
  padding: var(--s2, 8px) var(--s3, 12px);
  border-radius: var(--r-md, 12px);
  font-size: var(--fs-sm, .9375rem);
  line-height: var(--lh-normal, 1.5);
  white-space: pre-wrap;
  word-wrap: break-word;
}
.c-aura__msg--user {
  align-self: flex-end;
  background: var(--accent, #2F6BFF);
  color: #fff;
  border-bottom-right-radius: var(--r-sm, 4px);
}
.c-aura__msg--bot {
  align-self: flex-start;
  background: var(--bg-glass, rgba(255 255 255 / .04));
  border: 1px solid var(--border-faint, rgba(234 240 255 / .06));
  color: var(--auroa-field-text, #e6ecff);
  border-bottom-left-radius: var(--r-sm, 4px);
}
.c-aura__msg--bot a { color: var(--accent-2, #00D3A7); }
.c-aura__msg--typing { opacity: .6; font-style: italic; }

/* Samtykke-gate */
.c-aura__consent {
  padding: var(--s3, 12px) var(--s4, 16px);
  background: var(--bg-glass, rgba(255 255 255 / .04));
  border-top: 1px solid var(--border-faint, rgba(234 240 255 / .06));
  font-size: var(--fs-xs, .8125rem);
  line-height: var(--lh-normal, 1.5);
  color: var(--auroa-field-text, #e6ecff);
}
.c-aura__consent-text { margin: 0 0 var(--s2, 8px); }
.c-aura__consent-text a { color: var(--accent-2, #00D3A7); }
.c-aura__consent-check {
  display: flex; gap: var(--s2, 8px); align-items: flex-start; cursor: pointer;
}
.c-aura__consent-check input { margin-top: 3px; }
.c-aura[data-consented="1"] .c-aura__consent { display: none; }

/* Turnstile */
.cf-turnstile { padding: var(--s2, 8px) var(--s4, 16px) 0; }

/* Inputrække */
.c-aura__input {
  display: flex;
  align-items: flex-end;
  gap: var(--s2, 8px);
  padding: var(--s3, 12px) var(--s4, 16px);
  border-top: 1px solid var(--border, rgba(234 240 255 / .12));
}
.c-aura__input--locked { opacity: .5; pointer-events: none; }
.c-aura__field {
  flex: 1;
  resize: none;
  max-height: 120px;
  padding: var(--s2, 8px) var(--s3, 12px);
  border: 1px solid var(--auroa-field-border, rgba(234 240 255 / .18));
  border-radius: var(--r-md, 12px);
  background: var(--auroa-field-bg, rgba(255 255 255 / .03));
  color: var(--auroa-field-text, #e6ecff);
  font: inherit;
  font-size: var(--fs-sm, .9375rem);
}
.c-aura__field::placeholder { color: var(--auroa-field-placeholder, #8a93a8); }
.c-aura__field:focus {
  outline: none;
  border-color: var(--accent, #2F6BFF);
}
.c-aura__send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  width: 42px; height: 42px;
  padding: 0;
  border: none;
  border-radius: var(--r-md, 12px);
  background: var(--accent, #2F6BFF);
  color: #fff;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background .2s ease;
}
.c-aura__send:hover { background: var(--accent-hover, #4A82FF); }
.c-aura__send:disabled { opacity: .5; cursor: default; }

/* --------------------------------------------- Reduceret bevægelse */
@media (prefers-reduced-motion: reduce) {
  .c-aura__pulse { animation: none; }
  .c-aura__launcher { transition: none; }
}

/* ----------------------------------------------------- Mobil */
@media (max-width: 480px) {
  .c-aura {
    right: 0;
    bottom: 0;
  }

  /* Launcher i nederste højre hjørne */
  .c-aura__launcher {
    position: fixed;
    right: 16px;
    bottom: 16px;
    width: 56px;
    height: 56px;
  }

  /* Panel: fast forankret til alle fire kanter. Højden følger den
     SYNLIGE del af skærmen (svh = small viewport height), så tastaturet
     ikke skubber inputfeltet ud af syne. */
  .c-aura[data-state="open"] .c-aura__panel {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100vw;
    height: 100svh;          /* small viewport height — stabil med tastatur */
    max-height: 100svh;
    border: none;
    border-radius: 0;
  }

  /* Log fylder resten og scroller; bar + input forbliver synlige */
  .c-aura__log { flex: 1 1 auto; min-height: 0; padding: 14px; }
  .c-aura__bar   { flex: 0 0 auto; padding: 12px 16px; }
  .c-aura__input { flex: 0 0 auto; }
  .c-aura__consent { flex: 0 0 auto; }

  /* Skriftstørrelser — undgå at site-tokens skalerer for stort */
  .c-aura__panel { font-size: 16px; }
  .c-aura__brand { font-size: 1rem; }
  .c-aura__msg {
    max-width: 88%;
    font-size: 0.95rem;
    line-height: 1.45;
  }
  .c-aura__field { font-size: 16px; }  /* 16px = iOS zoomer ikke ved fokus */
}
