/* AERO chat widget — "Cyber Core" theme, ported from the standalone app
   (frontend/src/themes.ts + the component modules) so the embedded widget
   matches it. Every rule lives under #aero-widget-root and the whole widget is
   rendered inside a shadow root (see aero-widget.js), so the host retail page's
   CSS can never reach in and restyle it — and nothing here leaks out. */

#aero-widget-root {
  /* --- Cyber Core palette --- */
  --aero-bg: radial-gradient(130% 90% at 75% -10%, #0e1f44 0%, #081026 45%, #050811 100%);
  --aero-panel: rgba(13, 26, 52, 0.82);
  --aero-panel-2: rgba(22, 40, 74, 0.5);
  --aero-line: rgba(90, 200, 255, 0.22);
  --aero-text: #e9f5ff;
  --aero-fg: #e9f5ff;
  --aero-muted: #8ba8cc;
  --aero-accent: #28e7ff;
  --aero-accent-2: #a06bff;
  --aero-accent-ink: #04121c;
  --aero-accent-text: #04121c;
  --aero-glow: rgba(40, 231, 255, 0.45);
  --aero-radius: 16px;
  --aero-border: rgba(90, 200, 255, 0.22);
  --aero-user-bubble: #28e7ff;
  --aero-user-ink: #04121c;
  --aero-bot-bubble: rgba(22, 40, 74, 0.5);
  --aero-field-bg: rgba(8, 16, 38, 0.55);
  --aero-shadow: 0 26px 54px rgba(0, 0, 0, 0.55);
  --aero-display-font: "Orbitron", system-ui, sans-serif;
  --aero-body-font: "Chakra Petch", system-ui, sans-serif;
  --aero-tag-font: "Orbitron", system-ui, sans-serif;
  --aero-launcher-grad: linear-gradient(135deg, #28e7ff, #7b5cff);
  --aero-header-grad: linear-gradient(135deg, rgba(40, 231, 255, 0.16), rgba(160, 107, 255, 0.12));
  --aero-bg-image: radial-gradient(circle at 1px 1px, rgba(120, 210, 255, 0.1) 1px, transparent 1.6px);
  --aero-bg-size: 22px 22px;

  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 2147483000;
  font-family: var(--aero-body-font);
}

#aero-widget-root *,
#aero-widget-root *::before,
#aero-widget-root *::after {
  box-sizing: border-box;
}

/* ---------- the alien mark (used in the header, bot rows, launcher) ----------
   The supplied logo is a single-colour silhouette used as a MASK, so the
   element paints the theme's accent gradient and the image only decides where
   that paint lands. url() resolves against THIS stylesheet's location
   (…/widget/aero-widget.css), i.e. …/widget/alienware.png — correct no matter
   what origin the host page is served from. */
.aero-avatar {
  flex: none;
  display: inline-block;
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, var(--aero-accent), var(--aero-accent-2));
  -webkit-mask: url("alienware.png") no-repeat center / contain;
  mask: url("alienware.png") no-repeat center / contain;
  filter: drop-shadow(0 0 8px var(--aero-glow));
}

/* ---------- launcher ---------- */
.aero-launcher {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 1px solid var(--aero-line);
  background: var(--aero-launcher-grad);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 18px var(--aero-glow);
  transition: transform 0.15s ease;
  font-size: 0;
}
.aero-launcher::before {
  content: "";
  width: 62%;
  height: 62%;
  background: var(--aero-accent-text);
  -webkit-mask: url("alienware.png") no-repeat center / contain;
  mask: url("alienware.png") no-repeat center / contain;
}
.aero-launcher:hover {
  transform: scale(1.06);
}

/* ---------- panel ---------- */
.aero-panel {
  position: absolute;
  right: 0;
  bottom: 72px;
  width: min(392px, calc(100vw - 40px));
  /* dvh so the panel fits the visible area on mobile browsers whose toolbar
     shows/hides; the vh line is the fallback for older engines. */
  height: min(640px, calc(100vh - 120px));
  height: min(640px, calc(100dvh - 120px));
  background-color: #0a0e16;
  background-image: var(--aero-bg-image), var(--aero-bg);
  background-size: var(--aero-bg-size), cover;
  background-repeat: repeat, no-repeat;
  color: var(--aero-text);
  border: 1px solid var(--aero-line);
  border-radius: var(--aero-radius);
  box-shadow: var(--aero-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.aero-panel[hidden] {
  display: none;
}

.aero-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background: var(--aero-header-grad);
  border-bottom: 1px solid var(--aero-line);
}
.aero-header .aero-avatar {
  width: 42px;
  height: 42px;
}
.aero-brand {
  min-width: 0;
}
.aero-name {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  font-family: var(--aero-display-font);
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--aero-text);
  font-size: 15px;
}
.aero-ai-tag {
  font-family: var(--aero-tag-font);
  font-size: 8px;
  letter-spacing: 0.08em;
  background: var(--aero-accent);
  color: var(--aero-accent-text);
  padding: 3px 5px;
  border-radius: 4px;
}
.aero-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 3px 0 0;
  color: var(--aero-muted);
  font-size: 10.5px;
}
.aero-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--aero-accent);
  box-shadow: 0 0 7px var(--aero-accent);
  animation: aero-status-blink 1.8s ease-in-out infinite;
}

