/* Sporetag Assistant (public/static/app/assistant.js): the header button, the
   panel on the right (a sheet from the bottom on phones), messages, change
   cards and drafts. Colors come from the tokens in site.css only, so light and
   dark match the rest of the app; ratios are the tokens' own. */

/* ---------------- the header button ---------------- */
.as-open {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 34px;
  padding: 0 12px 0 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--line-control);
  border-radius: 999px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.12s ease, border-color 0.12s ease;
}
.as-open[hidden] {
  display: none;
}
.as-open svg {
  color: var(--accent);
}
.as-open:hover {
  background: var(--bg-hover);
  border-color: var(--line-strong);
}
.as-open[aria-expanded='true'] {
  background: var(--accent-soft);
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
}
.as-open:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* The client bar's nav is a row of buttons; keep ours in step with them. */
.client-nav .as-open {
  min-height: var(--btn-h-sm);
}

/* ---------------- the panel ---------------- */
.as-scrim {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: var(--scrim);
}
.as-scrim[hidden] {
  display: none;
}

.as-panel {
  --as-w: 420px;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 71;
  display: flex;
  flex-direction: column;
  width: var(--as-w);
  max-width: 100vw;
  background: var(--bg-panel);
  border-left: 1px solid var(--line);
  box-shadow: var(--shadow-sheet);
  transform: translateX(100%);
  transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.as-panel[hidden] {
  display: none;
}
.as-panel.is-open {
  transform: none;
}

/* Wide screens keep the page beside the panel instead of under it. */
@media (min-width: 1180px) {
  body.as-on {
    padding-right: 420px;
  }
  body.as-on .as-panel {
    box-shadow: var(--shadow-panel);
  }
}

.as-grab {
  display: none;
}

.as-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 12px 10px 18px;
}
.as-head-main {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.as-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  color: var(--accent);
  background: var(--accent-soft);
  border-radius: 10px;
}
.as-mark svg {
  width: 18px;
  height: 18px;
}
.as-head-text {
  min-width: 0;
}
.as-title {
  margin: 0;
  font-size: 15.5px;
  font-weight: 650;
  line-height: 1.25;
  letter-spacing: -0.005em;
}
.as-sub {
  margin: 1px 0 0;
  overflow: hidden;
  font-size: 12.5px;
  color: var(--text-faint);
  white-space: nowrap;
  text-overflow: ellipsis;
}
.as-head-actions {
  display: flex;
  gap: 2px;
}
.as-icon {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--text-dim);
  background: transparent;
  border: 0;
  border-radius: 9px;
  cursor: pointer;
}
.as-icon:hover {
  color: var(--text);
  background: var(--bg-hover);
}
.as-icon:focus-visible,
.as-tab:focus-visible,
.as-chip:focus-visible,
.as-send:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* Chat, Changes, Drafts: a quiet segmented row. */
.as-tabs {
  display: flex;
  gap: 4px;
  margin: 0 18px 6px;
  padding: 3px;
  background: var(--bg-tint);
  border-radius: 10px;
}
.as-tab {
  flex: 1;
  min-height: 32px;
  padding: 0 10px;
  font: inherit;
  font-size: 13px;
  font-weight: 550;
  color: var(--text-dim);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}
.as-tab[hidden] {
  display: none;
}
.as-tab[aria-selected='true'] {
  color: var(--text);
  background: var(--bg-raised);
  box-shadow: 0 1px 2px rgba(60, 45, 20, 0.08);
}

.as-body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
}
.as-log,
.as-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 18px 18px;
}
.as-log[hidden],
.as-list[hidden] {
  display: none;
}

/* ---------------- messages ---------------- */
.as-msg {
  font-size: 14.5px;
  line-height: 1.55;
  overflow-wrap: anywhere;
}
.as-msg p {
  margin: 0;
}
.as-user {
  align-self: flex-end;
  max-width: 86%;
  padding: 9px 13px;
  color: var(--text);
  background: var(--accent-soft);
  border-radius: 14px 14px 4px 14px;
  white-space: pre-wrap;
}
.as-bot {
  align-self: stretch;
  color: var(--text);
}
.as-rich p + p,
.as-rich p + ul,
.as-rich p + ol,
.as-rich ul + p,
.as-rich ol + p {
  margin-top: 8px;
}
.as-rich ul,
.as-rich ol {
  margin: 4px 0 0;
  padding-left: 20px;
}
.as-rich li + li {
  margin-top: 3px;
}
.as-rich a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.as-rich code {
  padding: 1px 5px;
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--bg-tint);
  border-radius: 5px;
}

