/* ==========================================================================
   TOAST NOTIFICATIONS COMPONENT
   Modern toast notifications with CSS variables integration
   ========================================================================== */

/* Container */
.toast-container {
  position: fixed;
  top: var(--space-5, 20px);
  right: var(--space-5, 20px);
  z-index: var(--z-toast, 1080);
  max-width: 400px;
  display: flex;
  flex-direction: column;
  gap: var(--space-3, 12px);
  pointer-events: none;
}

/* Toast Base */
.toast {
  background: var(--bg-surface, #ffffff);
  border-radius: var(--radius-lg, 8px);
  box-shadow: var(--shadow-lg, 0 10px 25px rgba(0, 0, 0, 0.15));
  padding: var(--space-4, 16px) var(--space-5, 20px);
  display: flex;
  align-items: flex-start;
  gap: var(--space-3, 12px);
  min-width: 320px;
  pointer-events: auto;
  transform: translateX(calc(100% + 40px));
  opacity: 0;
  transition: all var(--transition-slow, 300ms)
    var(--ease-out, cubic-bezier(0, 0, 0.2, 1));
  border-left: 4px solid transparent;
  position: relative;
  overflow: hidden;
}

/* Show State */
.toast.show {
  transform: translateX(0);
  opacity: 1;
}

/* Hide State */
.toast.hide {
  transform: translateX(calc(100% + 40px));
  opacity: 0;
}

/* Toast Types - Border Colors */
.toast.success {
  border-left-color: var(--success, #10b981);
  background-color: #ffffff;
}

.toast.error {
  border-left-color: var(--danger, #ef4444);
}

.toast.warning {
  border-left-color: var(--warning, #f59e0b);
}

.toast.info {
  border-left-color: var(--info, #3b82f6);
}

/* Toast Icon */
.toast-icon {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full, 9999px);
  font-size: 12px;
}

.toast.success .toast-icon {
  background: rgba(16, 185, 129, 0.1);
  color: var(--success, #10b981);
}

.toast.error .toast-icon {
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger, #ef4444);
}

.toast.warning .toast-icon {
  background: rgba(245, 158, 11, 0.1);
  color: var(--warning, #f59e0b);
}

.toast.info .toast-icon {
  background: rgba(59, 130, 246, 0.1);
  color: var(--info, #3b82f6);
}

/* Toast Content */
.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-weight: var(--font-semibold, 600);
  font-size: var(--text-sm, 14px);
  line-height: var(--leading-tight, 1.25);
  margin: 0 0 var(--space-1, 4px) 0;
  color: var(--text-primary, #111827);
}

.toast-message {
  font-size: var(--text-sm, 13px);
  line-height: var(--leading-normal, 1.5);
  color: var(--text-secondary, #6b7280);
  margin: 0;
  word-wrap: break-word;
}

.toast-message a {
  color: var(--primary, #3b82f6);
  font-weight: var(--font-medium, 500);
  text-decoration: none;
}

.toast-message a:hover {
  text-decoration: underline;
}

/* Close Button */
.toast-close {
  position: absolute;
  top: var(--space-2, 8px);
  right: var(--space-2, 8px);
  background: none;
  border: none;
  color: var(--gray-400, #9ca3af);
  cursor: pointer;
  padding: var(--space-1, 4px);
  border-radius: var(--radius-sm, 4px);
  transition: all var(--transition-fast, 150ms) var(--ease-in-out);
  line-height: 1;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0;
}

.toast-close:hover {
  background: var(--gray-100, #f3f4f6);
  color: var(--gray-600, #4b5563);
}

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

/* Progress Bar */
.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  width: 100%;
  transition: width linear;
}

.toast.success .toast-progress {
  background: var(--success, #10b981);
  opacity: 0.3;
}

.toast.error .toast-progress {
  background: var(--danger, #ef4444);
  opacity: 0.3;
}

.toast.warning .toast-progress {
  background: var(--warning, #f59e0b);
  opacity: 0.3;
}

.toast.info .toast-progress {
  background: var(--info, #3b82f6);
  opacity: 0.3;
}

/* Hover Effects */
.toast:hover {
  box-shadow: var(--shadow-xl, 0 20px 25px -5px rgba(0, 0, 0, 0.1));
}

.toast:hover .toast-progress {
  animation-play-state: paused;
}

/* Paused State (for progress bar) */
.toast.paused .toast-progress {
  animation-play-state: paused;
}

/* ========================================
   RESPONSIVE STYLES
   ======================================== */

@media (max-width: 549px) {
  .toast-container {
    top: var(--space-3, 12px);
    right: var(--space-3, 12px);
    left: var(--space-3, 12px);
    max-width: none;
  }

  .toast {
    min-width: auto;
    width: 100%;
    transform: translateY(-100%);
  }

  .toast.show {
    transform: translateY(0);
  }

  .toast.hide {
    transform: translateY(-100%);
  }
}

/* ========================================
   WOOCOMMERCE INTEGRATION
   Hide original WooCommerce notices
   ======================================== */

body.use-toast-notifications .woocommerce-message,
body.use-toast-notifications .woocommerce-error,
body.use-toast-notifications .woocommerce-info,
body.use-toast-notifications .message-wrapper,
body.use-toast-notifications .widget_shopping_cart_live_region {
  display: none !important;
}

/* Hide WooCommerce cart fragments live region (accessibility element we replace with toast) */
.widget_shopping_cart_live_region.screen-reader-text {
  display: none !important;
}

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

@keyframes toast-slide-in {
  from {
    transform: translateX(calc(100% + 40px));
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes toast-slide-out {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(calc(100% + 40px));
    opacity: 0;
  }
}

@keyframes toast-progress {
  from {
    width: 100%;
  }
  to {
    width: 0%;
  }
}
