/**
 * Toast Notification System
 * 
 * A lightweight, globally accessible toast notification system.
 * Usage: window.Toast.error('message'), window.Toast.success('message'), etc.
 * 
 * Supports:
 *   - Types: success, error, warning, info
 *   - Variants: default, accent, compact
 *   - Actions: buttons and links
 * 
 * Uses theme CSS variables:
 *   --clr-success, --clr-error, --clr-warning, --clr-info
 */

/* ============================================================================
   Toast Container
   ============================================================================ */

.toast-container {
  position: fixed;
  bottom: 16px;
  right: 16px;
  z-index: 10000;
  display: flex;
  flex-direction: column-reverse;
  gap: 12px;
  pointer-events: none;
  max-width: 420px;
  width: calc(100% - 32px);
}

@media (max-width: 640px) {
  .toast-container {
    bottom: 12px;
    right: 12px;
    left: 12px;
    width: auto;
    max-width: none;
  }
}

/* ============================================================================
   Base Toast Styles
   ============================================================================ */

.toast {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 2px 4px rgba(0, 0, 0, 0.1);
  pointer-events: auto;
  transform: translateY(100%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.3s ease;
  font-family: var(--font-body, system-ui, sans-serif);
  font-size: 14px;
  line-height: 1.5;
  background-color: #ffffff;
}

.toast.toast-visible {
  transform: translateY(0);
  opacity: 1;
}

.toast.toast-hiding {
  transform: translateY(100%);
  opacity: 0;
}

/* ============================================================================
   Toast Icon
   ============================================================================ */

.toast-icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

.toast-icon svg {
  width: 100%;
  height: 100%;
}

/* ============================================================================
   Toast Content
   ============================================================================ */

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

.toast-title {
  font-weight: 500;
  font-size: 14px;
  margin: 0 0 4px 0;
}

.toast-message {
  margin: 0;
  font-size: 14px;
}

/* Only add margin-top when there's a title before the message */
.toast-title + .toast-message {
  margin-top: 8px;
}

.toast-message ul {
  margin: 8px 0 0 0;
  padding-left: 20px;
  list-style-type: disc;
}

.toast-message li {
  margin: 4px 0;
}

/* ============================================================================
   Close Button
   ============================================================================ */

.toast-close {
  flex-shrink: 0;
  background: none;
  border: none;
  padding: 6px;
  margin: -6px -6px -6px 0;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.15s ease, background-color 0.15s ease;
  border-radius: 6px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.toast-close:hover {
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.05);
}

.toast-close svg {
  width: 20px;
  height: 20px;
}

/* ============================================================================
   Action Buttons
   ============================================================================ */

.toast-actions {
  display: flex;
  gap: 12px;
  margin-top: 12px;
  margin-left: -8px;
  margin-bottom: -6px;
}

.toast-action {
  padding: 6px 8px;
  font-size: 14px;
  font-weight: 500;
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

/* ============================================================================
   Inline Link
   ============================================================================ */

.toast-link-wrapper {
  display: flex;
  flex: 1;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

@media (min-width: 768px) {
  .toast-link-wrapper {
    flex-direction: row;
  }
}

.toast-link {
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  margin-top: 12px;
}

@media (min-width: 768px) {
  .toast-link {
    margin-top: 0;
    margin-left: 24px;
  }
}

.toast-link:hover {
  text-decoration: underline;
}

/* ============================================================================
   Variant: Accent (left border)
   ============================================================================ */

.toast-accent {
  border-radius: 0;
  border-left-width: 4px;
  border-left-style: solid;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ============================================================================
   Variant: Compact (single line)
   ============================================================================ */

.toast-compact {
  padding: 12px 16px;
}

.toast-compact .toast-content {
  display: flex;
  align-items: center;
}

.toast-compact .toast-title {
  margin: 0;
}

.toast-compact .toast-message {
  margin: 0;
}

/* ============================================================================
   Type: Error
   Uses --clr-error from theme (default: #EF4444)
   ============================================================================ */

.toast-error {
  background-color: #fef2f2;
  border-color: var(--clr-error, #EF4444);
  outline: 1px solid rgba(239, 68, 68, 0.2);
}

.toast-error.toast-accent {
  border-left-color: var(--clr-error, #EF4444);
  outline: none;
}

.toast-error .toast-icon {
  color: var(--clr-error, #EF4444);
}

.toast-error .toast-title {
  color: #991b1b;
}

.toast-error .toast-message {
  color: #b91c1c;
}

.toast-error .toast-close {
  color: #991b1b;
}

.toast-error .toast-action {
  color: #991b1b;
}

.toast-error .toast-action:hover {
  background-color: #fee2e2;
}

.toast-error .toast-link {
  color: var(--clr-error, #EF4444);
}

.toast-error .toast-link:hover {
  color: #dc2626;
}

/* ============================================================================
   Type: Success
   Uses --clr-success from theme (default: #18a558)
   ============================================================================ */

.toast-success {
  background-color: #f0fdf4;
  border-color: var(--clr-success, #18a558);
  outline: 1px solid rgba(24, 165, 88, 0.2);
}

.toast-success.toast-accent {
  border-left-color: var(--clr-success, #18a558);
  outline: none;
}

.toast-success .toast-icon {
  color: var(--clr-success, #18a558);
}

.toast-success .toast-title {
  color: #166534;
}

.toast-success .toast-message {
  color: #15803d;
}

.toast-success .toast-close {
  color: #166534;
}

.toast-success .toast-action {
  color: #166534;
}

.toast-success .toast-action:hover {
  background-color: #dcfce7;
}

.toast-success .toast-link {
  color: var(--clr-success, #18a558);
}

.toast-success .toast-link:hover {
  color: #15803d;
}

/* ============================================================================
   Type: Warning
   Uses --clr-warning from theme (default: #F59E0B)
   ============================================================================ */

.toast-warning {
  background-color: #fffbeb;
  border-color: var(--clr-warning, #F59E0B);
  outline: 1px solid rgba(245, 158, 11, 0.2);
}

.toast-warning.toast-accent {
  border-left-color: var(--clr-warning, #F59E0B);
  outline: none;
}

.toast-warning .toast-icon {
  color: var(--clr-warning, #F59E0B);
}

.toast-warning .toast-title {
  color: #92400e;
}

.toast-warning .toast-message {
  color: #a16207;
}

.toast-warning .toast-close {
  color: #92400e;
}

.toast-warning .toast-action {
  color: #92400e;
}

.toast-warning .toast-action:hover {
  background-color: #fef3c7;
}

.toast-warning .toast-link {
  color: var(--clr-warning, #F59E0B);
}

.toast-warning .toast-link:hover {
  color: #d97706;
}

/* ============================================================================
   Type: Info
   Uses --clr-info from theme (default: #3B82F6)
   ============================================================================ */

.toast-info {
  background-color: #eff6ff;
  border-color: var(--clr-info, #3B82F6);
  outline: 1px solid rgba(59, 130, 246, 0.2);
}

.toast-info.toast-accent {
  border-left-color: var(--clr-info, #3B82F6);
  outline: none;
}

.toast-info .toast-icon {
  color: var(--clr-info, #3B82F6);
}

.toast-info .toast-title {
  color: #1e40af;
}

.toast-info .toast-message {
  color: #1d4ed8;
}

.toast-info .toast-close {
  color: #1e40af;
}

.toast-info .toast-action {
  color: #1e40af;
}

.toast-info .toast-action:hover {
  background-color: #dbeafe;
}

.toast-info .toast-link {
  color: var(--clr-info, #3B82F6);
}

.toast-info .toast-link:hover {
  color: #2563eb;
}
