/**
 * Toast Notification Styles
 * 
 * Fixed position container in top-right corner with highest z-index
 * to prevent layout shift when toasts appear/disappear.
 */

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
  pointer-events: none; /* Allow clicks to pass through empty space */
}

.toast-item {
  pointer-events: auto; /* Re-enable clicks on actual toasts */
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  font-size: 0.95rem;
  line-height: 1.4;
  overflow-wrap: break-word;
  white-space: normal;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast-item span {
  flex: 1;
  min-width: 0;
  margin-right: 8px;
  overflow-wrap: break-word;
}

.toast-item .btn-close {
  flex-shrink: 0;
  opacity: 0.6;
  transition: opacity 0.2s ease;
}

.toast-item .btn-close:hover {
  opacity: 1;
}

/* Toast type styles (Bootstrap-inspired) */
.toast-item.toast-success {
  background-color: #d1e7dd;
  color: #0f5132;
  border-left: 4px solid #198754;
}

.toast-item.toast-danger {
  background-color: #f8d7da;
  color: #842029;
  border-left: 4px solid #dc3545;
}

.toast-item.toast-warning {
  background-color: #fff3cd;
  color: #664d03;
  border-left: 4px solid #ffc107;
}

.toast-item.toast-info {
  background-color: #cfe2ff;
  color: #084298;
  border-left: 4px solid #0d6efd;
}

/* Animation classes */
.toast-item.fade-in {
  animation: toastSlideIn 0.3s ease forwards;
}

.toast-item.fade-out {
  animation: toastSlideOut 0.3s ease forwards;
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastSlideOut {
  from {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
  to {
    opacity: 0;
    transform: translateX(100%) scale(0.9);
  }
}

/* ============================================================================
   Accessibility: Reduced Motion Support
   ============================================================================ */

/**
 * For users with motion sensitivity (prefers-reduced-motion), disable
 * slide/scale animations and use instant opacity fade instead.
 * 
 * WCAG 2.1 Success Criterion 2.3.3 (AAA): Animation from Interactions
 */
@media (prefers-reduced-motion: reduce) {
  .toast-item.fade-in,
  .toast-item.fade-out {
    animation: none;
    transition: opacity 0.2s ease;
  }

  .toast-item.fade-in {
    opacity: 1;
    transform: none;
  }

  .toast-item.fade-out {
    opacity: 0;
    transform: none;
  }

  /* Disable coin bounce and amount pop for FP toasts */
  .toast-fp-icon,
  .toast-fp-amount {
    animation: none !important;
  }
}

/* ============================================================================
   Accessibility: Keyboard Navigation
   ============================================================================ */

/**
 * Focus indicator for keyboard users (WCAG 2.1 SC 2.4.7: Focus Visible)
 * 2px blue outline with offset for visibility against all toast backgrounds
 */
.toast-item:focus {
  outline: 2px solid #0d6efd;
  outline-offset: 3px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15), 0 0 0 3px rgba(13, 110, 253, 0.25);
}

.toast-item:focus-visible {
  outline: 2px solid #0d6efd;
  outline-offset: 3px;
}

/* Positioned toast container (admin preview mode) */
.toast-container-positioned {
  position: fixed;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: 400px;
  pointer-events: none;
  z-index: 9999;
}

.toast-container-positioned .toast-item {
  pointer-events: auto;
}

/* Ensure close button is keyboard accessible */
.toast-item .btn-close:focus {
  outline: 2px solid #0d6efd;
  outline-offset: 2px;
  opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 576px) {
  .toast-container {
    left: 10px;
    right: 10px;
    max-width: calc(100vw - 20px);
  }

  .toast-item {
    font-size: 0.9rem;
    padding: 10px 14px;
    max-width: 100%;
  }
  
  /* Positioned toasts on mobile should stay visible */
  .toast-container-positioned {
    max-width: calc(100vw - 20px);
  }
}

/* FP (Fortunio Points) Award Toast - Special golden styling */
.toast-item.toast-fp {
  background: linear-gradient(135deg, #ffc107 0%, #ff9800 50%, #f57c00 100%);
  color: #1a1a1a;
  border: none;
  border-left: 4px solid #e65100;
  font-weight: 600;
  gap: 8px;
  display: flex;
  flex-direction: row;
  align-items: center;
}

.toast-fp-icon {
  font-size: 1.4em;
  margin-right: 4px;
  flex-shrink: 0;
  animation: coinBounce 0.5s ease-out;
}

.toast-fp-amount {
  font-size: 1.1em;
  font-weight: 700;
  color: #1a1a1a;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.5);
  animation: fpAmountPop 0.4s ease-out 0.1s both;
  flex-shrink: 0;
  white-space: nowrap;
}

.toast-fp-label {
  font-size: 0.85em;
  font-weight: 500;
  color: #333;
  opacity: 0.9;
  margin-left: 4px;
  white-space: nowrap;
  flex-shrink: 0;
}

.toast-item.toast-fp .btn-close {
  filter: none;
}

/* Coin bounce animation */
@keyframes coinBounce {
  0%, 100% { transform: translateY(0); }
  25% { transform: translateY(-5px); }
  50% { transform: translateY(2px); }
  75% { transform: translateY(-2px); }
}

/* Amount pop animation */
@keyframes fpAmountPop {
  0% { 
    transform: scale(0.5);
    opacity: 0;
  }
  50% { 
    transform: scale(1.2);
  }
  100% { 
    transform: scale(1);
    opacity: 1;
  }
}
