/* Ask ZAP — "Ink & Signal".
   A dark, editorial-technical console that floats over the light admin shell.
   One accent (#63BEAE, the topbar brand teal from layouts/header.php) carries
   every signal: focus, send, thinking, live. Type is Jost for the voice and
   Source Sans Pro for reading, both already loaded by assets/css/core.css.
   No new font requests, no n8n bundle styles. */

.ask-zap {
  --az-ink: #0d1420;
  --az-ink-2: #131c2b;
  --az-ink-3: #1b2637;
  --az-line: rgba(255, 255, 255, 0.09);
  --az-line-strong: rgba(255, 255, 255, 0.16);
  --az-text: #e9eef6;
  --az-muted: #93a2b8;
  --az-faint: #6b7a91;
  --az-accent: #63beae;
  --az-accent-hot: #8cebd7;
  --az-accent-deep: #2f7d71;
  --az-danger: #f08a7a;

  --az-display: 'Jost', 'Noto Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;
  --az-body: 'Source Sans Pro', 'Noto Sans', 'Helvetica Neue', Helvetica, Arial, sans-serif;

  --az-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --az-ease-in: cubic-bezier(0.55, 0, 0.45, 1);

  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 9999;
  font-family: var(--az-body);
  color: var(--az-text);
  -webkit-font-smoothing: antialiased;
}

/* The mark. One glyph, used at three scales, so identity stays constant.
   Sized in em so each container's font size drives it: 16px header avatar,
   11px answer row, 24px launcher. Ink on teal, so it inherits the dark
   colour the mark boxes already set. */
.ask-zap .az-mark-zap {
  display: block;
  width: 1.15em;
  height: 1.15em;
  color: var(--az-ink);
}

/* ------------------------------------------------------------- launcher */

.ask-zap .az-launcher {
  position: relative;
  width: 56px;
  height: 56px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  display: grid;
  place-items: center;
  /* The launcher floats free of the panel, so it needs its own shadow. */
  box-shadow: 0 14px 34px rgba(9, 16, 26, 0.34);
  transition: transform 0.42s var(--az-ease);
  animation: az-launcher-in 0.62s var(--az-ease) both;
}

.ask-zap .az-launcher:hover,
.ask-zap .az-launcher:focus-visible {
  transform: translateY(-3px) scale(1.04);
}

.ask-zap .az-launcher:active {
  transform: translateY(0) scale(0.97);
}

.ask-zap .az-mark-box {
  position: relative;
  z-index: 2;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--az-accent-hot), var(--az-accent) 52%, var(--az-accent-deep));
  /* The bubble is ink on teal. Without this it would inherit the light text
     colour and disappear into the circle. */
  color: var(--az-ink);
}

/* A touch more presence on hover, so the launcher feels pressable. */
.ask-zap .az-launcher-icon {
  display: block;
  width: 24px;
  height: 24px;
  color: var(--az-ink);
  transition: transform 0.42s var(--az-ease);
}

.ask-zap .az-launcher:hover .az-launcher-icon,
.ask-zap .az-launcher:focus-visible .az-launcher-icon {
  transform: scale(1.08);
}

/* A slow teal breath, so an idle launcher still reads as "live". */
.ask-zap .az-launcher-halo {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 1px solid var(--az-accent);
  animation: az-halo 2.9s var(--az-ease) infinite;
  pointer-events: none;
}

.ask-zap .az-launcher-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid var(--az-line-strong);
  transition: transform 0.42s var(--az-ease), opacity 0.42s var(--az-ease);
}

.ask-zap .az-launcher:hover .az-launcher-ring {
  transform: scale(1.08);
  border-color: var(--az-accent);
}

