/* =============================================================================
   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: calc(var(--topbar-height, 3.5rem) + 0.5rem);
  right: 0.25rem;
  z-index: var(--z-toast, 1080);
  display: flex;
  flex-direction: column;
  gap: var(--spacing-sm, 0.5rem);
  max-width: min(36rem, calc(100vw - 0.5rem));
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.6rem 0.6rem 0.6rem 0.6rem;
  background: var(--bg-card, #161b22);
  border: 1px solid var(--border-primary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md);
  min-width: min(32rem, calc(100vw - 0.5rem));
  max-width: 36rem;
  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: 1.1rem;
  height: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  line-height: 1;
  margin-left: 0;
  margin-top: 0.12rem;
}

.toast-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.1rem;
}

.toast-title {
  font-weight: 500;
  font-size: 0.875rem;
  line-height: 1.3;
  color: var(--text-primary);
  margin-bottom: 0;
}

.toast-message {
  font-size: 0.75rem;
  font-weight: 400;
  line-height: 1.35;
  color: var(--text-secondary);
  word-wrap: break-word;
}

.toast-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  padding: 0.15rem 0.25rem;
  margin: -0.15rem -0.1rem -0.15rem 0;
  border-radius: .25rem;
  font-size: 1.25rem;
  font-weight: 300;
  line-height: 1;
  width: 1.75rem;
  height: 1.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  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,
.toast.toast-title-only,
.toast:not(:has(.toast-message)) {
  align-items: center;
}

.toast.toast-compact .toast-title,
.toast.toast-title-only .toast-title,
.toast:not(:has(.toast-message)) .toast-title {
  margin-bottom: 0;
  font-weight: 500;
}

.toast.toast-compact .toast-title {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast.toast-compact .toast-message,
.toast.toast-compact .toast-action {
  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-clickable {
  cursor: pointer;
}

.toast.toast-clickable .toast-content {
  cursor: pointer;
}

.toast.toast-success {
  border-left: 5px 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;
  }
}