.aero-header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  flex: none;
}
.aero-new {
  background: transparent;
  border: 1px solid var(--aero-line);
  color: var(--aero-muted);
  font-family: var(--aero-body-font);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 6px 9px;
  border-radius: 7px;
  cursor: pointer;
}
.aero-new:hover {
  border-color: var(--aero-accent);
  color: var(--aero-accent);
}
.aero-close,
.aero-max {
  background: transparent;
  border: 1px solid var(--aero-line);
  color: var(--aero-text);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  width: 30px;
  height: 30px;
  border-radius: 7px;
  display: grid;
  place-items: center;
}
.aero-max {
  font-size: 15px;
}
.aero-close:hover,
.aero-max:hover {
  border-color: var(--aero-accent);
  color: var(--aero-accent);
}
.aero-max[aria-pressed="true"] {
  border-color: var(--aero-accent);
  color: var(--aero-accent);
}

/* Two-class specificity is intentional: later tablet/landscape .aero-panel
   rules must never shrink a maximised panel back to the compact dimensions. */
.aero-panel.aero-panel--max {
  position: fixed;
  inset: 0;
  width: 100vw;
  width: 100dvw;
  height: 100vh;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  --aero-content-max: 920px;
}
.aero-panel.aero-panel--max .aero-log,
.aero-panel.aero-panel--max .aero-quick,
.aero-panel.aero-panel--max .aero-form {
  width: 100%;
  max-width: var(--aero-content-max);
  align-self: center;
}

.aero-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.aero-log::-webkit-scrollbar {
  width: 8px;
}
.aero-log::-webkit-scrollbar-thumb {
  background: var(--aero-line);
  border-radius: 9px;
}

/* A bot message is an avatar + a column of bubble(s). */
.aero-bot-row {
  display: flex;
  gap: 9px;
  align-items: flex-start;
  padding-right: 8px;
}
.aero-bot-row .aero-avatar {
  width: 26px;
  height: 26px;
  margin-top: 2px;
}
.aero-bot-col {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.aero-msg {
  width: fit-content;
  max-width: 100%;
  padding: 10px 13px;
  font-size: 13px;
  line-height: 1.5;
  white-space: pre-line;
  overflow-wrap: anywhere;
  animation: aero-msg-in 0.3s ease both;
}
.aero-msg.user {
  align-self: flex-end;
  max-width: 85%;
  background: var(--aero-user-bubble);
  color: var(--aero-user-ink);
  font-weight: 600;
  border-radius: 13px 13px 4px 13px;
  box-shadow: 0 4px 16px var(--aero-glow);
}
.aero-msg.bot {
  background: var(--aero-panel-2);
  border: 1px solid var(--aero-line);
  color: var(--aero-text);
  border-radius: 4px 13px 13px 13px;
}
.aero-msg.error {
  align-self: flex-start;
  background: rgba(255, 70, 70, 0.12);
  border: 1px solid rgba(255, 90, 90, 0.4);
  color: #ffd9d9;
  border-radius: 4px 13px 13px 13px;
}

.aero-typing {
  align-self: flex-start;
  color: var(--aero-muted);
  font-size: 12.5px;
  font-style: italic;
}

.aero-quick {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  padding: 0 14px 10px;
}
.aero-quick button {
  border: 1px solid var(--aero-line);
  background: var(--aero-panel-2);
  color: var(--aero-text);
  border-radius: 999px;
  padding: 9px 14px;
  font-family: var(--aero-body-font);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  min-width: 0;
  text-align: center;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.aero-quick button:hover {
  border-color: var(--aero-accent);
  box-shadow: 0 0 12px var(--aero-glow);
}

.aero-form {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--aero-line);
  background: var(--aero-panel);
}
.aero-form textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--aero-line);
  border-radius: 10px;
  padding: 11px 12px;
  font-family: var(--aero-body-font);
  font-size: 12.5px;
  line-height: 1.4;
  background: var(--aero-field-bg);
  color: var(--aero-text);
  max-height: 110px;
  outline: none;
}
.aero-form textarea::placeholder {
  color: var(--aero-muted);
}
.aero-form textarea:focus {
  border-color: var(--aero-accent);
}
.aero-form button {
  width: 42px;
  height: 42px;
  flex: none;
  border: none;
  border-radius: 11px;
  background: var(--aero-launcher-grad);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 0 16px var(--aero-glow);
}
.aero-form button:disabled {
  opacity: 0.45;
  cursor: default;
  box-shadow: none;
}
.aero-send-arrow {
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 11px solid var(--aero-accent-text);
  margin-left: 3px;
}

