/**
 * Shared Zorin Assist composer surface.
 * Used by the Assistant home/chat composer and the ZyraStore landing bar.
 * Scoped under .za-assist so host pages keep their own design tokens.
 */

.za-assist {
  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.12);
  --text: #f4f6fb;
  --text-muted: #9aa3b5;
  --text-faint: #6b7385;
  --panel: #10101c;
  --accent: #7c9cff;
  --composer-max: 720px;
  --dur: 160ms;
  --dur-med: 220ms;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-soft: cubic-bezier(0.4, 0, 0.2, 1);
  --radius: 16px;
  position: relative;
  z-index: 2;
  width: 100%;
  max-width: var(--composer-max);
  display: grid;
  gap: 0.75rem;
  color: var(--text);
  font-family: Inter, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.za-assist button,
.za-assist textarea,
.za-assist input {
  font: inherit;
  color: inherit;
}

.za-assist .visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.za-assist .icon {
  display: inline-grid !important;
  place-items: center;
  line-height: 0;
  flex-shrink: 0 !important;
  color: inherit;
  opacity: 1 !important;
  visibility: visible !important;
  overflow: visible;
  min-width: 1px;
  min-height: 1px;
}

.za-assist .icon svg,
.za-assist .icon-btn svg,
.za-assist .send-btn svg {
  display: block !important;
  flex-shrink: 0 !important;
  max-width: none;
  max-height: none;
  opacity: 1 !important;
  visibility: visible !important;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  color: inherit;
}

.za-assist .icon-btn {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  color: #b6bfd1;
  border-radius: 8px;
  cursor: pointer;
  opacity: 1;
  visibility: visible;
  transition:
    color var(--dur) var(--ease-soft),
    background var(--dur) var(--ease-soft),
    transform var(--dur) var(--ease),
    box-shadow var(--dur) var(--ease-soft);
}

.za-assist .icon-btn:hover {
  color: #f4f6fb;
  background: rgba(255, 255, 255, 0.06);
}

.za-assist .icon-btn:active { transform: scale(0.96); }

.za-assist .icon-btn:focus-visible {
  outline: 2px solid rgba(124, 156, 255, 0.55);
  outline-offset: 2px;
}

.za-assist .icon-btn.active {
  color: var(--accent);
  background: rgba(124, 156, 255, 0.1);
}

.za-assist .composer-area,
.za-assist.composer-area {
  position: relative;
  z-index: 2;
  width: 100%;
  display: grid;
  gap: 0.75rem;
}

.za-assist .composer-slot:empty { display: none; }

.za-assist .composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 0.2rem;
  min-height: 52px;
  padding: 0.35rem 0.35rem 0.35rem 0.45rem;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background: rgba(12, 12, 22, 0.88);
  box-shadow:
    0 0 0 1px rgba(96, 165, 250, 0.06),
    0 0 36px rgba(99, 102, 241, 0.1),
    0 10px 32px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: border-color var(--dur) var(--ease-soft), box-shadow var(--dur) var(--ease-soft);
}

.za-assist .composer:focus-within {
  border-color: rgba(124, 156, 255, 0.28);
  box-shadow:
    0 0 0 1px rgba(96, 165, 250, 0.12),
    0 0 40px rgba(99, 102, 241, 0.14),
    0 12px 36px rgba(0, 0, 0, 0.32);
}

.za-assist .composer-left,
.za-assist .composer-right {
  display: flex;
  align-items: center;
  gap: 0.1rem;
}

.za-assist .composer-side {
  width: 32px;
  height: 32px;
  border-radius: 8px;
}

.za-assist .composer-field {
  position: relative;
  min-width: 0;
  align-self: center;
}

.za-assist .composer textarea {
  resize: none;
  border: none;
  outline: none;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  line-height: 1.4;
  max-height: 140px;
  padding: 0.55rem 0.4rem;
  min-height: 32px;
  width: 100%;
  align-self: center;
}

.za-assist-bar .composer textarea::placeholder {
  color: transparent;
}

.za-assist .composer-ph {
  position: absolute;
  left: 0.4rem;
  right: 0.4rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  font-size: 0.95rem;
  line-height: 1.4;
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 1;
  transition: opacity 420ms var(--ease-soft);
}

.za-assist .composer-ph.is-swap {
  opacity: 0;
}

.za-assist.is-filled .composer-ph,
.za-assist .composer-ph.is-hidden {
  opacity: 0;
}

.za-assist .send-btn {
  width: 34px;
  height: 34px;
  border: none;
  border-radius: 10px;
  display: grid;
  place-items: center;
  cursor: pointer;
  color: #ffffff;
  background: linear-gradient(135deg, #6366f1, #3b82f6 55%, #22d3ee);
  box-shadow: 0 0 14px rgba(59, 130, 246, 0.35);
  transition: transform var(--dur) var(--ease), filter var(--dur) var(--ease-soft), box-shadow var(--dur) var(--ease-soft);
  margin-left: 0.1rem;
  opacity: 1;
  visibility: visible;
}

.za-assist .send-btn .icon,
.za-assist .send-btn svg {
  color: #ffffff !important;
  stroke: #ffffff !important;
  fill: none !important;
  opacity: 1 !important;
  visibility: visible !important;
}

.za-assist .send-btn:hover {
  transform: translateY(-0.5px);
  filter: brightness(1.06);
  box-shadow: 0 0 18px rgba(59, 130, 246, 0.42);
}

.za-assist .send-btn:focus-visible {
  outline: 2px solid rgba(124, 156, 255, 0.55);
  outline-offset: 2px;
}

.za-assist .send-btn.is-stop {
  background: #334155;
  box-shadow: none;
  border-radius: 10px;
}

.za-assist .add-menu {
  position: absolute;
  left: 0;
  top: calc(100% - 2.5rem);
  min-width: 160px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.3rem;
  z-index: 8;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
}

.za-assist .add-option {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
}

.za-assist .add-option:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.za-assist .attach-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.za-assist .attach-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.28rem 0.5rem;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  font-size: 0.75rem;
}

