/**
 * Toast Notifications - JamWatHQ Brand Styling
 * Design by: Nobara (Creative Strategy & UX)
 * Implementation by: Yuuji (Implementation Specialist)
 * Date: 2026-01-27
 *
 * Replaces native alert() calls with styled toast notifications
 * Follows JamWatHQ black/yellow aesthetic with colored borders
 */

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

.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 10003; /* Above modals (10001-10002) */
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
  max-height: calc(100vh - 40px);
  overflow: hidden;
}

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

.toast {
  width: 350px;
  min-height: 60px;
  padding: 16px 20px;
  border-radius: 10px;
  background: #000000;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  pointer-events: auto;
  position: relative;
  opacity: 0;
  transform: translateX(100%);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(0);
}

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

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

/* Success Toast */
.toast--success {
  border: 3px solid #22c55e;
  box-shadow: 0 10px 40px rgba(34, 197, 94, 0.3);
}

.toast--success .toast__icon {
  color: #22c55e;
}

.toast--success .toast__title {
  color: #22c55e;
}

/* Error Toast */
.toast--error {
  border: 3px solid #ef4444;
  box-shadow: 0 10px 40px rgba(239, 68, 68, 0.3);
}

.toast--error .toast__icon {
  color: #ef4444;
}

.toast--error .toast__title {
  color: #ef4444;
}

/* Warning Toast */
.toast--warning {
  border: 3px solid #ffee00;
  box-shadow: 0 10px 40px rgba(255, 238, 0, 0.3);
}

.toast--warning .toast__icon {
  color: #ffee00;
}

.toast--warning .toast__title {
  color: #ffee00;
}

/* Info Toast */
.toast--info {
  border: 3px solid #3b82f6;
  box-shadow: 0 10px 40px rgba(59, 130, 246, 0.3);
}

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

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

/* ========================================
   TOAST ICON
   ======================================== */

.toast__icon {
  flex-shrink: 0;
  font-size: 1.5rem;
  line-height: 1;
  margin-top: 2px;
}

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

.toast__content {
  flex: 1;
  min-width: 0;
  padding-right: 28px; /* Prevent text from overlapping close button */
}

.toast__title {
  font-weight: 700;
  font-size: 1rem;
  margin: 0 0 4px 0;
  line-height: 1.3;
}

.toast__message {
  color: #ffffff;
  font-size: 0.9rem;
  margin: 0;
  line-height: 1.4;
  word-wrap: break-word;
}

/* ========================================
   TOAST CLOSE BUTTON
   ======================================== */

.toast__close {
  position: absolute;
  top: 8px;
  right: 8px;
  background: transparent;
  border: none;
  color: #888888;
  font-size: 28px; /* ✅ TIER 2 STANDARD - Icon Size Standardization 2026-02-01 */
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  border-radius: 4px;
  transition: color 0.2s ease, background-color 0.2s ease;
}

.toast__close:hover {
  color: #ffffff;
  background-color: rgba(255, 255, 255, 0.1);
}

.toast__close:focus {
  outline: 2px solid #ffee00;
  outline-offset: 2px;
  color: #ffffff;
}

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

.toast__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: currentColor;
  border-radius: 0 0 0 7px;
  opacity: 0.5;
  transition: width linear;
}

.toast--success .toast__progress {
  background: #22c55e;
}

.toast--error .toast__progress {
  background: #ef4444;
}

.toast--warning .toast__progress {
  background: #ffee00;
}

.toast--info .toast__progress {
  background: #3b82f6;
}

/* Pause progress when hovering */
.toast:hover .toast__progress {
  animation-play-state: paused;
}

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

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

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

/* ========================================
   REDUCED MOTION SUPPORT
   ======================================== */

@media (prefers-reduced-motion: reduce) {
  .toast {
    transition: opacity 0.1s ease;
    transform: none;
  }

  .toast.show {
    transform: none;
  }

  .toast.hiding {
    transform: none;
  }

  .toast__progress {
    transition: none;
  }
}

/* ========================================
   MOBILE RESPONSIVE
   ======================================== */

@media (max-width: 480px) {
  .toast-container {
    left: 5%;
    right: 5%;
    top: 10px;
    width: auto;
  }

  .toast {
    width: 100%;
    padding: 14px 16px;
    min-height: 50px;
  }

  .toast__icon {
    font-size: 1.25rem;
  }

  .toast__title {
    font-size: 0.95rem;
  }

  .toast__message {
    font-size: 0.85rem;
  }

  .toast__close {
    top: 6px;
    right: 6px;
    font-size: 24px; /* ✅ TIER 2 MOBILE STANDARD - Icon Size Standardization 2026-02-01 */
  }

  .toast__content {
    padding-right: 24px; /* Prevent text from overlapping close button on mobile */
  }
}

/* ========================================
   TABLET RESPONSIVE
   ======================================== */

@media (max-width: 768px) and (min-width: 481px) {
  .toast-container {
    right: 15px;
  }

  .toast {
    width: 320px;
  }
}

/* ========================================
   STACKING BEHAVIOR
   ======================================== */

/* Limit visible toasts to prevent screen overflow */
.toast-container .toast:nth-child(n+4) {
  opacity: 0.7;
  transform: scale(0.95);
}

.toast-container .toast:nth-child(n+5) {
  display: none;
}
