/* EVA Store — floating AI assistant (store + dashboard home).
   Self-contained: every class is `sa-*`, tokens live on .sa-root, so page CSS cannot leak in.
   Motion: transform/opacity only, one ease-out curve, separate (shorter) exit curves. */

.sa-root {
  --sa-bg: #160b10;
  --sa-surface: #28141d;
  --sa-surface-2: #412331;
  --sa-line: rgba(196,159,176, .15);
  --sa-line-2: rgba(196,159,176, .27);
  --sa-ink: #f6edf1;
  --sa-ink-2: #cdb6c1;
  --sa-mute: #a38593;
  --sa-gold: #e8579c;
  --sa-gold-2: #d62f7f;
  --sa-fill: linear-gradient(150deg, #e36ba3 0%, #d62f7f 100%);
  --sa-on: #0d0709;
  --sa-ease: cubic-bezier(.22, 1, .36, 1);
  position: fixed;
  inset: 0;
  z-index: 9000;
  pointer-events: none;
  direction: rtl;
  color: var(--sa-ink);
  font-family: "Cairo", "Tajawal", system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}
.sa-root *, .sa-root *::before, .sa-root *::after { box-sizing: border-box; }
body.system-workspace-open .sa-root { display: none; }

.sa-root button, .sa-root textarea {
  appearance: none; -webkit-appearance: none; margin: 0; min-height: 0; min-width: 0; text-transform: none; letter-spacing: normal;
  text-shadow: none; filter: none; font-family: inherit;
}
.sa-root button { overflow: visible; cursor: pointer; }
.sa-root svg { display: block; width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

/* --------------------------------------------------------------- launcher */
.sa-root .sa-fab {
  position: absolute; right: 24px; bottom: 24px; width: 60px; height: 60px; padding: 0; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: var(--sa-fill); color: var(--sa-on); pointer-events: auto;
  box-shadow: 0 16px 34px -10px rgba(214,47,127, .55), inset 0 1px 0 rgba(255, 255, 255, .25), 0 0 0 6px rgba(214,47,127, .12);
  transition: transform .4s var(--sa-ease), box-shadow .4s ease, opacity .3s ease;
  animation: saFabIn .8s var(--sa-ease) .5s backwards;
}
.sa-root .sa-fab:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 20px 40px -10px rgba(214,47,127, .65), inset 0 1px 0 rgba(255, 255, 255, .28), 0 0 0 9px rgba(214,47,127, .16); }
.sa-root .sa-fab:active { transform: scale(.97); }
.sa-root .sa-fab:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.sa-fab-ico { position: absolute; width: 27px; height: 27px; transition: opacity .3s ease, transform .5s var(--sa-ease); }
.sa-fab-ico.is-close { opacity: 0; transform: rotate(-90deg) scale(.55); }
.sa-root[data-open="true"] .sa-fab-ico.is-open { opacity: 0; transform: rotate(90deg) scale(.55); }
.sa-root[data-open="true"] .sa-fab-ico.is-close { opacity: 1; transform: none; }

/* ------------------------------------------------------------------ panel */
.sa-panel {
  position: absolute; right: 24px; bottom: 100px; width: min(396px, calc(100vw - 32px)); height: min(640px, calc(100vh - 132px));
  display: flex; flex-direction: column; overflow: hidden; border-radius: 26px;
  border: 1px solid var(--sa-line-2); background: linear-gradient(180deg, #301a24, #26131c);
  box-shadow: 0 40px 90px -30px rgba(0, 0, 0, .95), 0 0 0 1px rgba(255, 255, 255, .02) inset;
  visibility: hidden; opacity: 0; pointer-events: none; transform: translateY(22px) scale(.95); transform-origin: 100% 100%;
  transition: opacity .28s ease, transform .4s cubic-bezier(.5, 0, .75, 0), visibility 0s linear .42s;
}
.sa-root[data-open="true"] .sa-panel {
  visibility: visible; opacity: 1; pointer-events: auto; transform: none;
  transition: opacity .42s ease, transform .6s var(--sa-ease), visibility 0s;
}
.sa-panel:focus { outline: 0; }

.sa-head {
  flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 16px 16px 14px 14px;
  border-bottom: 1px solid var(--sa-line); background: linear-gradient(180deg, rgba(255, 255, 255, .035), transparent);
}
.sa-tile {
  flex: 0 0 auto; width: 46px; height: 46px; padding: 11px; border-radius: 15px; background: var(--sa-fill); color: var(--sa-on);
  box-shadow: 0 10px 22px -10px rgba(214,47,127, .6), inset 0 1px 0 rgba(255, 255, 255, .25);
}
.sa-titles { flex: 1; min-width: 0; }
.sa-title { font-weight: 800; font-size: 1.06rem; line-height: 1.3; color: var(--sa-ink); }
.sa-sub { margin-top: 2px; color: var(--sa-mute); font-size: .78rem; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sa-root .sa-icon {
  flex: 0 0 auto; width: 38px; height: 38px; padding: 10px; border-radius: 50%; border: 1px solid var(--sa-line-2);
  background: rgba(255, 255, 255, .03); color: var(--sa-ink-2); transition: background .2s ease, color .2s ease, border-color .2s ease;
}
.sa-root .sa-icon:hover { background: rgba(255, 255, 255, .09); color: var(--sa-ink); border-color: rgba(198,162,179, .4); }
.sa-root .sa-icon:focus-visible, .sa-root .sa-chip:focus-visible, .sa-root .sa-send:focus-visible { outline: 2px solid var(--sa-gold); outline-offset: 2px; }
.sa-root .sa-icon[hidden] { display: none; }

/* -------------------------------------------------------------------- log */
.sa-log {
  flex: 1; min-height: 0; overflow-y: auto; scrollbar-width: none !important; overscroll-behavior: contain; padding: 18px 16px 8px;
  display: flex; flex-direction: column; gap: 14px; scrollbar-width: none; -ms-overflow-style: none;
}
.sa-log::-webkit-scrollbar { display: none; }
.sa-msg { display: flex; align-items: flex-start; gap: 9px; animation: saRise .5s var(--sa-ease) both; }
.sa-avatar {
  flex: 0 0 auto; width: 34px; height: 34px; padding: 8px; border-radius: 50%; color: var(--sa-gold);
  background: rgba(198,162,179, .12); border: 1px solid var(--sa-line-2);
}
.sa-bubble {
  max-width: calc(100% - 46px); padding: 11px 15px; border-radius: 20px; font-size: .92rem; line-height: 1.85;
  font-weight: 500; overflow-wrap: anywhere; word-break: break-word;
}
.sa-bot .sa-bubble { background: var(--sa-surface); border: 1px solid var(--sa-line); border-end-start-radius: 6px; color: var(--sa-ink); }
.sa-user { justify-content: flex-end; }
.sa-user .sa-bubble { max-width: 86%; background: var(--sa-fill); color: var(--sa-on); font-weight: 600; border-end-end-radius: 6px; white-space: pre-wrap; }
.sa-error .sa-bubble { border-color: rgba(239, 127, 115, .35); background: rgba(239, 127, 115, .07); }

.sa-bubble .sa-p { margin: 0 0 .55em; }
.sa-bubble .sa-p:last-child, .sa-bubble .sa-list:last-child, .sa-bubble pre:last-child { margin-bottom: 0; }
.sa-bubble .sa-list { margin: .25em 0 .55em; padding: 0; padding-inline-start: 1.35em; }
.sa-bubble .sa-list li { margin: .18em 0; padding-inline-start: .15em; }
.sa-bubble strong { font-weight: 800; color: #fff; }
.sa-bubble a { color: #f39ac3; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(217,194,205, .45); }
.sa-bubble a:hover { text-decoration-color: currentColor; }
.sa-bubble code {
  direction: ltr; unicode-bidi: isolate; padding: 1px 7px; border-radius: 7px; background: rgba(255, 255, 255, .08);
  font: 600 .84em ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #e1cdd6;
}
.sa-bubble pre {
  direction: ltr; text-align: left; margin: .5em 0; padding: 11px 13px; overflow-x: auto; border-radius: 13px; scrollbar-width: none;
  background: #190d13; border: 1px solid var(--sa-line);
}
.sa-bubble pre::-webkit-scrollbar { display: none; }
.sa-bubble pre code { padding: 0; background: none; font-size: .8rem; line-height: 1.7; color: #e1cdd6; white-space: pre; }

.sa-dots { display: inline-flex; align-items: center; gap: 5px; height: 1.85em; }
.sa-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--sa-gold-2); animation: saDot 1.3s ease-in-out infinite; }
.sa-dots i:nth-child(2) { animation-delay: .17s; }
.sa-dots i:nth-child(3) { animation-delay: .34s; }

.sa-retry {
  display: inline-flex; margin-top: 8px; padding: 6px 14px; border-radius: 999px; border: 1px solid var(--sa-line-2);
  background: transparent; color: var(--sa-ink); font: 700 .8rem "Cairo", sans-serif; transition: background .2s ease, border-color .2s ease;
}
.sa-retry:hover { background: rgba(255, 255, 255, .07); border-color: var(--sa-gold-2); }

/* ------------------------------------------------------------ quick chips */
.sa-chips {
  display: flex; flex-wrap: wrap; gap: 8px; margin-top: -4px; padding-inline-start: 43px;
  transition: opacity .3s ease, transform .35s var(--sa-ease), max-height .4s ease, margin .4s ease;
  max-height: 400px;
}
.sa-chips.is-gone { opacity: 0; transform: translateY(-8px); max-height: 0; margin: 0; overflow: hidden; pointer-events: none; }
.sa-root .sa-chip {
  padding: 9px 14px; border-radius: 999px; border: 1px solid var(--sa-line-2); background: rgba(255, 255, 255, .025);
  color: var(--sa-ink-2); font: 700 .82rem/1.4 "Cairo", "Tajawal", sans-serif; text-align: start;
  transition: border-color .2s ease, background .2s ease, color .2s ease, transform .25s var(--sa-ease);
  animation: saRise .55s var(--sa-ease) backwards; animation-delay: calc(var(--i, 0) * 65ms + 220ms);
}
.sa-root .sa-chip:hover { border-color: var(--sa-gold-2); background: rgba(198,162,179, .1); color: var(--sa-ink); transform: translateY(-1px); }
.sa-root .sa-chip:active { transform: scale(.98); }

/* ------------------------------------------------------------------ input */
.sa-form { flex: 0 0 auto; padding: 10px 14px 12px; border-top: 1px solid var(--sa-line); margin: 0; }
.sa-pill {
  display: flex; align-items: flex-end; gap: 8px; padding: 6px 14px 6px 6px; border-radius: 27px;
  border: 1px solid var(--sa-line-2); background: var(--sa-surface); transition: border-color .25s ease, box-shadow .25s ease;
}
.sa-pill:focus-within { border-color: var(--sa-gold-2); box-shadow: 0 0 0 3px rgba(198,162,179, .1); }
/* the site's global input/textarea rules are !important (dark fill, focus ring, 13px) — this field must sit flat inside the pill */
.sa-root .sa-input, .sa-root .sa-input:focus, .sa-root .sa-input:hover {
  flex: 1; min-width: 0; height: 42px; max-height: 120px; padding: 9px 4px !important; resize: none; outline: 0 !important;
  border: 0 !important; border-radius: 0 !important; box-shadow: none !important; background: transparent !important; color: var(--sa-ink) !important;
  font: 600 .92rem/1.6 "Cairo", "Tajawal", sans-serif !important; scrollbar-width: none !important;
}
.sa-root .sa-input::-webkit-scrollbar { display: none; }
.sa-root .sa-input::placeholder { color: var(--sa-mute) !important; font-weight: 500; opacity: 1; }
.sa-root .sa-send {
  flex: 0 0 auto; width: 42px; height: 42px; padding: 11px; border: 0; border-radius: 50%; background: var(--sa-fill); color: var(--sa-on);
  box-shadow: 0 8px 18px -8px rgba(214,47,127, .65); transition: transform .25s var(--sa-ease), opacity .25s ease, filter .2s ease;
}
.sa-root .sa-send:hover:not(:disabled) { filter: brightness(1.06); transform: translateY(-1px); }
.sa-root .sa-send:active:not(:disabled) { transform: scale(.94); }
.sa-root .sa-send:disabled { opacity: .38; cursor: default; box-shadow: none; }
.sa-root .sa-send.is-stop svg { fill: currentColor; stroke: none; padding: 1px; }
.sa-note { margin: 8px 0 0; text-align: center; color: var(--sa-mute); font-size: .7rem; font-weight: 500; }

.sa-scrim { display: none; }

/* ----------------------------------------------------------------- motion */
@keyframes saRise { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: none; } }
@keyframes saFabIn { from { opacity: 0; transform: translateY(18px) scale(.6); } to { opacity: 1; transform: none; } }
@keyframes saDot { 0%, 60%, 100% { opacity: .3; transform: translateY(0); } 30% { opacity: 1; transform: translateY(-3px); } }

/* ----------------------------------------------------------------- mobile */
@media (max-width: 560px) {
  .sa-root .sa-fab { right: 16px; bottom: 16px; width: 56px; height: 56px; }
  .sa-panel {
    right: 0; left: 0; bottom: 0; width: 100%; height: min(88dvh, 720px); border-radius: 26px 26px 0 0; border-inline: 0; border-bottom: 0;
    opacity: 1; transform: translateY(102%); transform-origin: 50% 100%;
    transition: transform .42s cubic-bezier(.5, 0, .75, 0), visibility 0s linear .45s;
  }
  .sa-root[data-open="true"] .sa-panel { transform: none; transition: transform .65s var(--sa-ease), visibility 0s; }
  .sa-scrim {
    display: block; position: absolute; inset: 0; background: rgba(9,5,7, .62); opacity: 0; visibility: hidden; pointer-events: none;
    transition: opacity .4s ease, visibility 0s linear .4s;
  }
  .sa-root[data-open="true"] .sa-scrim { opacity: 1; visibility: visible; pointer-events: auto; transition: opacity .5s ease, visibility 0s; }
  .sa-root[data-open="true"] .sa-fab { opacity: 0; pointer-events: none; transform: scale(.6); }
  .sa-form { padding-bottom: calc(12px + env(safe-area-inset-bottom)); }
}