.as-tool {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 8px;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.as-tool-dot {
  width: 7px;
  height: 7px;
  background: var(--accent);
  border-radius: 50%;
  animation: as-pulse 1s ease-in-out infinite;
}
.as-tool.is-done .as-tool-dot {
  background: var(--chip-ok-fg);
  animation: none;
}

.as-typing {
  display: inline-flex;
  align-self: flex-start;
  gap: 4px;
  padding: 6px 0;
}
.as-typing span {
  width: 6px;
  height: 6px;
  background: var(--text-faint);
  border-radius: 50%;
  animation: as-pulse 1.1s ease-in-out infinite;
}
.as-typing span:nth-child(2) {
  animation-delay: 0.15s;
}
.as-typing span:nth-child(3) {
  animation-delay: 0.3s;
}
@keyframes as-pulse {
  0%,
  100% {
    opacity: 0.35;
  }
  50% {
    opacity: 1;
  }
}

.as-note {
  margin: 0;
  font-size: 13px;
  color: var(--text-faint);
}
.as-note.is-error {
  padding: 8px 12px;
  color: var(--error-text);
  background: var(--error-bg);
  border: 1px solid var(--error-line);
  border-radius: 10px;
}

.as-empty {
  margin: auto 0;
  padding: 12px 4px 4px;
  text-align: left;
}
.as-empty p {
  margin: 0;
  font-size: 14px;
  color: var(--text-dim);
}
.as-empty .as-empty-title {
  margin-bottom: 6px;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.015em;
  color: var(--text);
}

/* ---------------- change cards ---------------- */
.as-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  background: var(--bg-raised);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
}
.as-card[data-status='pending'] {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}
.as-card.is-busy {
  opacity: 0.7;
}
.as-card-head {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.as-card-eyebrow,
.as-card-when {
  margin: 0;
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.as-card-when {
  color: var(--text-faint);
}
.as-card[data-status='applied'] .as-card-eyebrow {
  color: var(--chip-ok-fg);
}
.as-card[data-status='cancelled'] .as-card-eyebrow,
.as-card[data-status='undone'] .as-card-eyebrow {
  color: var(--text-faint);
}
.as-card[data-status='failed'] .as-card-eyebrow {
  color: var(--danger-fg);
}
.as-card-title {
  margin: 0;
  font-size: 15px;
  font-weight: 650;
  line-height: 1.3;
}
.as-card-rows {
  display: grid;
  margin: 0;
  border-top: 1px solid var(--line);
}
.as-card-rows > div {
  display: grid;
  grid-template-columns: minmax(84px, 34%) 1fr;
  gap: 10px;
  padding: 7px 0;
  border-bottom: 1px solid var(--line);
}
.as-card-rows dt {
  font-size: 12.5px;
  color: var(--text-faint);
}
.as-card-rows dd {
  margin: 0;
  font-size: 13.5px;
  color: var(--text);
  overflow-wrap: anywhere;
}
.as-card-note,
.as-card-warn,
.as-card-status {
  margin: 0;
  font-size: 13px;
  color: var(--text-dim);
}
.as-card-warn {
  padding: 8px 10px;
  color: var(--chip-warn-fg);
  background: var(--chip-warn-bg);
  border: 1px solid var(--chip-warn-line);
  border-radius: 9px;
}
.as-card-status {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--text);
}
.as-card-status svg {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin-top: 2px;
  color: var(--chip-ok-fg);
}
.as-card-status.is-error {
  color: var(--danger-fg);
}
.as-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.as-card-actions .btn {
  min-height: 36px;
}
.as-card-edit {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 2px;
}
.as-card-edit[hidden] {
  display: none;
}
.as-card-edit .field-label {
  margin-top: 4px;
  font-size: 12.5px;
}

/* Email and text drafts, drawn like the thing itself. */
.as-mail {
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 11px;
}
.as-mail-head {
  padding: 10px 12px;
  background: var(--bg-tint);
  border-bottom: 1px solid var(--line);
}
.as-mail-subject {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
}
.as-mail-preview {
  margin: 2px 0 0;
  font-size: 12.5px;
  color: var(--text-faint);
}
.as-mail-body {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  font-size: 13.5px;
  line-height: 1.55;
}
.as-mail-body h4 {
  margin: 0;
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.as-mail-body p {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.as-mail-btn {
  display: inline-block;
  padding: 7px 14px;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 8px;
}
.as-sms {
  display: flex;
  padding: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 11px;
}
.as-sms-bubble {
  max-width: 88%;
  margin: 0;
  padding: 9px 12px;
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  background: var(--bg-tint);
  border-radius: 16px 16px 16px 4px;
}
.as-copy {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
}
.as-copy:has(> :nth-child(2):last-child) {
  grid-template-columns: minmax(0, 1fr) auto;
}
.as-select {
  min-width: 0;
  min-height: 34px;
  padding: 0 28px 0 10px;
  font: inherit;
  font-size: 13px;
  color: var(--text);
  background: var(--bg-input) var(--select-chevron) no-repeat right 8px center / 14px;
  border: 1px solid var(--line-control);
  border-radius: 8px;
  appearance: none;
}

.as-setting {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--bg-tint);
  border-radius: 12px;
}
.as-setting label {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  color: var(--text-dim);
}
.as-setting strong {
  font-size: 13.5px;
  color: var(--text);
}
.as-switch-input {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
}

/* ---------------- bottom: starters, composer, foot ---------------- */
.as-bottom {
  padding: 10px 14px calc(12px + env(safe-area-inset-bottom));
  background: var(--bg-panel);
  border-top: 1px solid var(--line);
}
.as-starters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}
.as-starters[hidden] {
  display: none;
}
.as-chip {
  min-height: 34px;
  padding: 6px 12px;
  font: inherit;
  font-size: 13px;
  line-height: 1.3;
  text-align: left;
  color: var(--text);
  background: var(--bg-raised);
  border: 1px solid var(--line-control);
  border-radius: 999px;
  cursor: pointer;
}
.as-chip:hover {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line-control));
  background: var(--bg-hover);
}
.as-compose {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 6px 6px 6px 12px;
  background: var(--bg-input);
  border: 1px solid var(--line-control);
  border-radius: 14px;
}
.as-compose[hidden] {
  display: none;
}
.as-compose:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.as-input {
  flex: 1;
  min-height: 34px;
  max-height: 160px;
  padding: 7px 0;
  font: inherit;
  font-size: 15px;
  line-height: 1.4;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  resize: none;
}
.as-input::placeholder {
  color: var(--text-faint);
}
.as-send {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  color: var(--accent-ink);
  background: var(--accent);
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}
.as-send:hover {
  background: var(--accent-hover);
}
.as-send:disabled {
  opacity: 0.45;
  cursor: default;
}
.as-foot {
  margin: 8px 2px 0;
  font-size: 11.5px;
  color: var(--text-faint);
}
.as-foot[hidden] {
  display: none;
}

