/**
 * SGLE Toast/Notification System
 * Modern notification components inspired by Shadcn/UI Sonner
 * 
 * Features:
 * - Multiple variants (success, error, warning, info, default)
 * - Smooth animations (slide + fade)
 * - Toast stacking with proper spacing
 * - Action buttons support (undo, retry, etc)
 * - Promise-based toasts with loading/success/error states
 * - Rich content support (title, description, icons)
 * - Accessible (ARIA labels, keyboard support)
 * - Responsive (mobile-friendly positioning)
 * 
 * @package SGLE_Theme
 * @version 2.0.0
 * @since 2026-01-15
 */

/* ========================================
   TOAST CONTAINER
   ======================================== */

.sgle-toast-container {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 0.5rem; /* 8px */
}

/* Container Positioning Variants */
.sgle-toast-container-top-right {
  top: 1rem; /* 16px */
  right: 1rem;
}

.sgle-toast-container-top-left {
  top: 1rem;
  left: 1rem;
}

.sgle-toast-container-top-center {
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
}

.sgle-toast-container-bottom-right {
  bottom: 1rem;
  right: 1rem;
}

.sgle-toast-container-bottom-left {
  bottom: 1rem;
  left: 1rem;
}

.sgle-toast-container-bottom-center {
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
}

/* Mobile adjustments */
@media (max-width: 640px) {
  .sgle-toast-container {
    left: 1rem !important;
    right: 1rem !important;
    transform: none !important;
    width: calc(100% - 2rem);
  }
}

/* ========================================
   TOAST BASE STYLES
   ======================================== */

.sgle-toast {
  position: relative;
  pointer-events: auto;
  
  /* Layout */
  display: flex;
  align-items: flex-start;
  gap: 0.75rem; /* 12px */
  
  /* Sizing */
  min-width: 320px;
  max-width: 420px;
  width: 100%;
  padding: 1rem 1.25rem; /* 16px 20px */
  
  /* Visual */
  background-color: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 0.75rem; /* 12px */
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1),
              0 4px 6px -4px rgba(0, 0, 0, 0.1);
  
  /* Animation */
  opacity: 0;
  transform: translateX(100%);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  
  /* Typography */
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 0.875rem; /* 14px */
  line-height: 1.5;
  color: #0f172a;
}

/* Toast visible state */
.sgle-toast.sgle-toast-visible {
  opacity: 1;
  transform: translateX(0);
}

/* Toast exit state */
.sgle-toast.sgle-toast-exit {
  opacity: 0;
  transform: translateX(100%);
}

/* Mobile responsive */
@media (max-width: 640px) {
  .sgle-toast {
    min-width: unset;
    max-width: unset;
    width: 100%;
  }
}

/* ========================================
   TOAST CONTENT STRUCTURE
   ======================================== */

.sgle-toast-icon {
  flex-shrink: 0;
  width: 1.25rem; /* 20px */
  height: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.125rem; /* 2px - visual alignment */
}

.sgle-toast-icon .material-symbols-outlined {
  font-size: 1.25rem;
  font-variation-settings: 'FILL' 1, 'wght' 500;
}

.sgle-toast-content {
  flex: 1;
  min-width: 0; /* Allow text truncation */
}

.sgle-toast-title {
  font-weight: 600;
  font-size: 0.875rem; /* 14px */
  line-height: 1.25rem; /* 20px */
  color: #0f172a;
  margin: 0;
  margin-bottom: 0.25rem; /* 4px */
}

.sgle-toast-description {
  font-weight: 400;
  font-size: 0.875rem; /* 14px */
  line-height: 1.5rem; /* 24px */
  color: #64748b;
  margin: 0;
}

/* Single line toast (no title) */
.sgle-toast-description-only {
  color: #0f172a;
  font-weight: 500;
}

.sgle-toast-actions {
  display: flex;
  gap: 0.5rem; /* 8px */
  margin-top: 0.75rem; /* 12px */
}

