/**
 * Flash Stack Notification System
 * ================================
 * Sistema de notificaciones apilables (hasta 4 simultáneas)
 * Compatible con temas claro/oscuro
 * 
 * Version: 1.0.0
 * Date: 2026-01-16
 */

/* Container - Fixed position in top-right corner */
.flash-stack-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 400px;
  width: 100%;
  pointer-events: none;
}

/* Adjust for auth pages without navbar */
.auth-body .flash-stack-container {
  top: 20px;
}

/* Individual notification */
.flash-stack-item {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  min-width: 300px;
  max-width: 400px;
  
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  box-shadow: 
    0 4px 6px -1px rgba(0, 0, 0, 0.1),
    0 2px 4px -1px rgba(0, 0, 0, 0.06),
    0 12px 40px rgba(0, 0, 0, 0.12);
  
  font-size: 0.9rem;
  font-weight: 500;
  line-height: 1.4;
  
  pointer-events: auto;
  
  /* Animation */
  animation: flashSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
  transform: translateX(100%);
  opacity: 0;
}

/* Animation states */
.flash-stack-item.flash-entering {
  animation: flashSlideIn 0.35s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

.flash-stack-item.flash-exiting {
  animation: flashSlideOut 0.3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Type-specific border colors */
.flash-stack-item[data-type="success"] {
  border-left: 4px solid #10b981;
}

.flash-stack-item[data-type="error"],
.flash-stack-item[data-type="danger"] {
  border-left: 4px solid #ef4444;
}

.flash-stack-item[data-type="warning"] {
  border-left: 4px solid #f59e0b;
}

.flash-stack-item[data-type="info"] {
  border-left: 4px solid #3b82f6;
}

/* Icon */
.flash-stack-icon {
  flex-shrink: 0;
  font-size: 1.25rem;
  line-height: 1;
  margin-top: 1px;
}

.flash-stack-item[data-type="success"] .flash-stack-icon {
  color: #10b981;
}

.flash-stack-item[data-type="error"] .flash-stack-icon,
.flash-stack-item[data-type="danger"] .flash-stack-icon {
  color: #ef4444;
}

.flash-stack-item[data-type="warning"] .flash-stack-icon {
  color: #f59e0b;
}

.flash-stack-item[data-type="info"] .flash-stack-icon {
  color: #3b82f6;
}

/* Content */
.flash-stack-content {
  flex: 1;
  min-width: 0;
  word-wrap: break-word;
  color: #1f2937;
}

/* Close button */
.flash-stack-close {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  margin: -4px -4px -4px 4px;
  
  background: transparent;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  opacity: 0.5;
  transition: all 0.2s ease;
  
  color: #6b7280;
  font-size: 1rem;
}

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

.flash-stack-close:focus {
  outline: none;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

/* Progress bar for auto-dismiss */
.flash-stack-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 0 0 12px 12px;
  overflow: hidden;
}

.flash-stack-progress-bar {
  height: 100%;
  width: 100%;
  transform-origin: left;
  animation: flashProgress linear forwards;
}

.flash-stack-item[data-type="success"] .flash-stack-progress-bar {
  background: #10b981;
}

.flash-stack-item[data-type="error"] .flash-stack-progress-bar,
.flash-stack-item[data-type="danger"] .flash-stack-progress-bar {
  background: #ef4444;
}

.flash-stack-item[data-type="warning"] .flash-stack-progress-bar {
  background: #f59e0b;
}

.flash-stack-item[data-type="info"] .flash-stack-progress-bar {
  background: #3b82f6;
}

/* ============================================
   DARK THEME STYLES
   ============================================ */

[data-bs-theme="dark"] .flash-stack-item {
  background: rgba(30, 32, 38, 0.98);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 
    0 4px 6px -1px rgba(0, 0, 0, 0.3),
    0 2px 4px -1px rgba(0, 0, 0, 0.2),
    0 12px 40px rgba(0, 0, 0, 0.4);
}

[data-bs-theme="dark"] .flash-stack-content {
  color: #e5e7eb;
}

[data-bs-theme="dark"] .flash-stack-close {
  color: #9ca3af;
}

[data-bs-theme="dark"] .flash-stack-close:hover {
  background: rgba(255, 255, 255, 0.1);
}

[data-bs-theme="dark"] .flash-stack-progress {
  background: rgba(255, 255, 255, 0.1);
}

/* Dark theme icon colors (slightly brighter) */
[data-bs-theme="dark"] .flash-stack-item[data-type="success"] .flash-stack-icon {
  color: #34d399;
}

[data-bs-theme="dark"] .flash-stack-item[data-type="error"] .flash-stack-icon,
[data-bs-theme="dark"] .flash-stack-item[data-type="danger"] .flash-stack-icon {
  color: #f87171;
}

[data-bs-theme="dark"] .flash-stack-item[data-type="warning"] .flash-stack-icon {
  color: #fbbf24;
}

[data-bs-theme="dark"] .flash-stack-item[data-type="info"] .flash-stack-icon {
  color: #60a5fa;
}

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

@keyframes flashSlideIn {
  0% {
    transform: translateX(100%);
    opacity: 0;
  }
  100% {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes flashSlideOut {
  0% {
    transform: translateX(0);
    opacity: 1;
  }
  100% {
    transform: translateX(100%);
    opacity: 0;
  }
}

@keyframes flashProgress {
  0% {
    transform: scaleX(1);
  }
  100% {
    transform: scaleX(0);
  }
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */

@media (max-width: 576px) {
  .flash-stack-container {
    top: 10px;
    right: 10px;
    left: 10px;
    max-width: none;
  }
  
  .flash-stack-item {
    min-width: 0;
    max-width: none;
    font-size: 0.85rem;
    padding: 12px 14px;
  }
  
  .flash-stack-icon {
    font-size: 1.1rem;
  }
}

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

@media (prefers-reduced-motion: reduce) {
  .flash-stack-item {
    animation: none;
    transform: translateX(0);
    opacity: 1;
  }
  
  .flash-stack-item.flash-exiting {
    animation: none;
    opacity: 0;
  }
  
  .flash-stack-progress-bar {
    animation: none;
  }
}