/* ---------------- admin totals ---------------- */
.as-adm-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
  margin: 16px 0;
}
.as-adm-tile p {
  margin: 0;
}
.as-adm-label {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.as-adm-num {
  margin: 4px 0 !important;
  font-family: var(--serif);
  font-size: 30px;
  font-variant-numeric: tabular-nums;
}

/* ---------------- phones: a sheet from the bottom ---------------- */
@media (max-width: 720px) {
  .as-panel {
    top: auto;
    left: 0;
    width: auto;
    height: min(88dvh, 760px);
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
  }
  .as-panel.is-open {
    transform: none;
  }
  .as-grab {
    display: block;
    width: 38px;
    height: 4px;
    margin: 8px auto 0;
    background: var(--line-strong);
    border-radius: 999px;
  }
  .as-head {
    padding: 8px 8px 8px 16px;
  }
  .as-tabs {
    margin: 0 16px 6px;
  }
  .as-log,
  .as-list {
    padding: 14px 16px 16px;
  }
  /* 16px stops iOS from zooming into the field. */
  .as-input {
    font-size: 16px;
  }
  .as-card-actions .btn {
    min-height: 40px;
  }
  /* The format picker takes its own row; the copy buttons share the next. */
  .as-copy {
    grid-template-columns: 1fr 1fr;
  }
  .as-copy .as-select {
    grid-column: 1 / -1;
  }
  .as-copy:has(> :nth-child(2):last-child) {
    grid-template-columns: 1fr;
  }
  /* The page under the sheet does not scroll (or show a scrollbar beside it). */
  :root:has(body.as-on),
  body.as-on {
    overflow: hidden;
  }
}

@media (max-width: 480px) {
  .as-open {
    width: 36px;
    min-height: 36px;
    padding: 0;
    justify-content: center;
  }
  .as-open-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  .as-panel {
    transition: none;
  }
  .as-tool-dot,
  .as-typing span {
    animation: none;
  }
}
