/* ==========================================================================
   ALERT & TOAST COMPONENT
   ========================================================================== */

/*
 * Notification system for feedback messages
 * Supports static alerts (inline) and toast notifications (floating)
 * 
 * Usage:
 *   <!-- Static Alert -->
 *   <div class="ds-alert" data-variant="success">
 *     <div class="ds-alert__icon">...</div>
 *     <div class="ds-alert__content">
 *       <h4 class="ds-alert__title">Success!</h4>
 *       <p class="ds-alert__message">Your changes have been saved.</p>
 *     </div>
 *     <button class="ds-alert__close">×</button>
 *   </div>
 * 
 *   <!-- Toast (via JS) -->
 *   Toast.show('Success!', 'Your changes have been saved.', 'success');
 * 
 * Variants: success | warning | danger | info
 * Types: alert (static) | toast (floating)
 */


/* ==========================================================================
   BASE ALERT
   ========================================================================== */

.ds-alert {
  display: flex;
  align-items: flex-start;
  gap: 0.75rem;
  
  padding: 1rem;
  border-radius: 0.5rem;
  border: 1.5px solid transparent;
  
  font-family: var(--font-primary);
  
  position: relative;
  overflow: hidden;
  
  transition: all 0.2s ease;
}

.ds-alert::before {
  content: '';
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  width: 4px;
}


/* ==========================================================================
   ALERT STRUCTURE
   ========================================================================== */

.ds-alert__icon {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin-top: 2px;
}

.ds-alert__icon svg {
  width: 100%;
  height: 100%;
}

.ds-alert__content {
  flex: 1;
  min-width: 0;
}

.ds-alert__title {
  font-size: 0.9375rem;
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 0.25rem 0;
}

.ds-alert__message {
  font-size: 0.875rem;
  line-height: 1.5;
  margin: 0;
  opacity: 0.9;
}

/* Title-only alert (no message) */
.ds-alert__title:last-child {
  margin-bottom: 0;
}

.ds-alert__close {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  
  display: flex;
  align-items: center;
  justify-content: center;
  
  background: transparent;
  border: none;
  border-radius: 0.25rem;
  
  font-size: 1.25rem;
  line-height: 1;
  color: currentColor;
  opacity: 0.6;
  
  cursor: pointer;
  transition: all 0.15s ease;
}

.ds-alert__close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.08);
}

[data-theme="dark"] .ds-alert__close:hover {
  background: rgba(255, 255, 255, 0.1);
}

.ds-alert__close:active {
  transform: scale(0.95);
}


/* ==========================================================================
   ALERT ACTIONS (optional action buttons)
   ========================================================================== */

.ds-alert__actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.ds-alert__action {
  padding: 0.375rem 0.75rem;
  
  font-size: 0.875rem;
  font-weight: 600;
  
  background: transparent;
  border: 1.5px solid currentColor;
  border-radius: 0.25rem;
  
  color: currentColor;
  cursor: pointer;
  
  transition: all 0.15s ease;
}

.ds-alert__action:hover {
  background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .ds-alert__action:hover {
  background: rgba(255, 255, 255, 0.08);
}


/* ==========================================================================
   COLOR VARIANTS - SUCCESS
   ========================================================================== */

.ds-alert[data-variant="success"] {
  background: #F9F9F9; /* Changed from transparent rgba to solid linen white */
  color: #065F46;
  border-color: rgba(5, 150, 105, 0.2);
}

.ds-alert[data-variant="success"]::before {
  background: #059669;
}

.ds-alert[data-variant="success"] .ds-alert__icon {
  color: #059669;
}

[data-theme="dark"] .ds-alert[data-variant="success"] {
  background: rgba(16, 185, 129, 0.12);
  color: #A7F3D0;
  border-color: rgba(16, 185, 129, 0.25);
}

[data-theme="dark"] .ds-alert[data-variant="success"]::before {
  background: #10B981;
}

[data-theme="dark"] .ds-alert[data-variant="success"] .ds-alert__icon {
  color: #10B981;
}


/* ==========================================================================
   COLOR VARIANTS - WARNING
   ========================================================================== */

.ds-alert[data-variant="warning"] {
  background: #F9F9F9; /* Changed from transparent rgba to solid linen white */
  color: #92400E;
  border-color: rgba(217, 119, 6, 0.2);
}

.ds-alert[data-variant="warning"]::before {
  background: #D97706;
}

.ds-alert[data-variant="warning"] .ds-alert__icon {
  color: #D97706;
}

[data-theme="dark"] .ds-alert[data-variant="warning"] {
  background: rgba(245, 158, 11, 0.12);
  color: #FDE68A;
  border-color: rgba(245, 158, 11, 0.25);
}

[data-theme="dark"] .ds-alert[data-variant="warning"]::before {
  background: #F59E0B;
}

[data-theme="dark"] .ds-alert[data-variant="warning"] .ds-alert__icon {
  color: #F59E0B;
}


/* ==========================================================================
   COLOR VARIANTS - DANGER
   ========================================================================== */

.ds-alert[data-variant="danger"] {
  background: #F9F9F9; /* Changed from transparent rgba to solid linen white */
  color: #991B1B;
  border-color: rgba(220, 38, 38, 0.2);
}

.ds-alert[data-variant="danger"]::before {
  background: #DC2626;
}

.ds-alert[data-variant="danger"] .ds-alert__icon {
  color: #DC2626;
}

[data-theme="dark"] .ds-alert[data-variant="danger"] {
  background: rgba(239, 68, 68, 0.12);
  color: #FECACA;
  border-color: rgba(239, 68, 68, 0.25);
}

[data-theme="dark"] .ds-alert[data-variant="danger"]::before {
  background: #EF4444;
}

[data-theme="dark"] .ds-alert[data-variant="danger"] .ds-alert__icon {
  color: #EF4444;
}


/* ==========================================================================
   COLOR VARIANTS - INFO
   ========================================================================== */

.ds-alert[data-variant="info"] {
  background: #F9F9F9; /* Changed from transparent rgba to solid linen white */
  color: #1E3A8A;
  border-color: rgba(37, 99, 235, 0.2);
}

.ds-alert[data-variant="info"]::before {
  background: #2563EB;
}

.ds-alert[data-variant="info"] .ds-alert__icon {
  color: #2563EB;
}

[data-theme="dark"] .ds-alert[data-variant="info"] {
  background: rgba(59, 130, 246, 0.12);
  color: #BFDBFE;
  border-color: rgba(59, 130, 246, 0.25);
}

[data-theme="dark"] .ds-alert[data-variant="info"]::before {
  background: #3B82F6;
}

[data-theme="dark"] .ds-alert[data-variant="info"] .ds-alert__icon {
  color: #3B82F6;
}


/* ==========================================================================
   TOAST NOTIFICATIONS (floating)
   ========================================================================== */

.ds-toast-container {
  position: fixed;
  z-index: 10000;
  
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  
  pointer-events: none;
}

/* Toast positions */
.ds-toast-container[data-position="top-right"] {
  top: 1rem;
  right: 1rem;
  align-items: flex-end;
}

.ds-toast-container[data-position="top-left"] {
  top: 1rem;
  left: 1rem;
  align-items: flex-start;
}

.ds-toast-container[data-position="top-center"] {
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  align-items: center;
}

.ds-toast-container[data-position="bottom-right"] {
  bottom: 1rem;
  right: 1rem;
  align-items: flex-end;
}

.ds-toast-container[data-position="bottom-left"] {
  bottom: 1rem;
  left: 1rem;
  align-items: flex-start;
}

.ds-toast-container[data-position="bottom-center"] {
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  align-items: center;
}

.ds-toast {
  min-width: 320px;
  max-width: 500px;
  
  pointer-events: auto;
  
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15),
              0 4px 10px rgba(0, 0, 0, 0.08);
  
  animation: toast-slide-in 0.3s ease-out;
}

