/* ============================================
   ALERTS COMPONENT - CASCADE OF HOPE HMS
   ============================================ */

/* ============================================
   BASE ALERT
   ============================================ */

.alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  margin-bottom: var(--space-4);
  animation: slideDown var(--transition-base);
}

@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-1rem);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.alert-icon {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  margin-top: 0.125rem;
}

.alert-content {
  flex: 1;
  min-width: 0;
}

.alert-title {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  margin-bottom: var(--space-1);
}

.alert-message {
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
}

.alert-close {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  background: none;
  border: none;
  color: currentColor;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.alert-close:hover {
  opacity: 1;
}

/* ============================================
   ALERT VARIANTS
   ============================================ */

.alert-success {
  background-color: var(--success-light);
  border-color: var(--success);
  color: var(--success-dark);
}

.alert-success .alert-icon {
  color: var(--success);
}

.alert-danger,
.alert-error {
  background-color: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger-dark);
}

.alert-danger .alert-icon,
.alert-error .alert-icon {
  color: var(--danger);
}

.alert-warning {
  background-color: var(--warning-light);
  border-color: var(--warning);
  color: var(--warning-dark);
}

.alert-warning .alert-icon {
  color: var(--warning);
}

.alert-info {
  background-color: var(--info-light);
  border-color: var(--info);
  color: var(--info-dark);
}

.alert-info .alert-icon {
  color: var(--info);
}

/* ============================================
   ALERT WITH ACTIONS
   ============================================ */

.alert-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.alert-action-btn {
  padding: var(--space-1) var(--space-3);
  background-color: currentColor;
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
  opacity: 0.9;
}

.alert-action-btn:hover {
  opacity: 1;
}

.alert-action-btn.secondary {
  background-color: transparent;
  color: currentColor;
  border: 1px solid currentColor;
}

/* ============================================
   DISMISSIBLE ALERT
   ============================================ */

.alert-dismissible {
  position: relative;
}

.alert-dismissible.dismissed {
  animation: slideUp var(--transition-base);
}

@keyframes slideUp {
  to {
    opacity: 0;
    transform: translateY(-1rem);
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-bottom: 0;
  }
}

/* ============================================
   TOAST NOTIFICATIONS
   ============================================ */

.toast-container {
  position: fixed;
  z-index: var(--z-notification);
  pointer-events: none;
}

.toast-container.top-right {
  top: var(--space-4);
  right: var(--space-4);
}

.toast-container.top-left {
  top: var(--space-4);
  left: var(--space-4);
}

.toast-container.top-center {
  top: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
}

.toast-container.bottom-right {
  bottom: var(--space-4);
  right: var(--space-4);
}

.toast-container.bottom-left {
  bottom: var(--space-4);
  left: var(--space-4);
}

.toast-container.bottom-center {
  bottom: var(--space-4);
  left: 50%;
  transform: translateX(-50%);
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  min-width: 300px;
  max-width: 500px;
  padding: var(--space-4);
  background-color: var(--bg-elevated);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
  margin-bottom: var(--space-3);
  border-left: 4px solid;
  pointer-events: auto;
  animation: toastSlideIn var(--transition-base);
}

@keyframes toastSlideIn {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.toast.toast-exit {
  animation: toastSlideOut var(--transition-base);
}

@keyframes toastSlideOut {
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

.toast-success {
  border-left-color: var(--success);
}

.toast-success .toast-icon {
  color: var(--success);
}

.toast-error,
.toast-danger {
  border-left-color: var(--danger);
}

.toast-error .toast-icon,
.toast-danger .toast-icon {
  color: var(--danger);
}

.toast-warning {
  border-left-color: var(--warning);
}

.toast-warning .toast-icon {
  color: var(--warning);
}

.toast-info {
  border-left-color: var(--info);
}

.toast-info .toast-icon {
  color: var(--info);
}

.toast-icon {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
}

.toast-content {
  flex: 1;
  min-width: 0;
}

.toast-title {
  font-size: var(--text-base);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
  margin-bottom: var(--space-1);
}

.toast-message {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}

.toast-close {
  flex-shrink: 0;
  width: 1.5rem;
  height: 1.5rem;
  padding: 0;
  background: none;
  border: none;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: color var(--transition-fast);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
}

.toast-close:hover {
  color: var(--text-primary);
}

.toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background-color: currentColor;
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  transform-origin: left;
  animation: toastProgress 5s linear;
}

@keyframes toastProgress {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

/* ============================================
   MODAL OVERLAY (Confirmation Dialogs)
   ============================================ */

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(2px);
}

.modal-overlay.show {
  opacity: 1;
}

/* Modal Content */
.modal-overlay > div {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  max-width: 400px;
  width: 90%;
  box-shadow: var(--shadow-2xl);
  transform: scale(0.9);
  transition: transform 0.3s ease;
  position: relative;
  z-index: 10001;
}

.modal-overlay.show > div {
  transform: scale(1);
}

/* Modal Typography */
.modal-overlay h3 {
  margin: 0 0 var(--space-4) 0;
  font-size: var(--text-xl);
  font-weight: var(--font-semibold);
  color: var(--text-primary);
}

.modal-overlay p {
  margin: 0 0 var(--space-6) 0;
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
  font-size: var(--text-base);
}

/* Modal Actions */
.modal-overlay .modal-actions {
  display: flex;
  gap: var(--space-3);
  justify-content: flex-end;
}

/* Modal Buttons */
.modal-overlay button {
  padding: var(--space-3) var(--space-5);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--font-medium);
  cursor: pointer;
  transition: all var(--transition-fast);
  border: none;
  outline: none;
}