.sgle-toast-close {
  flex-shrink: 0;
  width: 1.25rem;
  height: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  margin: 0;
  margin-top: 0.125rem;
  background: transparent;
  border: none;
  color: #64748b;
  cursor: pointer;
  border-radius: 0.375rem; /* 6px */
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

.sgle-toast-close:hover {
  background-color: #f1f5f9;
  color: #0f172a;
}

.sgle-toast-close:active {
  transform: scale(0.95);
}

.sgle-toast-close .material-symbols-outlined {
  font-size: 1.125rem; /* 18px */
  font-variation-settings: 'FILL' 0, 'wght' 400;
}

/* ========================================
   TOAST VARIANTS
   ======================================== */

/* Default Toast */
.sgle-toast-default {
  background-color: #ffffff;
  border-color: #e2e8f0;
}

.sgle-toast-default .sgle-toast-icon {
  color: #3b82f6;
}

/* Success Toast */
.sgle-toast-success {
  background-color: #f0fdf4;
  border-color: #86efac;
}

.sgle-toast-success .sgle-toast-icon {
  color: #10b981;
}

.sgle-toast-success .sgle-toast-title {
  color: #065f46;
}

/* Error Toast */
.sgle-toast-error {
  background-color: #fef2f2;
  border-color: #fecaca;
}

.sgle-toast-error .sgle-toast-icon {
  color: #ef4444;
}

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

/* Warning Toast */
.sgle-toast-warning {
  background-color: #fffbeb;
  border-color: #fde68a;
}

.sgle-toast-warning .sgle-toast-icon {
  color: #f59e0b;
}

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

/* Info Toast */
.sgle-toast-info {
  background-color: #eff6ff;
  border-color: #bfdbfe;
}

.sgle-toast-info .sgle-toast-icon {
  color: #3b82f6;
}

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

/* Loading Toast */
.sgle-toast-loading {
  background-color: #ffffff;
  border-color: #cbd5e1;
}

.sgle-toast-loading .sgle-toast-icon {
  color: #64748b;
}

/* ========================================
   TOAST ACTION BUTTONS
   ======================================== */

.sgle-toast-action-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.375rem; /* 6px */
  
  padding: 0.375rem 0.75rem; /* 6px 12px */
  
  font-size: 0.75rem; /* 12px */
  font-weight: 600;
  line-height: 1rem;
  text-decoration: none;
  
  border: 1px solid transparent;
  border-radius: 0.5rem; /* 8px */
  
  cursor: pointer;
  transition: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
  
  white-space: nowrap;
}

.sgle-toast-action-btn:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Primary action button */
.sgle-toast-action-btn-primary {
  background-color: #3b82f6;
  color: #ffffff;
  border-color: #3b82f6;
}

.sgle-toast-action-btn-primary:hover {
  background-color: #2563eb;
  border-color: #2563eb;
}

.sgle-toast-action-btn-primary:active {
  background-color: #1d4ed8;
  transform: scale(0.97);
}

/* Secondary action button */
.sgle-toast-action-btn-secondary {
  background-color: transparent;
  color: #64748b;
  border-color: #e2e8f0;
}

.sgle-toast-action-btn-secondary:hover {
  background-color: #f8fafc;
  color: #334155;
  border-color: #cbd5e1;
}

.sgle-toast-action-btn-secondary:active {
  background-color: #f1f5f9;
  transform: scale(0.97);
}

/* Ghost action button */
.sgle-toast-action-btn-ghost {
  background-color: transparent;
  color: #64748b;
  border-color: transparent;
}

.sgle-toast-action-btn-ghost:hover {
  background-color: #f8fafc;
  color: #334155;
}

.sgle-toast-action-btn-ghost:active {
  background-color: #f1f5f9;
}

/* Variant-specific action button colors */
.sgle-toast-success .sgle-toast-action-btn-primary {
  background-color: #10b981;
  border-color: #10b981;
}

.sgle-toast-success .sgle-toast-action-btn-primary:hover {
  background-color: #059669;
}

.sgle-toast-error .sgle-toast-action-btn-primary {
  background-color: #ef4444;
  border-color: #ef4444;
}

.sgle-toast-error .sgle-toast-action-btn-primary:hover {
  background-color: #dc2626;
}

.sgle-toast-warning .sgle-toast-action-btn-primary {
  background-color: #f59e0b;
  border-color: #f59e0b;
}

.sgle-toast-warning .sgle-toast-action-btn-primary:hover {
  background-color: #d97706;
}

/* ========================================
   TOAST LOADING SPINNER
   ======================================== */

.sgle-toast-spinner {
  display: inline-block;
  width: 1.25rem; /* 20px */
  height: 1.25rem;
  border: 2px solid #e2e8f0;
  border-top-color: #3b82f6;
  border-radius: 50%;
  animation: sgle-toast-spin 0.8s linear infinite;
}

@keyframes sgle-toast-spin {
  to {
    transform: rotate(360deg);
  }
}

/* ========================================
   TOAST PROGRESS BAR
   ======================================== */

.sgle-toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background-color: rgba(0, 0, 0, 0.1);
  border-bottom-left-radius: 0.75rem;
  border-bottom-right-radius: 0.75rem;
  overflow: hidden;
}

.sgle-toast-progress-bar {
  height: 100%;
  background-color: currentColor;
  transition: width 0.1s linear;
}

.sgle-toast-success .sgle-toast-progress-bar {
  background-color: #10b981;
}

.sgle-toast-error .sgle-toast-progress-bar {
  background-color: #ef4444;
}

.sgle-toast-warning .sgle-toast-progress-bar {
  background-color: #f59e0b;
}

.sgle-toast-info .sgle-toast-progress-bar {
  background-color: #3b82f6;
}

.sgle-toast-default .sgle-toast-progress-bar {
  background-color: #3b82f6;
}

/* ========================================
   TOAST ANIMATIONS
   ======================================== */