[data-theme="dark"] .ds-toast {
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.4),
              0 4px 10px rgba(0, 0, 0, 0.3);
}

/* Toast entering animation */
@keyframes toast-slide-in {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.ds-toast-container[data-position="top-left"] .ds-toast,
.ds-toast-container[data-position="bottom-left"] .ds-toast {
  animation: toast-slide-in-left 0.3s ease-out;
}

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

.ds-toast-container[data-position="top-center"] .ds-toast,
.ds-toast-container[data-position="bottom-center"] .ds-toast {
  animation: toast-slide-in-top 0.3s ease-out;
}

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

/* Toast leaving animation */
.ds-toast.is-leaving {
  animation: toast-slide-out 0.2s ease-in forwards;
}

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

/* Toast progress bar (auto-hide indicator) */
.ds-toast__progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: currentColor;
  opacity: 0.3;
  border-radius: 0 0 0.5rem 0.5rem;
  transition: width linear;
}


/* ==========================================================================
   SIZE VARIANTS
   ========================================================================== */

.ds-alert[data-size="sm"] {
  padding: 0.75rem;
  gap: 0.5rem;
}

.ds-alert[data-size="sm"] .ds-alert__icon {
  width: 16px;
  height: 16px;
}

.ds-alert[data-size="sm"] .ds-alert__title {
  font-size: 0.875rem;
}

.ds-alert[data-size="sm"] .ds-alert__message {
  font-size: 0.8125rem;
}

.ds-alert[data-size="lg"] {
  padding: 1.25rem;
  gap: 1rem;
}

.ds-alert[data-size="lg"] .ds-alert__icon {
  width: 24px;
  height: 24px;
}

.ds-alert[data-size="lg"] .ds-alert__title {
  font-size: 1rem;
}

.ds-alert[data-size="lg"] .ds-alert__message {
  font-size: 0.9375rem;
}


/* ==========================================================================
   COMPACT VARIANT (no icon, smaller padding)
   ========================================================================== */

.ds-alert[data-compact] {
  padding: 0.75rem 1rem;
  gap: 0.5rem;
}

.ds-alert[data-compact] .ds-alert__icon {
  display: none;
}


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

.ds-alert:focus-within {
  outline: 2px solid var(--color-primary, #34568B);
  outline-offset: 2px;
}

/* Announce to screen readers */
.ds-alert[role="alert"],
.ds-toast[role="alert"] {
  /* Automatically announced by assistive tech */
}

/* Screen reader only content */
.ds-alert__sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}


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

@media (max-width: 640px) {
  .ds-toast {
    min-width: calc(100vw - 2rem);
    max-width: calc(100vw - 2rem);
  }
  
  .ds-toast-container[data-position="top-right"],
  .ds-toast-container[data-position="top-left"],
  .ds-toast-container[data-position="bottom-right"],
  .ds-toast-container[data-position="bottom-left"] {
    left: 1rem;
    right: 1rem;
  }
  
  .ds-toast-container[data-position="top-center"],
  .ds-toast-container[data-position="bottom-center"] {
    left: 1rem;
    right: 1rem;
    transform: none;
  }
}
