/* QRIL Unified In-App Push-Up Toast Layer (Unbenannt 1).
 *
 * ONE central toast rail for the three notification worlds (§10):
 *   activity     — "I need to do something."            (cyan,  ✓, dezent)
 *   system       — "Something happened to the platform." (severity color, ⚠/ℹ)
 *   live_signal  — "Something happened in the market."   (violet,  ⚡, urgent)
 *
 * Position (§2): bottom-left, directly right of the sidebar, above the bottom
 * news ticker. The right workspace stays completely free (§16). Uses the QRIL
 * design tokens (tokens.css) — no foreign toast look (§17).
 *
 * Injected globally via QRLToastMiddleware. Animation: slide-up on enter,
 * fade-out on leave (§3). Z-index 9400 sits ABOVE dashboard cards but BELOW
 * modals / dialogs / security confirmations (§14).
 */

/* ── Rail ──────────────────────────────────────────────────────────────── */

.qrl-toast-wrap {
  position: fixed;
  left: 296px;                 /* 280px sidebar + 16px gutter (overridden by JS) */
  bottom: 48px;                /* 32px ticker + 16px gap (§2) */
  z-index: 9400;
  display: flex;
  flex-direction: column;
  gap: 8px;                    /* vertical gap between toasts (§2) */
  pointer-events: none;
}

/* JS toggles these classes based on the live sidebar state. */
.qrl-toast-wrap.sb-collapsed { left: 84px; }  /* 68px + 16px */
.qrl-toast-wrap.sb-none       { left: 16px; }  /* no sidebar on this page */

/* ── Toast card ────────────────────────────────────────────────────────── */

.qrl-toast {
  width: 340px;
  max-width: calc(100vw - 32px);
  box-sizing: border-box;
  background: var(--color-surface-secondary, #171B20);
  border: 1px solid var(--color-border-strong, #39414A);
  border-left: 3px solid var(--color-accent, #C9CDD3);
  border-radius: var(--radius-modal, 8px);
  box-shadow: var(--shadow-modal, 0 4px 16px rgba(0, 0, 0, 0.5));
  padding: 11px 14px 10px;
  pointer-events: auto;
  cursor: pointer;
  animation: qrl-toast-in 0.24s cubic-bezier(0.22, 0.61, 0.36, 1);
}
.qrl-toast.leaving {
  animation: qrl-toast-out 0.16s ease-in forwards;
}

/* Type accents — restrained, semantic, never color alone (§17/§33). */
.qrl-toast.t-activity   { border-left-color: var(--chart-cyan, #39c5cf); }
.qrl-toast.t-live_signal{ border-left-color: var(--chart-purple, #bc8cff); }
.qrl-toast.t-system.sev-INFO    { border-left-color: var(--color-accent-info, #9AA2AB); }
.qrl-toast.t-system.sev-SUCCESS { border-left-color: var(--status-success, #62A67B); }
.qrl-toast.t-system.sev-WARNING { border-left-color: var(--status-warning, #C2A25C); }
.qrl-toast.t-system.sev-CRITICAL{ border-left-color: var(--status-error, #C56B70); }

/* Critical system pushes may stay until acknowledged (§6) — slightly stronger. */
.qrl-toast.t-system.sev-CRITICAL {
  border-width: 1px;
  border-left-width: 3px;
  box-shadow: 0 0 0 1px rgba(197, 107, 112, 0.25), var(--shadow-modal, 0 4px 16px rgba(0, 0, 0, 0.5));
}

/* ── Header row: icon + tag … timestamp … close ────────────────────────── */

.qrl-toast-head {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
}
.qrl-toast-icon {
  font-size: 12px;
  line-height: 1;
  flex-shrink: 0;
}
.qrl-toast.t-activity    .qrl-toast-icon { color: var(--chart-cyan, #39c5cf); }
.qrl-toast.t-live_signal .qrl-toast-icon { color: var(--chart-purple, #bc8cff); }
.qrl-toast.t-system.sev-INFO    .qrl-toast-icon { color: var(--color-accent-info, #9AA2AB); }
.qrl-toast.t-system.sev-SUCCESS .qrl-toast-icon { color: var(--status-success, #62A67B); }
.qrl-toast.t-system.sev-WARNING .qrl-toast-icon { color: var(--status-warning, #C2A25C); }
.qrl-toast.t-system.sev-CRITICAL .qrl-toast-icon { color: var(--status-error, #C56B70); }

.qrl-toast-tag {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--color-text-secondary, #B3BAC2);
  padding: 1px 6px;
  border: 1px solid var(--color-border-subtle, #262C33);
  border-radius: 3px;
}
.qrl-toast-time {
  margin-left: auto;
  font-size: 10px;
  color: var(--color-text-disabled, #59616A);
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.qrl-toast-close {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--color-text-disabled, #59616A);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  border-radius: 4px;
  padding: 0;
  flex-shrink: 0;
}
.qrl-toast-close:hover {
  color: var(--color-text-primary, #F2F4F6);
  background: var(--color-surface-hover, #242A31);
}

/* ── Body ──────────────────────────────────────────────────────────────── */

.qrl-toast-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text-primary, #F2F4F6);
  line-height: 1.3;
}
.qrl-toast.t-live_signal .qrl-toast-title {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.01em;
}
.qrl-toast-message {
  font-size: 12px;
  color: var(--color-text-secondary, #B3BAC2);
  margin-top: 2px;
  line-height: 1.35;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qrl-toast-meta {
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.qrl-toast-meta-line {
  font-size: 11px;
  color: var(--color-text-muted, #7F8892);
  font-variant-numeric: tabular-nums;
}
/* Live-signal price is the prominent datum (§7). */
.qrl-toast.t-live_signal .qrl-toast-meta-line.qrl-toast-price {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text-primary, #F2F4F6);
}

/* ── Footer / action ───────────────────────────────────────────────────── */

.qrl-toast-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--color-border-subtle, #262C33);
}
.qrl-toast-action {
  font-size: 11px;
  font-weight: 600;
  color: var(--color-accent, #C9CDD3);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  text-decoration: none;
}
.qrl-toast.t-live_signal .qrl-toast-action { color: var(--chart-purple, #bc8cff); }
.qrl-toast.t-activity   .qrl-toast-action { color: var(--chart-cyan, #39c5cf); }
.qrl-toast-action:hover { text-decoration: underline; }

.qrl-toast-close:focus-visible,
.qrl-toast-action:focus-visible {
  outline: 1px solid var(--color-accent, #C9CDD3);
  outline-offset: 2px;
}

/* SR-only live region announces incoming pushes (§33). */
.qrl-toast-live {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ── Animation (§3): slide up from below, ease-out ─────────────────────── */

@keyframes qrl-toast-in {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes qrl-toast-out {
  from { opacity: 1; transform: translateX(0); }
  to   { opacity: 0; transform: translateX(-12px); }
}

@media (prefers-reduced-motion: reduce) {
  .qrl-toast { animation: none; }
  .qrl-toast.leaving { animation: none; }
}

/* ── Responsive (§16): small viewports collapse to the corner ──────────── */

@media (max-width: 768px) {
  .qrl-toast-wrap,
  .qrl-toast-wrap.sb-collapsed,
  .qrl-toast-wrap.sb-none {
    left: 16px;
    right: 16px;
    bottom: 48px;
  }
  .qrl-toast { width: auto; }
}