@keyframes az-launcher-in {
  from { opacity: 0; transform: translateY(16px) scale(0.86); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes az-halo {
  0%   { transform: scale(1);    opacity: 0.5; }
  70%  { transform: scale(1.34); opacity: 0; }
  100% { transform: scale(1.34); opacity: 0; }
}

/* ---------------------------------------------------------------- panel */

.ask-zap .az-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 1;
}

.ask-zap .az-panel[hidden] {
  display: none;
}

.ask-zap .az-scrim {
  position: fixed;
  inset: 0;
  background: rgba(9, 16, 26, 0.42);
  opacity: 0;
  transition: opacity 0.32s var(--az-ease);
}

.ask-zap .az-sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 396px;
  max-width: calc(100vw - 40px);
  height: min(620px, calc(100vh - 40px));
  border: 1px solid var(--az-line);
  border-radius: 20px;
  background: linear-gradient(180deg, var(--az-ink-2), var(--az-ink) 62%);
  box-shadow: 0 34px 80px rgba(6, 11, 19, 0.5), 0 2px 0 rgba(255, 255, 255, 0.04) inset;
  overflow: hidden;
  opacity: 0;
  transform: translateY(18px) scale(0.965);
  transform-origin: bottom right;
  transition: opacity 0.3s var(--az-ease), transform 0.42s var(--az-ease);
}

.ask-zap .az-panel.is-open .az-sheet {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.ask-zap .az-panel.is-open .az-scrim {
  opacity: 1;
}

/* Only the header lifts into place. The rest is already composed. */
.ask-zap .az-panel.is-open .az-header {
  animation: az-head-in 0.5s var(--az-ease) both;
}

@keyframes az-head-in {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* --------------------------------------------------------------- header */

.ask-zap .az-header {
  position: relative;
  flex: 0 0 auto;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--az-line);
  background: linear-gradient(135deg, rgba(99, 190, 174, 0.12), rgba(19, 28, 43, 0) 62%);
}

/* One soft light source in the top left, the way a desk lamp would sit. */
.ask-zap .az-header-glow {
  position: absolute;
  top: -60px;
  left: -30px;
  width: 190px;
  height: 150px;
  background: radial-gradient(closest-side, rgba(99, 190, 174, 0.28), rgba(99, 190, 174, 0));
  pointer-events: none;
}

.ask-zap .az-title-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: 11px;
}

.ask-zap .az-avatar {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  display: grid;
  place-items: center;
  font-size: 16px;
  background: linear-gradient(145deg, var(--az-accent-hot), var(--az-accent) 55%, var(--az-accent-deep));
  box-shadow: 0 6px 16px rgba(47, 125, 113, 0.4);
}

.ask-zap .az-titles {
  flex: 1 1 auto;
  min-width: 0;
}

.ask-zap .az-title {
  margin: 0;
  font-family: var(--az-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--az-text);
  line-height: 1.2;
}

/* Mirrors the topbar logo span in layouts/header.php. */
.ask-zap .az-brand {
  font-family: var(--az-display);
  font-weight: 700;
  font-size: 0.86em;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--az-accent);
  white-space: nowrap;
}

.ask-zap .az-subtitle {
  margin: 2px 0 0;
  font-size: 11.5px;
  line-height: 1.35;
  color: var(--az-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ask-zap .az-header-actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.ask-zap .az-icon-btn {
  width: 30px;
  height: 30px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--az-line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--az-muted);
  cursor: pointer;
  transition: color 0.2s, background 0.2s, border-color 0.2s, transform 0.2s var(--az-ease);
}

.ask-zap .az-icon-btn:hover,
.ask-zap .az-icon-btn:focus-visible {
  color: var(--az-accent-hot);
  border-color: rgba(99, 190, 174, 0.5);
  background: rgba(99, 190, 174, 0.12);
  transform: translateY(-1px);
}

.ask-zap .az-close:hover,
.ask-zap .az-close:focus-visible {
  color: var(--az-danger);
  border-color: rgba(240, 138, 122, 0.45);
  background: rgba(240, 138, 122, 0.1);
}

/* New conversation spins once on hover, then the icon is a spark again. */
.ask-zap .ask-zap-new:hover svg,
.ask-zap .ask-zap-new:focus-visible svg {
  animation: az-spin 0.62s var(--az-ease);
}

@keyframes az-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(-360deg); }
}