/* Budget slider (shown when the assistant asks for a budget) */
.aero-budget {
  align-self: stretch;
  margin: 4px 0 2px;
  padding: 12px;
  border: 1px solid var(--aero-line);
  border-radius: var(--aero-radius);
  background: var(--aero-panel-2);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.aero-budget-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}
.aero-budget-tag {
  font-family: var(--aero-tag-font);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--aero-accent);
}
.aero-budget-val {
  font-size: 18px;
  font-weight: 800;
  color: var(--aero-text);
}
.aero-budget-range {
  width: 100%;
  accent-color: var(--aero-accent);
  cursor: pointer;
}
.aero-budget-scale {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: var(--aero-muted);
}
.aero-budget-btn {
  border: none;
  background: var(--aero-launcher-grad);
  color: var(--aero-accent-text);
  border-radius: 10px;
  padding: 10px 14px;
  font-family: var(--aero-body-font);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 14px var(--aero-glow);
}

/* Structured recommendation: aligned configuration bars + catalog matches. */
.aero-rich {
  align-self: stretch;
  min-width: 0;
  padding: 12px;
  border: 1px solid var(--aero-line);
  border-radius: var(--aero-radius);
  background: var(--aero-panel-2);
  display: flex;
  flex-direction: column;
  gap: 11px;
}
.aero-rich-head {
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.aero-rich-tag,
.aero-products-head {
  font-family: var(--aero-tag-font);
  color: var(--aero-accent);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.09em;
}
.aero-rich-title {
  color: var(--aero-text);
  font-size: 12px;
  font-weight: 700;
}
.aero-spec-bars {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.aero-spec-row {
  display: grid;
  grid-template-columns: 54px minmax(32px, 1fr) minmax(82px, 120px);
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.aero-spec-label {
  color: var(--aero-muted);
  font-size: 9px;
  letter-spacing: 0.05em;
}
.aero-spec-track {
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--aero-muted) 22%, transparent);
  overflow: hidden;
}
.aero-spec-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--aero-accent), var(--aero-accent-2));
}
.aero-spec-value {
  min-width: 0;
  overflow: hidden;
  color: var(--aero-text);
  font-size: 10px;
  font-weight: 650;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.aero-spec-summary {
  color: var(--aero-muted);
  font-size: 10px;
  font-weight: 600;
}
.aero-products {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding-top: 10px;
  border-top: 1px solid var(--aero-line);
}
.aero-product {
  position: relative; /* anchors .aero-product-link, the stretched product link */
  min-width: 0;
  padding: 9px;
  border: 1px solid var(--aero-line);
  border-radius: 10px;
  background: var(--aero-field-bg);
  display: flex;
  flex-direction: column;
  gap: 5px;
  /* The card itself is the <a> to the product, so undo the default link
     styling — it should read as a card, not as blue underlined text. */
  color: inherit;
  text-decoration: none;
  transition:
    border-color 0.18s ease,
    transform 0.18s ease,
    box-shadow 0.18s ease;
}
.aero-product:hover,
.aero-product:focus-within {
  border-color: var(--aero-accent);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4), 0 0 12px var(--aero-glow);
}

