/* =============================================================================
   Toast notifications — canonical styles for live shell + SPA (vpx-webkit tokens)
   Must stay compatible with theme-dark.css (app.html loads both).
   ============================================================================= */

:root,
:root[data-theme] {
  --border: var(--border-primary, #30363d);
  --muted: var(--text-muted, #8b949e);
  --primary: var(--color-primary, #1f6feb);
  --success: var(--color-success, #238636);
  --danger: var(--color-danger, #da3633);
  --spacing-xs: 0.25rem;
  --spacing-sm: 0.5rem;
  --spacing-md: 0.75rem;
  --radius-lg: 0.5rem;
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -1px rgba(0, 0, 0, 0.2);
  --transition-normal: 200ms ease;
  --z-toast: 1080;
}

.toast-container {
  position: fixed;
  top: 60px;
  right: 12px;
  z-index: var(--z-toast, 1080);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm, 0.5rem);
  max-width: min(400px, calc(100vw - 24px));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-xs, 0.25rem);
  padding: var(--spacing-md, 0.75rem);
  background: var(--bg-card, #161b22);
  border: 1px solid var(--border-primary, #30363d);
  border-radius: var(--radius-lg, 0.5rem);
  box-shadow: var(--shadow-md);
  min-width: 280px;
  max-width: 400px;
  pointer-events: auto;
  position: relative;
  animation: zk-toast-in var(--transition-normal, 200ms ease) forwards;
}

.toast.toast-dismissing {
  animation: zk-toast-out var(--transition-normal, 200ms ease) forwards;
}

@keyframes zk-toast-in {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes zk-toast-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

.toast-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.3;
  color: var(--text-primary, #c9d1d9);
  margin-bottom: 2px;
}

.toast-message {
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--text-secondary, #8b949e);
  word-wrap: break-word;
}

.toast-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--text-tertiary, #8b949e);
  cursor: pointer;
  padding: 2px 4px;
  margin: -2px -2px -2px 0;
  border-radius: 4px;
  font-size: 1.125rem;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.toast-close:hover {
  background: var(--bg-hover, rgba(255, 255, 255, 0.08));
  color: var(--text-primary, #c9d1d9);
}

.toast.toast-compact {
  min-width: 220px;
  max-width: min(360px, calc(100vw - 24px));
  align-items: center;
  padding: 0.55rem 0.75rem;
}

.toast.toast-compact .toast-title {
  margin-bottom: 0;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.toast-compact .toast-message,
.toast.toast-compact .toast-action,
.toast.toast-compact .toast-close {
  display: none;
}

.toast-action {
  margin-top: 8px;
}

.toast-action a {
  display: inline-block;
  padding: 4px 10px;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 6px;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-primary, #c9d1d9);
  text-decoration: none;
}

.toast-action a:hover {
  background: rgba(255, 255, 255, 0.12);
}

.toast.toast-success {
  border-left: 4px solid var(--color-success, #238636);
}
.toast.toast-success .toast-icon {
  color: var(--color-success, #238636);
}

.toast.toast-error,
.toast.toast-danger {
  border-left: 4px solid var(--color-danger, #da3633);
}
.toast.toast-error .toast-icon,
.toast.toast-danger .toast-icon {
  color: var(--color-danger, #da3633);
}

.toast.toast-warning {
  border-left: 4px solid var(--color-warning, #d29922);
}
.toast.toast-warning .toast-icon {
  color: var(--color-warning, #d29922);
}

.toast.toast-info {
  border-left: 4px solid var(--color-info, #1f6feb);
}
.toast.toast-info .toast-icon {
  color: var(--color-info, #1f6feb);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: rgba(255, 255, 255, 0.25);
  border-radius: 0 0 0 var(--radius-lg, 0.5rem);
  animation: zk-toast-progress linear forwards;
}

@keyframes zk-toast-progress {
  from { width: 100%; }
  to { width: 0%; }
}

@media (prefers-reduced-motion: reduce) {
  .toast {
    animation: none;
    opacity: 1;
    transform: none;
  }
  .toast.toast-dismissing {
    animation: none;
    opacity: 0;
  }
}