/* A hairline that fills while n8n is working. The only progress cue. */
.ask-zap .az-meter {
  margin: 12px -16px -12px;
  height: 2px;
  background: rgba(255, 255, 255, 0.05);
  overflow: hidden;
}

.ask-zap .az-meter-fill {
  display: block;
  height: 100%;
  width: 0;
  background: linear-gradient(90deg, transparent, var(--az-accent), var(--az-accent-hot));
  opacity: 0;
  transition: opacity 0.24s;
}

.ask-zap.is-busy .az-meter-fill {
  opacity: 1;
  animation: az-meter 1.25s var(--az-ease-in) infinite;
}

@keyframes az-meter {
  from { width: 0;    transform: translateX(0); }
  to   { width: 100%; transform: translateX(0); }
}

/* ------------------------------------------------------------- messages */

.ask-zap .az-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: var(--az-line-strong) transparent;
}

.ask-zap .az-log::-webkit-scrollbar { width: 6px; }
.ask-zap .az-log::-webkit-scrollbar-thumb {
  background: var(--az-line-strong);
  border-radius: 999px;
}

.ask-zap .az-row {
  display: flex;
  gap: 9px;
  /* Each turn arrives on its own, so the thread reads as a conversation. */
  animation: az-row-in 0.36s var(--az-ease) both;
}

@keyframes az-row-in {
  from { opacity: 0; transform: translateY(9px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ask-zap .az-row-user {
  justify-content: flex-end;
}

.ask-zap .az-row-avatar {
  flex: 0 0 auto;
  width: 22px;
  height: 22px;
  margin-top: 2px;
  border-radius: 7px;
  display: grid;
  place-items: center;
  font-size: 11px;
  background: linear-gradient(145deg, var(--az-accent-hot), var(--az-accent) 55%, var(--az-accent-deep));
}

.ask-zap .az-bubble {
  max-width: 84%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.5;
  word-break: break-word;
  overflow-wrap: anywhere;
}

/* The user's turn is a quiet solid chip, pushed to the right. */
.ask-zap .az-bubble-user {
  background: rgba(99, 190, 174, 0.15);
  border: 1px solid rgba(99, 190, 174, 0.26);
  border-bottom-right-radius: 5px;
  color: #eaf7f4;
}

.ask-zap .az-bubble-user p { margin: 0; }

/* The answer is a raised card with a teal edge: the focal surface. */
.ask-zap .az-bubble-bot {
  background: var(--az-ink-3);
  border: 1px solid var(--az-line);
  border-left: 2px solid var(--az-accent);
  border-bottom-left-radius: 5px;
  box-shadow: 0 8px 20px rgba(6, 11, 19, 0.28);
}

.ask-zap .az-answer > :first-child { margin-top: 0; }
.ask-zap .az-answer > :last-child  { margin-bottom: 0; }

.ask-zap .az-answer p {
  margin: 0 0 8px;
  color: var(--az-text);
}

.ask-zap .az-answer strong {
  font-weight: 600;
  color: #fff;
}

.ask-zap .az-answer code {
  padding: 1px 5px;
  border-radius: 5px;
  background: rgba(99, 190, 174, 0.14);
  color: var(--az-accent-hot);
  font-family: ui-monospace, Menlo, Consolas, 'DejaVu Sans Mono', monospace;
  font-size: 0.88em;
}

.ask-zap .az-answer ul {
  margin: 0 0 8px;
  padding-left: 18px;
}

.ask-zap .az-answer li { margin: 0 0 4px; }

.ask-zap .az-answer li::marker { color: var(--az-accent); }

/* Thinking state: three dots, staggered, never a frozen spinner. */
.ask-zap .az-bubble-pending {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 13px 15px;
}

.ask-zap .az-bubble-pending span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--az-accent);
  animation: az-dot 1.15s var(--az-ease-in) infinite;
}

.ask-zap .az-bubble-pending span:nth-child(2) { animation-delay: 0.16s; }
.ask-zap .az-bubble-pending span:nth-child(3) { animation-delay: 0.32s; }

@keyframes az-dot {
  0%, 100% { transform: translateY(0);    opacity: 0.32; }
  40%      { transform: translateY(-5px); opacity: 1; }
}

.ask-zap .az-row-system {
  justify-content: center;
  font-size: 11.5px;
  color: var(--az-faint);
  text-align: center;
  padding: 0 8px;
}

/* -------------------------------------------------------------- composer */

.ask-zap .az-footer {
  flex: 0 0 auto;
  padding: 10px 14px 12px;
  border-top: 1px solid var(--az-line);
  background: rgba(6, 11, 19, 0.4);
}

.ask-zap .az-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 7px 7px 7px 12px;
  border: 1px solid var(--az-line);
  border-radius: 13px;
  background: var(--az-ink-3);
  transition: border-color 0.24s, box-shadow 0.24s, background 0.24s;
}

