/* Aarbakke Design — booking/quote assistant widget.
 * CSP-safe: this is the ONLY place widget styling lives (style-src 'self').
 * chatbot.js never sets inline styles. Uses brand tokens from styles.css,
 * with literal fallbacks so the widget survives if those tokens are renamed.
 *
 * Accessibility: interactive targets are >= 44x44 px (WCAG 2.2 SC 2.5.8 asks
 * >= 24x24; 44 is the enhanced/thumb-reach best practice). All motion is gated
 * behind prefers-reduced-motion. Focus is always visible (:focus-visible). */

.aad-chat {
  /* Widgeten eier egne tokens — arver bevisst IKKE sidens --accent
   * (marketing.css definerer fortsatt gammel oransje der). */
  --c-accent: #c98f5f;
  --c-accent-hover: #d1a171;
  --c-accent-ink: #12151b; /* mørk ink på kobberflater — kobber + hvit feiler WCAG */
  --c-bg: var(--bg-card, #111114);
  --c-bg-elev: var(--bg-elevated, #1a1a1f);
  --c-text: var(--text, #fafafa);
  --c-text-dim: var(--text-secondary, #a1a1aa);
  --c-border: var(--border, rgba(255, 255, 255, 0.1));
  --c-radius: var(--radius-lg, 20px);
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000; /* above lightbox + nav */
  font-family: var(--font-sans, system-ui), sans-serif;
}

/* Launcher bubble */
.aad-chat__launcher {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, var(--c-accent) 0%, #b0784a 100%);
  color: var(--c-accent-ink);
  font-size: 24px;
  line-height: 56px;
  box-shadow: 0 8px 24px rgba(201, 143, 95, 0.35);
  transition: transform 200ms ease, box-shadow 200ms ease;
}
.aad-chat__launcher:hover {
  transform: scale(1.06);
  box-shadow: 0 10px 30px rgba(201, 143, 95, 0.5);
}

/* Panel */
.aad-chat__panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: min(380px, calc(100vw - 40px));
  height: min(560px, calc(100vh - 120px));
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: var(--c-bg);
  border: 1px solid var(--c-border);
  border-radius: var(--c-radius);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.aad-chat--open .aad-chat__panel {
  display: flex;
}

/* Header: heading on the left, icon actions (email a human / close) on the right */
.aad-chat__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 12px 12px 12px 16px;
  background: var(--c-bg-elev);
  border-bottom: 1px solid var(--c-border);
}
.aad-chat__heading {
  flex: 1;
  min-width: 0;
  padding-top: 4px;
}
.aad-chat__title {
  font-family: var(--font-sans, system-ui), sans-serif;
  font-weight: 600;
  font-size: 15px;
  color: var(--c-text);
}
.aad-chat__subtitle {
  font-size: 12px;
  color: var(--c-text-dim);
  margin-top: 2px;
}
.aad-chat__header-actions {
  display: flex;
  gap: 2px;
  flex: none;
}
.aad-chat__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  border: none;
  background: transparent;
  color: var(--c-text-dim);
  border-radius: 10px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
  transition: color 150ms ease, background 150ms ease;
}
.aad-chat__icon-btn:hover {
  color: var(--c-text);
  background: var(--c-border);
}

/* Disclosure (AI Act Art 50) + short privacy line */
.aad-chat__notice {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 16px;
  background: var(--c-bg-elev);
  border-bottom: 1px solid var(--c-border);
}
.aad-chat__notice-line {
  font-size: 11px;
  line-height: 1.4;
  color: var(--c-text-dim);
}
.aad-chat__notice-line--dim {
  opacity: 0.85;
}
.aad-chat__notice-link {
  display: inline-block;
  padding: 4px 0;
  font-size: 11px;
  color: var(--c-accent-hover);
  text-decoration: underline;
  width: fit-content;
}
.aad-chat__notice-link:hover {
  color: var(--c-accent);
}
.aad-chat__notice-link:focus-visible {
  outline: 2px solid var(--c-accent-hover);
  outline-offset: 2px;
}

.aad-chat__log {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.aad-chat__msg {
  max-width: 85%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.aad-chat__msg--bot {
  align-self: flex-start;
  background: var(--c-bg-elev);
  color: var(--c-text);
  border-bottom-left-radius: 4px;
}
.aad-chat__msg--user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--c-accent) 0%, #b0784a 100%);
  color: var(--c-accent-ink);
  border-bottom-right-radius: 4px;
}
.aad-chat__msg--typing {
  color: var(--c-text-dim);
  font-style: italic;
}

.aad-chat__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-self: flex-start;
}
.aad-chat__cta {
  display: inline-flex;
  align-items: center;
  min-height: 40px;
  border: 1px solid var(--c-accent);
  background: transparent;
  color: var(--c-accent-hover);
  border-radius: 999px;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  transition: background 150ms ease, color 150ms ease;
}
.aad-chat__cta:hover {
  background: var(--c-accent);
  color: var(--c-accent-ink);
}

/* "Betal nå" — filled primary variant of the CTA pill; sits alongside the
 * portal link so the two actions stay visually distinct at a glance. */
.aad-chat__pay-btn {
  background: var(--c-accent);
  color: var(--c-accent-ink);
  border-color: var(--c-accent);
  font-weight: 600;
}
.aad-chat__pay-btn:hover {
  background: #b0784a;
  border-color: #b0784a;
  color: var(--c-accent-ink);
}
.aad-chat__pay-btn:disabled {
  opacity: 0.55;
  cursor: default;
}
.aad-chat__pay-btn:focus-visible {
  outline: 2px solid var(--c-accent-hover);
  outline-offset: 2px;
}

.aad-chat__form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--c-border);
}
.aad-chat__input {
  flex: 1;
  resize: none;
  border: 1px solid var(--c-border);
  background: var(--c-bg-elev);
  color: var(--c-text);
  border-radius: 12px;
  padding: 11px 12px;
  font-family: inherit;
  font-size: 14px;
  min-height: 44px;
  max-height: 96px;
}
.aad-chat__input:focus {
  outline: none;
  border-color: var(--c-accent);
}
.aad-chat__send {
  border: none;
  background: var(--c-accent);
  color: var(--c-accent-ink);
  border-radius: 12px;
  min-width: 44px;
  min-height: 44px;
  cursor: pointer;
  font-size: 18px;
  transition: background 150ms ease;
}
.aad-chat__send:hover {
  background: var(--c-accent-hover);
}
.aad-chat__send:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Always-visible keyboard focus indicator */
.aad-chat__launcher:focus-visible,
.aad-chat__icon-btn:focus-visible,
.aad-chat__cta:focus-visible,
.aad-chat__send:focus-visible,
.aad-chat__input:focus-visible {
  outline: 2px solid var(--c-accent-hover);
  outline-offset: 2px;
}

/* Mobile: the panel takes over the screen → it is genuinely modal there
 * (chatbot.js sets aria-modal="true" + traps focus only at this breakpoint). */
@media (max-width: 480px) {
  .aad-chat--open .aad-chat__panel {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-width: none;
    border: none;
    border-radius: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .aad-chat__launcher,
  .aad-chat__icon-btn,
  .aad-chat__cta,
  .aad-chat__send {
    transition: none;
  }
  .aad-chat__launcher:hover {
    transform: none;
  }
}