.modal-overlay button:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

.modal-overlay .btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-medium);
}

.modal-overlay .btn-secondary:hover {
  background: var(--bg-tertiary);
  border-color: var(--border-dark);
}

.modal-overlay .btn-primary {
  background: var(--primary-500);
  color: white;
}

.modal-overlay .btn-primary:hover {
  background: var(--primary-600);
}

.modal-overlay .btn-primary:active {
  background: var(--primary-700);
}

/* Dark Mode Support */
[data-theme="dark"] .modal-overlay {
  background: rgba(0, 0, 0, 0.7);
}

[data-theme="dark"] .modal-overlay > div {
  background: var(--bg-secondary);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* ============================================
   LOADING OVERLAY
   ============================================ */

#global-loader {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  opacity: 0;
  transition: opacity 0.3s ease;
  backdrop-filter: blur(2px);
}

#global-loader > div {
  background: var(--bg-elevated);
  padding: var(--space-6);
  border-radius: var(--radius-lg);
  text-align: center;
  min-width: 200px;
  box-shadow: var(--shadow-2xl);
}

#global-loader .spinner-border {
  width: 3rem;
  height: 3rem;
  border-width: 0.25rem;
}

#global-loader .loader-message {
  margin-top: var(--space-4);
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

[data-theme="dark"] #global-loader > div {
  background: var(--bg-secondary);
}

/* ============================================
   BANNER ALERTS (Full Width)
   ============================================ */

.alert-banner {
  border-radius: 0;
  border-left: none;
  border-right: none;
  margin-bottom: 0;
}

/* ============================================
   INLINE ALERTS (No Margin)
   ============================================ */

.alert-inline {
  margin-bottom: 0;
}

/* ============================================
   COMPACT ALERTS
   ============================================ */

.alert-compact {
  padding: var(--space-2) var(--space-3);
}

.alert-compact .alert-title {
  font-size: var(--text-sm);
}

.alert-compact .alert-message {
  font-size: var(--text-xs);
}

/* ============================================
   SYSTEM STATUS ALERTS
   ============================================ */

.system-alert {
  position: fixed;
  top: var(--header-height);
  left: 0;
  right: 0;
  z-index: calc(var(--z-fixed) - 1);
  border-radius: 0;
  margin: 0;
  animation: slideDown var(--transition-base);
}

.system-alert.offline {
  background-color: var(--danger-light);
  border-color: var(--danger);
  color: var(--danger-dark);
  text-align: center;
  padding: var(--space-3);
}

.system-alert.online {
  background-color: var(--success-light);
  border-color: var(--success);
  color: var(--success-dark);
}

/* ============================================
   MEDICAL ALERTS
   ============================================ */

.alert-critical {
  background-color: #4a1f23;
  border-color: var(--blood-red);
  color: #ff6b82;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.8;
  }
}

.alert-abnormal-vitals {
  background-color: var(--danger-light);
  border-left: 4px solid var(--blood-red);
}

.alert-low-stock {
  background-color: var(--warning-light);
  border-left: 4px solid var(--warning);
}

.alert-appointment-reminder {
  background-color: var(--info-light);
  border-left: 4px solid var(--info);
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

@media (max-width: 768px) {
  .modal-overlay > div {
    max-width: 90%;
    padding: var(--space-5);
  }

  .modal-overlay h3 {
    font-size: var(--text-lg);
  }

  .modal-overlay p {
    font-size: var(--text-sm);
  }

  .modal-overlay button {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-xs);
  }

  #global-loader > div {
    min-width: 180px;
    padding: var(--space-5);
  }
}

@media (max-width: 640px) {
  .toast {
    min-width: 280px;
    max-width: calc(100vw - 2rem);
  }
  
  .toast-container.top-right,
  .toast-container.bottom-right {
    right: var(--space-2);
  }
  
  .toast-container.top-left,
  .toast-container.bottom-left {
    left: var(--space-2);
  }
  
  .toast-container.top-center,
  .toast-container.bottom-center {
    left: var(--space-2);
    right: var(--space-2);
    transform: none;
  }
  
  .alert {
    padding: var(--space-3);
  }
  
  .alert-title {
    font-size: var(--text-sm);
  }
  
  .alert-message {
    font-size: var(--text-xs);
  }

  .modal-overlay > div {
    max-width: 95%;
    padding: var(--space-4);
  }

  .modal-overlay .modal-actions {
    flex-direction: column-reverse;
  }

  .modal-overlay button {
    width: 100%;
  }
}

@media (max-width: 480px) {
  #global-loader > div {
    min-width: 160px;
    padding: var(--space-4);
  }

  #global-loader .spinner-border {
    width: 2.5rem;
    height: 2.5rem;
  }
}

/* ============================================
   PRINT STYLES
   ============================================ */

@media print {
  .toast-container,
  .alert-dismissible .alert-close,
  .system-alert,
  .modal-overlay,
  #global-loader {
    display: none !important;
  }
  
  .alert {
    border: 1px solid var(--border-dark);
    page-break-inside: avoid;
  }
}

/* ============================================
   ACCESSIBILITY
   ============================================ */

.modal-overlay:focus {
  outline: none;
}

.modal-overlay button:focus-visible,
.toast-close:focus-visible,
.alert-close:focus-visible {
  outline: 2px solid var(--primary-500);
  outline-offset: 2px;
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .toast,
  .alert,
  .modal-overlay,
  .modal-overlay > div {
    animation: none !important;
    transition: none !important;
  }
}