/**
 * Telecom Voucher — toast surface (TVToast)
 * Tabler-adjacent: top accent, tinted icon well, elevated panel, type-colored progress.
 */

.tv-toast-container {
  position: fixed;
  z-index: var(--tv-z-toast, 1080);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  pointer-events: none;
  max-width: min(22rem, calc(100vw - 1.5rem));
}

.tv-toast-container--top-right {
  top: max(1rem, calc(var(--topbar-height, 56px) + 4px));
  inset-inline-end: 1rem;
}

.tv-toast-container--top-left {
  top: max(1rem, calc(var(--topbar-height, 56px) + 4px));
  inset-inline-start: 1rem;
}

.tv-toast-container--bottom-right {
  bottom: 1rem;
  inset-inline-end: 1rem;
}

.tv-toast-container--bottom-left {
  bottom: 1rem;
  inset-inline-start: 1rem;
}

.tv-toast {
  --tv-toast-accent: var(--tv-info, #3b82f6);
  --tv-toast-icon-bg: rgba(59, 130, 246, 0.12);
  --tv-toast-icon-fg: var(--tv-info, #2563eb);
  position: relative;
  overflow: hidden;
  border-radius: var(--tv-radius-lg, 12px);
  border: 1px solid var(--tv-border, #e2e8f0);
  background: var(--tv-surface, #ffffff);
  box-shadow:
    0 1px 2px rgba(15, 23, 42, 0.06),
    0 12px 40px rgba(15, 23, 42, 0.12);
  pointer-events: auto;
  opacity: 0;
  transform: translate3d(100%, 0, 0);
  transition:
    opacity 0.28s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
}

.tv-toast::before {
  content: "";
  position: absolute;
  top: 0;
  inset-inline: 0;
  height: 3px;
  background: var(--tv-toast-accent);
  border-radius: var(--tv-radius-lg, 12px) var(--tv-radius-lg, 12px) 0 0;
  z-index: 1;
}

html[data-theme="dark"] .tv-toast {
  border-color: rgba(255, 255, 255, 0.1);
  background: var(--tv-surface, #1e293b);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04),
    0 16px 48px rgba(0, 0, 0, 0.45);
}

.tv-toast--success {
  --tv-toast-accent: var(--tv-success, #22c55e);
  --tv-toast-icon-bg: rgba(34, 197, 94, 0.14);
  --tv-toast-icon-fg: var(--tv-success, #16a34a);
}

.tv-toast--error {
  --tv-toast-accent: var(--tv-danger, #ef4444);
  --tv-toast-icon-bg: rgba(239, 68, 68, 0.14);
  --tv-toast-icon-fg: var(--tv-danger, #dc2626);
}

.tv-toast--warning {
  --tv-toast-accent: var(--tv-warning, #f59e0b);
  --tv-toast-icon-bg: rgba(245, 158, 11, 0.16);
  --tv-toast-icon-fg: var(--tv-warning, #d97706);
}

.tv-toast--info {
  --tv-toast-accent: var(--tv-info, #3b82f6);
  --tv-toast-icon-bg: rgba(59, 130, 246, 0.14);
  --tv-toast-icon-fg: var(--tv-info, #2563eb);
}

html[data-theme="dark"] .tv-toast--success {
  --tv-toast-icon-bg: rgba(34, 197, 94, 0.18);
  --tv-toast-icon-fg: #4ade80;
}

html[data-theme="dark"] .tv-toast--error {
  --tv-toast-icon-bg: rgba(239, 68, 68, 0.2);
  --tv-toast-icon-fg: #fca5a5;
}

html[data-theme="dark"] .tv-toast--warning {
  --tv-toast-icon-bg: rgba(245, 158, 11, 0.2);
  --tv-toast-icon-fg: #fcd34d;
}

html[data-theme="dark"] .tv-toast--info {
  --tv-toast-icon-bg: rgba(96, 165, 250, 0.18);
  --tv-toast-icon-fg: #93c5fd;
}

.tv-toast--visible {
  opacity: 1;
  transform: translate3d(0, 0, 0);
}

.tv-toast--dismissing {
  opacity: 0;
  transform: translate3d(100%, 0, 0);
}

.tv-toast__inner {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  padding: 0.875rem 1rem 0.75rem;
}

.tv-toast__icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.0625rem;
}

.tv-toast__icon-surface {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: var(--tv-radius-md, 8px);
  background: var(--tv-toast-icon-bg);
  color: var(--tv-toast-icon-fg);
}

.tv-toast__icon-surface svg {
  display: block;
}

.tv-toast__content {
  flex: 1;
  min-width: 0;
  padding-top: 0.125rem;
}

.tv-toast__title {
  font-weight: 600;
  font-size: 0.875rem;
  line-height: 1.35;
  letter-spacing: -0.01em;
  color: var(--tv-text, #0f172a);
  margin-bottom: 0.125rem;
}

.tv-toast__message {
  font-size: 0.8125rem;
  line-height: 1.45;
  color: var(--tv-text-secondary, #475569);
}

.tv-toast--solo .tv-toast__message {
  font-size: 0.875rem;
  color: var(--tv-text, #1e293b);
}

html[data-theme="dark"] .tv-toast__title {
  color: var(--tv-text, #f1f5f9);
}

html[data-theme="dark"] .tv-toast__message {
  color: var(--tv-text-secondary, #cbd5e1);
}

html[data-theme="dark"] .tv-toast--solo .tv-toast__message {
  color: var(--tv-text, #e2e8f0);
}

.tv-toast__close {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  margin-block-start: -0.125rem;
  margin-inline-end: -0.25rem;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--tv-text-muted, #64748b);
  border-radius: var(--tv-radius-md, 8px);
  cursor: pointer;
  transition:
    background-color 0.15s cubic-bezier(0.4, 0, 0.2, 1),
    color 0.15s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.tv-toast__close:hover {
  background: var(--tv-bg-muted, #f1f5f9);
  color: var(--tv-text, #0f172a);
}

.tv-toast__close:active {
  transform: scale(0.96);
}

.tv-toast__close:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--tv-surface, #fff), 0 0 0 4px rgba(var(--tv-primary-rgb, 58, 90, 156), 0.35);
}

html[data-theme="dark"] .tv-toast__close:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--tv-text, #f8fafc);
}

.tv-toast__progress {
  position: absolute;
  bottom: 0;
  inset-inline-start: 0;
  height: 2px;
  width: 100%;
  transform: scaleX(1);
  transform-origin: start center;
  background: var(--tv-toast-accent);
  opacity: 0.55;
  animation: tv-toast-progress linear forwards;
}

.tv-toast--paused .tv-toast__progress {
  animation-play-state: paused;
}

@keyframes tv-toast-progress {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

@media (max-width: 480px) {
  .tv-toast-container {
    inset-inline: 0.75rem;
    max-width: none;
  }

  .tv-toast-container--top-right,
  .tv-toast-container--top-left {
    top: max(0.75rem, calc(var(--topbar-height, 56px) + 2px));
  }

  .tv-toast-container--bottom-right,
  .tv-toast-container--bottom-left {
    bottom: 0.75rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .tv-toast {
    transition: opacity 0.01ms !important;
    transform: none !important;
  }

  .tv-toast--visible {
    transform: none;
  }

  .tv-toast--dismissing {
    transform: none;
    opacity: 0;
  }

  .tv-toast__progress {
    animation: none !important;
    opacity: 0;
  }
}