.ask-zap .az-composer:focus-within {
  border-color: rgba(99, 190, 174, 0.55);
  background: #1e2a3d;
  box-shadow: 0 0 0 3px rgba(99, 190, 174, 0.13);
}

.ask-zap .az-input {
  flex: 1 1 auto;
  min-width: 0;
  max-height: 132px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--az-text);
  font-family: var(--az-body);
  font-size: 13.5px;
  line-height: 1.5;
  resize: none;
  overflow-y: auto;
  scrollbar-width: thin;
}

.ask-zap .az-input::placeholder { color: var(--az-faint); }

.ask-zap .az-input:focus { outline: none; }

.ask-zap .az-input:disabled { opacity: 0.55; cursor: not-allowed; }

.ask-zap .az-send {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  display: grid;
  place-items: center;
  background: linear-gradient(145deg, var(--az-accent-hot), var(--az-accent) 55%, var(--az-accent-deep));
  color: var(--az-ink);
  cursor: pointer;
  transition: transform 0.22s var(--az-ease), opacity 0.22s, box-shadow 0.22s;
}

.ask-zap .az-send:not(:disabled) {
  box-shadow: 0 6px 16px rgba(47, 125, 113, 0.42);
}

.ask-zap .az-send:not(:disabled):hover {
  transform: translateY(-1px) scale(1.05);
}

.ask-zap .az-send:not(:disabled):active {
  transform: translateY(0) scale(0.94);
}

.ask-zap .az-send:disabled {
  opacity: 0.32;
  cursor: not-allowed;
}

/* While busy the send arrow turns into a sweeping ring. */
.ask-zap.is-busy .az-send svg {
  animation: az-send-spin 1.4s linear infinite;
}

@keyframes az-send-spin {
  to { transform: rotate(360deg); }
}

.ask-zap .az-note {
  margin: 8px 0 0;
  font-size: 10.5px;
  letter-spacing: 0.03em;
  text-align: center;
  color: var(--az-faint);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The AI disclaimer sits under the scope note. It wraps rather than clips,
   because the whole point is that it gets read. */
.ask-zap .az-disclaimer {
  margin: 4px 0 0;
  font-size: 10px;
  line-height: 1.45;
  letter-spacing: 0.02em;
  text-align: center;
  color: var(--az-faint);
  opacity: 0.82;
  text-wrap: balance;
}

/* ----------------------------------------------------------- small print */

.ask-zap .az-launcher:focus-visible,
.ask-zap .az-panel :focus-visible {
  outline: 2px solid var(--az-accent-hot);
  outline-offset: 2px;
}

@media (max-width: 480px) {
  .ask-zap .az-sheet {
    width: calc(100vw - 24px);
    height: min(76vh, calc(100vh - 24px));
  }
  .ask-zap .az-scrim { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .ask-zap *,
  .ask-zap *::before,
  .ask-zap *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}

@media print {
  .ask-zap {
    display: none !important;
  }
}