/* Slide in from right */
@keyframes sgle-toast-slide-in-right {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Slide out to right */
@keyframes sgle-toast-slide-out-right {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(100%);
    opacity: 0;
  }
}

/* Slide in from left */
@keyframes sgle-toast-slide-in-left {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* Slide out to left */
@keyframes sgle-toast-slide-out-left {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(-100%);
    opacity: 0;
  }
}

/* Slide in from top */
@keyframes sgle-toast-slide-in-top {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Slide out to top */
@keyframes sgle-toast-slide-out-top {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(-100%);
    opacity: 0;
  }
}

/* Slide in from bottom */
@keyframes sgle-toast-slide-in-bottom {
  from {
    transform: translateY(100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Slide out to bottom */
@keyframes sgle-toast-slide-out-bottom {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(100%);
    opacity: 0;
  }
}

/* Scale in */
@keyframes sgle-toast-scale-in {
  from {
    transform: scale(0.95);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* Scale out */
@keyframes sgle-toast-scale-out {
  from {
    transform: scale(1);
    opacity: 1;
  }
  to {
    transform: scale(0.95);
    opacity: 0;
  }
}

/* Animation classes */
.sgle-toast-animate-in-right {
  animation: sgle-toast-slide-in-right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sgle-toast-animate-out-right {
  animation: sgle-toast-slide-out-right 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sgle-toast-animate-in-left {
  animation: sgle-toast-slide-in-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sgle-toast-animate-out-left {
  animation: sgle-toast-slide-out-left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sgle-toast-animate-in-top {
  animation: sgle-toast-slide-in-top 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sgle-toast-animate-out-top {
  animation: sgle-toast-slide-out-top 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sgle-toast-animate-in-bottom {
  animation: sgle-toast-slide-in-bottom 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sgle-toast-animate-out-bottom {
  animation: sgle-toast-slide-out-bottom 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.sgle-toast-animate-in-scale {
  animation: sgle-toast-scale-in 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.sgle-toast-animate-out-scale {
  animation: sgle-toast-scale-out 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========================================
   TOAST STACKING
   ======================================== */

/* Progressive scale and opacity for stacked toasts */
.sgle-toast:not(.sgle-toast-visible) + .sgle-toast {
  transform: translateY(-0.5rem) scale(0.98);
  opacity: 0.8;
}

.sgle-toast:not(.sgle-toast-visible) + .sgle-toast + .sgle-toast {
  transform: translateY(-1rem) scale(0.96);
  opacity: 0.6;
}

.sgle-toast:not(.sgle-toast-visible) + .sgle-toast + .sgle-toast + .sgle-toast {
  opacity: 0;
  pointer-events: none;
}

/* ========================================
   ACCESSIBILITY
   ======================================== */

/* Focus visible states */
.sgle-toast:focus-visible {
  outline: 2px solid #3b82f6;
  outline-offset: 2px;
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .sgle-toast,
  .sgle-toast-close,
  .sgle-toast-action-btn {
    transition: none;
    animation: none;
  }
  
  .sgle-toast-spinner {
    animation-duration: 1.5s;
  }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .sgle-toast {
    border-width: 2px;
  }
  
  .sgle-toast-action-btn {
    border-width: 2px;
  }
}

/* ========================================
   DARK MODE SUPPORT (Future-ready)
   ======================================== */

.dark .sgle-toast-default {
  background-color: #1e293b;
  border-color: #334155;
}

.dark .sgle-toast-default .sgle-toast-title {
  color: #f8fafc;
}

.dark .sgle-toast-default .sgle-toast-description {
  color: #cbd5e1;
}

.dark .sgle-toast-close {
  color: #94a3b8;
}

.dark .sgle-toast-close:hover {
  background-color: #334155;
  color: #f8fafc;
}

/* Dark mode variants would go here when dark mode is implemented */

/* ========================================
   UTILITY CLASSES
   ======================================== */

.sgle-toast-full-width {
  width: 100%;
  max-width: 100%;
}

.sgle-toast-compact {
  padding: 0.75rem 1rem; /* 12px 16px */
  min-width: 280px;
}

.sgle-toast-no-icon .sgle-toast-icon {
  display: none;
}

.sgle-toast-no-close .sgle-toast-close {
  display: none;
}

/* ========================================
   MEDIA QUERIES
   ======================================== */

/* Tablet and below */
@media (max-width: 768px) {
  .sgle-toast {
    min-width: 280px;
    max-width: 100%;
  }
  
  .sgle-toast-title {
    font-size: 0.8125rem; /* 13px */
  }
  
  .sgle-toast-description {
    font-size: 0.8125rem; /* 13px */
  }
}

/* Mobile */
@media (max-width: 480px) {
  .sgle-toast {
    padding: 0.875rem 1rem; /* 14px 16px */
  }
  
  .sgle-toast-actions {
    flex-direction: column;
    width: 100%;
  }
  
  .sgle-toast-action-btn {
    width: 100%;
    justify-content: center;
  }
}