.za-assist .attach-chip button {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  color: var(--text-faint);
  border-radius: 50%;
}

.za-assist .attach-chip button:hover {
  color: var(--text);
  background: rgba(255, 255, 255, 0.06);
}

/* Store landing placement — transparent strip, composer pill carries depth */
.za-assist-bar {
  position: relative;
  z-index: 20;
  display: flex;
  justify-content: center;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px 20px 10px;
  box-sizing: border-box;
}

.za-assist-bar .za-assist {
  width: min(calc(var(--composer-max) + 2.75rem), 100%);
  max-width: calc(var(--composer-max) + 2.75rem);
}

.za-assist-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
}

.za-assist-row .composer {
  min-width: 0;
}

.za-assist-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  filter:
    drop-shadow(0 0 8px rgba(56, 189, 248, 0.42))
    drop-shadow(0 0 16px rgba(168, 85, 247, 0.28));
}

.za-assist-mark svg {
  display: block;
  width: 28px;
  height: 28px;
}

.za-assist-mark:focus-visible {
  outline: 2px solid rgba(124, 156, 255, 0.55);
  outline-offset: 3px;
  border-radius: 10px;
}

.za-assist-chat {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 10px);
  z-index: 30;
  display: flex;
  flex-direction: column;
  max-height: min(46vh, 360px);
  overflow: hidden;
  border-radius: 16px;
  border: 1px solid var(--border-strong);
  background: rgba(12, 12, 22, 0.92);
  box-shadow:
    0 0 0 1px rgba(96, 165, 250, 0.06),
    0 0 36px rgba(99, 102, 241, 0.1),
    0 16px 40px rgba(0, 0, 0, 0.38);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.za-assist-chat[hidden] { display: none !important; }

.za-assist-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.7rem 0.85rem 0.55rem;
  border-bottom: 1px solid var(--border);
}

.za-assist-chat-title {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.za-assist-chat-actions {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.za-assist-open-full {
  font-size: 0.72rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.28rem 0.55rem;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  transition: color var(--dur) var(--ease-soft), border-color var(--dur) var(--ease-soft);
}

.za-assist-open-full:hover {
  color: var(--text);
  border-color: var(--border-strong);
}

.za-assist-thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 0.75rem 0.9rem 1rem;
}

.za-assist .msg { display: grid; gap: 0.35rem; }
.za-assist .msg-role { font-size: 0.72rem; color: var(--text-faint); font-weight: 600; }
.za-assist .msg.user .msg-body {
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.2);
  border-radius: 14px;
  padding: 0.75rem 0.9rem;
  white-space: pre-wrap;
}
.za-assist .msg.assistant .msg-body {
  color: var(--text);
  line-height: 1.55;
  font-size: 0.95rem;
  white-space: pre-wrap;
}
.za-assist .msg-thinking {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text-muted);
  font-size: 0.88rem;
}
.za-assist .msg-thinking .dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  animation: zaAssistBlink 1s infinite;
}
@keyframes zaAssistBlink { 50% { opacity: 0.35; } }

.za-assist .msg-error {
  color: var(--text-muted);
  background: rgba(248, 113, 113, 0.08);
  border: 1px solid rgba(248, 113, 113, 0.2);
  border-radius: 12px;
  padding: 0.75rem 0.9rem;
  font-size: 0.9rem;
}

@media (max-width: 768px) {
  .za-assist-bar {
    padding: 12px 16px 6px;
  }

  .za-assist-row {
    gap: 0.45rem;
  }

  .za-assist-mark {
    width: 32px;
    height: 32px;
  }

  .za-assist-mark svg {
    width: 24px;
    height: 24px;
  }

  .za-assist .composer {
    min-height: 48px;
    padding: 0.28rem 0.28rem 0.28rem 0.32rem;
  }

  .za-assist .composer textarea,
  .za-assist .composer-ph {
    font-size: 0.9rem;
  }

  .za-assist-chat {
    max-height: min(42vh, 300px);
  }
}

@media (max-width: 480px) {
  .za-assist-bar {
    padding: 10px 12px 4px;
  }

  .za-assist .composer-side {
    width: 30px;
    height: 30px;
  }

  .za-assist-open-full {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .za-assist .composer,
  .za-assist .icon-btn,
  .za-assist .send-btn,
  .za-assist .composer-ph {
    transition-duration: 0.01ms !important;
  }
  .za-assist .msg-thinking .dot {
    animation: none !important;
  }
}
