/* ═══ STUDIOHAUS PORTAL — Assistant (admin chat) ═══
   Round button bottom right, chat panel above it. Monochrome, portal tokens,
   both themes. Below modals (z 500) so a modal opened from a link sits on top. */

.as-root { --as-gap: 20px; }

.as-fab {
  position: fixed;
  right: var(--as-gap);
  bottom: var(--as-gap);
  z-index: 450;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 0;
  background: var(--text);
  color: var(--bg);
  display: grid;
  place-items: center;
  cursor: pointer;
  box-shadow: 0 1px 2px rgba(0,0,0,0.12), 0 10px 30px rgba(0,0,0,0.22), inset 0 0 0 1px rgba(255,255,255,0.08);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}
.as-fab:hover { transform: translateY(-2px); box-shadow: 0 2px 4px rgba(0,0,0,0.14), 0 16px 36px rgba(0,0,0,0.28), inset 0 0 0 1px rgba(255,255,255,0.1); }
.as-fab:active { transform: translateY(0) scale(0.96); }
.as-fab:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }
.as-fab-icon { grid-area: 1 / 1; display: grid; place-items: center; transition: opacity 0.2s ease, transform 0.25s ease; }
.as-fab-open svg { width: 24px; height: 24px; }
.as-fab-close svg { width: 18px; height: 18px; }
.as-fab-close { opacity: 0; transform: rotate(-90deg) scale(0.6); }
.as-fab:hover .as-fab-open svg { transform: rotate(12deg); }
.as-fab-open svg { transition: transform 0.3s ease; }
.as-root.is-open .as-fab-open { opacity: 0; transform: rotate(90deg) scale(0.6); }
.as-root.is-open .as-fab-close { opacity: 1; transform: none; }
.as-root.is-open .as-fab { background: var(--bg-elevated); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.1), 0 8px 24px rgba(0,0,0,0.16), inset 0 0 0 1px var(--border-hover); }
@media (prefers-reduced-motion: reduce) { .as-fab, .as-fab-icon, .as-fab-open svg { transition: none; } }

/* Team views: a shoot sheet or edit panel (z 400/401) opened from a link sits on top */
body:has(.shoot-sheet) .as-root.as-team .as-fab,
body:has(.shoot-sheet) .as-root.as-team .as-panel { z-index: 399; }

/* The upload tray takes the same corner; the button steps left of it */
body:has(.up-tray) .as-fab { right: calc(var(--as-gap) + 316px); }

.as-panel {
  position: fixed;
  right: var(--as-gap);
  bottom: calc(var(--as-gap) + 60px);
  z-index: 450;
  width: 400px;
  max-width: calc(100vw - 32px);
  height: min(600px, calc(100vh - 120px));
  height: min(600px, calc(100dvh - 120px));
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0,0,0,0.35);
  overflow: hidden;
  font-family: var(--font);
  animation: asIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}
.as-panel[hidden] { display: none; }
@keyframes asIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.as-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: 14px 14px 14px 18px;
  border-bottom: 1px solid var(--border);
}
/* All caps tracked heading, as the portal's section titles */
.as-title {
  font-size: var(--fs-xs);
  font-weight: var(--fw-semi);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-60);
}
.as-head-actions { display: flex; align-items: center; gap: var(--s-1); }
.as-clear,
.as-close {
  background: none;
  border: 0;
  color: var(--text-45);
  cursor: pointer;
  font-family: var(--font);
  font-size: var(--fs-sm);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  display: flex;
  align-items: center;
}
.as-clear:hover,
.as-close:hover { color: var(--text); background: var(--bg-card-hover); }
.as-clear[hidden] { display: none; }
.as-close svg { width: 16px; height: 16px; }

.as-list {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--s-4);
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
}

.as-empty { margin: auto 0 0; display: flex; flex-direction: column; gap: var(--s-4); }
.as-empty-text { font-size: var(--fs-sm); line-height: 1.5; color: var(--text-45); }
.as-chips { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.as-chip {
  background: var(--bg-card);
  border: 1px solid var(--border-hover);
  color: var(--text);
  font-family: var(--font);
  font-size: var(--fs-sm);
  padding: 7px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.as-chip:hover { background: var(--bg-card-hover); border-color: var(--text-20); }

.as-msg {
  max-width: 88%;
  font-size: var(--fs-base);
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.as-user {
  align-self: flex-end;
  background: var(--text);
  color: var(--bg);
  padding: 9px 13px;
  border-radius: var(--radius) var(--radius) 4px var(--radius);
}
.as-bot {
  align-self: flex-start;
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: var(--radius) var(--radius) var(--radius) 4px;
}
.as-bot p + p,
.as-bot p + ul, .as-bot p + ol,
.as-bot ul + p, .as-bot ol + p { margin-top: 8px; }
.as-bot ul, .as-bot ol { padding-left: 18px; }
.as-bot li + li { margin-top: 3px; }
.as-bot strong { font-weight: var(--fw-semi); }
.as-error { color: var(--status-negative); border-color: rgba(var(--status-negative-rgb), 0.3); }

.as-links { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.as-link {
  background: none;
  border: 1px solid var(--border-hover);
  color: var(--text-60);
  font-family: var(--font);
  font-size: var(--fs-xs);
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.as-link:hover { color: var(--text); border-color: var(--text-20); }

.as-typing { display: flex; gap: 4px; padding: 14px; }
.as-typing span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-45);
  animation: asDot 1.2s infinite ease-in-out;
}
.as-typing span:nth-child(2) { animation-delay: 0.15s; }
.as-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes asDot { 0%, 80%, 100% { opacity: 0.25; transform: none; } 40% { opacity: 1; transform: translateY(-2px); } }

.as-form {
  display: flex;
  align-items: flex-end;
  gap: var(--s-2);
  padding: var(--s-3);
  border-top: 1px solid var(--border);
}
.as-input {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 140px;
  padding: 10px 12px;
  font-family: var(--font);
  font-size: var(--fs-base);
  line-height: 1.4;
  color: var(--text);
  background: var(--bg-input);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius);
  outline: none;
}
.as-input::placeholder { color: var(--text-40); }
.as-input:focus { border-color: var(--focus); }
.as-send {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: var(--radius);
  border: 0;
  background: var(--text);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.as-send svg { width: 18px; height: 18px; }
.as-send:disabled { opacity: 0.35; cursor: default; }

/* Phones: full width sheet above the bottom tab bar */
@media (max-width: 768px) {
  .as-fab {
    right: 16px;
    bottom: calc(61px + env(safe-area-inset-bottom) + 12px);
    width: 48px;
    height: 48px;
  }
  /* The upload tray spans the width above the tab bar; the button waits until it is gone */
  body:has(.up-tray) .as-fab { display: none; }
  .as-panel {
    left: 0;
    right: 0;
    bottom: calc(61px + env(safe-area-inset-bottom));
    width: 100%;
    max-width: none;
    height: calc(100vh - 61px - 56px);
    height: calc(100dvh - 61px - env(safe-area-inset-bottom) - 56px);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    border-left: 0;
    border-right: 0;
    border-bottom: 0;
  }
  .as-root.is-open .as-fab { display: none; }
  .as-input { font-size: 16px; }   /* no zoom on focus in iOS Safari */
}