/* Full spec sheet — collapsed until the cursor lands on the product. */
.aero-product-detail {
  display: grid;
  gap: 3px;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition:
    max-height 0.24s ease,
    opacity 0.18s ease,
    margin-top 0.24s ease;
}
.aero-product:hover .aero-product-detail,
.aero-product:focus-within .aero-product-detail {
  max-height: 260px;
  opacity: 1;
  margin-top: 3px;
}
.aero-detail-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.aero-detail-key {
  flex: 0 0 52px;
  font-size: 9px;
  letter-spacing: 0.1em;
  color: var(--aero-accent);
}
.aero-detail-val {
  flex: 1;
  min-width: 0;
  color: var(--aero-muted);
  font-size: 10px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

@media (hover: none) {
  .aero-product-detail {
    max-height: none;
    opacity: 1;
    margin-top: 3px;
  }
}
.aero-product-top,
.aero-product-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.aero-product-name {
  flex: 1;
  min-width: 0;
  color: var(--aero-text);
  font-size: 12px;
  font-weight: 750;
  line-height: 1.3;
}
.aero-fit,
.aero-close-fit {
  flex: none;
  padding: 3px 5px;
  border-radius: 4px;
  font-size: 8px;
  font-weight: 800;
}
.aero-fit {
  background: var(--aero-accent);
  color: var(--aero-accent-text);
}
.aero-close-fit {
  border: 1px solid var(--aero-line);
  color: var(--aero-muted);
}
.aero-product-specs,
.aero-product-note {
  color: var(--aero-muted);
  font-size: 10px;
  line-height: 1.4;
  overflow-wrap: anywhere;
}
.aero-product-meta {
  flex-wrap: wrap;
  color: var(--aero-muted);
  font-size: 10px;
}
.aero-product-meta strong {
  color: var(--aero-text);
}
/* The product link, stretched over the whole card so every part of it is
   clickable, while real controls inside it (the offers button, the T&C links)
   sit above it on .aero-offer-cell's stacking context and keep their clicks. */
.aero-product-link {
  position: absolute;
  inset: 0;
  z-index: 0;
  border-radius: inherit;
}
/* The offers strip at the bottom of the card. */
.aero-offer-cell {
  position: relative;
  z-index: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  margin-top: 2px;
  padding-top: 6px;
  border-top: 1px dashed var(--aero-line);
}
.aero-offer-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  width: 100%;
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  font: inherit;
  text-align: left;
}
.aero-offer-toggle:hover {
  opacity: 0.78;
}
.aero-offer-tag {
  flex: 1;
  min-width: 0;
  color: var(--aero-accent);
  font-size: 10px;
  font-weight: 800;
}
.aero-offer-hint {
  color: var(--aero-muted);
  font-size: 9.5px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.aero-offer-caret {
  color: var(--aero-accent);
  font-size: 9.5px;
  line-height: 1;
  transition: transform 0.18s ease;
}
.aero-offer-caret-open {
  transform: rotate(180deg);
}
.aero-offer-panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 5px;
  padding: 9px 10px;
  background: var(--aero-panel-2);
  border: 1px solid var(--aero-line);
  border-radius: 7px;
}
.aero-offer-item {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.aero-offer-heading {
  color: var(--aero-accent);
  font-size: 10px;
  font-weight: 750;
  line-height: 1.35;
}
.aero-offer-content {
  margin: 0;
  padding-left: 14px;
  color: var(--aero-muted);
  font-size: 9.5px;
  line-height: 1.45;
  /* Long T&C lines and URLs must wrap rather than widen the card. */
  overflow-wrap: anywhere;
}
.aero-offer-content li {
  margin-bottom: 3px;
}
.aero-offer-link {
  color: var(--aero-accent);
  font-weight: 650;
  text-decoration: underline;
  text-underline-offset: 2px;
}
/* A keyboard user gets the same affordance the mouse hover gives. */
.aero-product:focus-visible {
  outline: 2px solid var(--aero-accent);
  outline-offset: 2px;
}

/* ---------- animations ---------- */
@keyframes aero-status-blink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.3;
  }
}
@keyframes aero-msg-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (prefers-reduced-motion: reduce) {
  #aero-widget-root *,
  #aero-widget-root *::before,
  #aero-widget-root *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

/* ---------- tablet: a touch wider, still floating ---------- */
@media (max-width: 820px) and (min-width: 561px) {
  .aero-panel {
    width: min(420px, calc(100vw - 32px));
    height: min(680px, calc(100dvh - 110px));
  }
}

/* ---------- phone: full-screen panel ---------- */
@media (max-width: 560px) {
  #aero-widget-root {
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
  }

  /* Panel is already full-screen here — maximise toggle is redundant. */
  .aero-max {
    display: none;
  }

  .aero-panel,
  .aero-panel--max {
    position: fixed;
    inset: 0;
    width: 100vw;
    width: 100dvw;
    height: 100vh;
    height: 100dvh;
    max-width: none;
    max-height: none;
    margin: 0;
    border: none;
    border-radius: 0;
  }
  .aero-header {
    padding-top: max(12px, env(safe-area-inset-top));
  }
  .aero-form {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
  /* 16px input stops iOS zooming in on focus */
  .aero-form textarea {
    font-size: 16px;
  }

  .aero-spec-row {
    grid-template-columns: 46px minmax(28px, 1fr) minmax(74px, 96px);
    gap: 5px;
  }
}

/* ---------- landscape phone ---------- */
@media (max-height: 480px) and (max-width: 900px) {
  .aero-panel {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    border: none;
    border-radius: 0;
  }
}

/* Any touch device: finger-sized controls. */
@media (pointer: coarse) {
  .aero-form button {
    min-width: 44px;
    min-height: 44px;
  }
  .aero-quick button,
  .aero-budget-btn {
    min-height: 40px;
  }
  .aero-budget-range {
    height: 12px;
  }
}
