/**
 * Modern Notification System - LoveForm Style
 * Replaces default Bootstrap/Wappler notification styling
 * 
 * Key Features:
 * - Top banner notifications (not corner toasts)
 * - Subtle colors and shadows
 * - Smooth animations
 * - Professional typography
 */

/* CSS Variables for easy customization */
:root {
  /* Notification Colors */
  --notification-success-bg: #E6F4EA;
  --notification-success-text: #1E7E34;
  --notification-success-border: #C3E6CB;
  
  --notification-error-bg: #FFEAEA;
  --notification-error-text: #C13515;
  --notification-error-border: #F5C6CB;
  
  --notification-info-bg: #E8F4FD;
  --notification-info-text: #004085;
  --notification-info-border: #BEE5EB;
  
  --notification-warning-bg: #FFF4E5;
  --notification-warning-text: #856404;
  --notification-warning-border: #FFEAA7;
  
  /* Common styles */
  --notification-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  --notification-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --notification-animation-duration: 0.3s;
}

/* Override default dmx-notifications container */
.dmx-notifications {
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  inset: unset !important;
  z-index: 999999;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 0;
  padding: 0;
  margin: 0;
}

/* Base notification styles */
.dmx-notify {
  pointer-events: auto;
  width: 100%;
  min-width: unset;
  max-width: 100%;
  margin: 0;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--notification-shadow);
  border-radius: 0;
  border: none;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  opacity: 1 !important;
  animation: notificationSlideDown var(--notification-animation-duration) ease-out forwards;
  position: relative;
  font-family: var(--notification-font);
  background: #FFFFFF;
  color: #484848;
}

/* When hiding */
.dmx-notify.hide {
  animation: notificationSlideUp var(--notification-animation-duration) ease-out forwards;
}

/* Notification Types - Modern LoveForm Style */
.dmx-notify[class*="success"],
.dmx-notify.success {
  background: var(--notification-success-bg) !important;
  color: var(--notification-success-text) !important;
  border-bottom-color: var(--notification-success-border) !important;
}

.dmx-notify[class*="danger"],
.dmx-notify[class*="error"],
.dmx-notify.danger,
.dmx-notify.error {
  background: var(--notification-error-bg) !important;
  color: var(--notification-error-text) !important;
  border-bottom-color: var(--notification-error-border) !important;
}

.dmx-notify[class*="info"],
.dmx-notify.info {
  background: var(--notification-info-bg) !important;
  color: var(--notification-info-text) !important;
  border-bottom-color: var(--notification-info-border) !important;
}

.dmx-notify[class*="warning"],
.dmx-notify.warning {
  background: var(--notification-warning-bg) !important;
  color: var(--notification-warning-text) !important;
  border-bottom-color: var(--notification-warning-border) !important;
}

/* Notification Body */
.dmx-notify-body {
  flex: 0 1 auto;
  font-size: 14px;
  line-height: 1.5;
  font-weight: 400;
  text-align: center;
  padding: 0 40px; /* Space for close button */
}

/* Notification Title (if used) */
.dmx-notify-title {
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 14px;
}

/* Notification Message */
.dmx-notify-message {
  font-weight: 400;
  font-size: 14px;
}

/* Icon styling */
.dmx-notify-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-right: 12px;
  font-size: 18px;
  width: 20px;
  height: 20px;
  position: relative;
}

/* Hide Font Awesome icons (don't render on iPhone Safari) */
.dmx-notify-icon i,
.dmx-notify-icon svg {
  display: none !important;
}

/* Universal SVG icons via CSS (works on all browsers including iPhone Safari) */
.dmx-notify-icon::before {
  content: '';
  display: block;
  width: 18px;
  height: 18px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
}

/* Success icon (checkmark) - for "Settings loaded" etc. */
.dmx-notify[style*="51a351"] .dmx-notify-icon::before,
.dmx-notify.success .dmx-notify-icon::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 448 512' fill='%231E7E34'%3E%3Cpath d='M438.6 105.4c12.5 12.5 12.5 32.8 0 45.3l-256 256c-12.5 12.5-32.8 12.5-45.3 0l-128-128c-12.5-12.5-12.5-32.8 0-45.3s32.8-12.5 45.3 0L160 338.7 393.4 105.4c12.5-12.5 32.8-12.5 45.3 0z'/%3E%3C/svg%3E");
}

/* Info icon */
.dmx-notify[style*="2f96b4"] .dmx-notify-icon::before,
.dmx-notify.info .dmx-notify-icon::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 192 512' fill='%23004085'%3E%3Cpath d='M48 80a48 48 0 1 1 96 0A48 48 0 1 1 48 80zM0 224c0-17.7 14.3-32 32-32H96c17.7 0 32 14.3 32 32V448h32c17.7 0 32 14.3 32 32s-14.3 32-32 32H32c-17.7 0-32-14.3-32-32s14.3-32 32-32H64V256H32c-17.7 0-32-14.3-32-32z'/%3E%3C/svg%3E");
}

/* Warning icon (exclamation) */
.dmx-notify[style*="f89406"] .dmx-notify-icon::before,
.dmx-notify.warning .dmx-notify-icon::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 128 512' fill='%23856404'%3E%3Cpath d='M96 64c0-17.7-14.3-32-32-32S32 46.3 32 64V320c0 17.7 14.3 32 32 32s32-14.3 32-32V64zM64 480a40 40 0 1 0 0-80 40 40 0 1 0 0 80z'/%3E%3C/svg%3E");
}

/* Danger/Error icon (triangle with exclamation) */
.dmx-notify[style*="bd362f"] .dmx-notify-icon::before,
.dmx-notify.danger .dmx-notify-icon::before,
.dmx-notify.error .dmx-notify-icon::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512' fill='%23C13515'%3E%3Cpath d='M256 32c14.2 0 27.3 7.5 34.5 19.8l216 368c7.3 12.4 7.3 27.7 .2 40.1S486.3 480 472 480H40c-14.3 0-27.6-7.7-34.7-20.1s-7-27.8 .2-40.1l216-368C228.7 39.5 241.8 32 256 32zm0 128c-13.3 0-24 10.7-24 24V296c0 13.3 10.7 24 24 24s24-10.7 24-24V184c0-13.3-10.7-24-24-24zm32 224a32 32 0 1 0 -64 0 32 32 0 1 0 64 0z'/%3E%3C/svg%3E");
}

/* Close button - Modern X style */
.dmx-notify-close {
  position: absolute;
  right: 24px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  cursor: pointer;
  opacity: 0.6;
  transition: opacity 0.2s ease;
  padding: 0;
  color: inherit;
}

.dmx-notify-close:hover {
  opacity: 1;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 50%;
}

.dmx-notify-close:before {
  content: '×';
  font-size: 24px;
  line-height: 1;
  font-weight: 300;
}

/* Remove default close icon if present */
.dmx-notify-close i,
.dmx-notify-close svg {
  display: none;
}

/* Smooth animations */
@keyframes notificationSlideDown {
  from {
    transform: translateY(-100%);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes notificationSlideUp {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(-100%);
    opacity: 0;
  }
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .dmx-notify {
    padding: 12px 16px;
  }
  
  .dmx-notify-body {
    font-size: 13px;
    padding: 0 32px;
  }
  
  .dmx-notify-close {
    right: 16px;
    width: 28px;
    height: 28px;
  }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) and (prefers-color-scheme: light) {
  :root {
    --notification-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  }
  
  .dmx-notify {
    border-bottom-color: rgba(255, 255, 255, 0.1);
  }
}

/* Accessibility improvements */
.dmx-notify:focus-within {
  outline: 2px solid currentColor;
  outline-offset: -2px;
}

.dmx-notify-close:focus {
  outline: 2px solid currentColor;
  outline-offset: 2px;
  border-radius: 50%;
}

/* Multiple notifications stacking */
.dmx-notifications .dmx-notify:not(:last-child) {
  border-bottom: none;
  box-shadow: none;
}

.dmx-notifications .dmx-notify:last-child {
  box-shadow: var(--notification-shadow);
}

/* Special case: Login error notifications (modal style) */
.login-error-notification {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  border-radius: 12px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.15);
  max-width: 400px;
  width: 90%;
  padding: 32px;
  z-index: 999999;
  animation: modalFadeIn 0.3s ease-out;
}

.login-error-notification .error-icon {
  width: 48px;
  height: 48px;
  margin: 0 auto 20px;
  background: var(--notification-error-bg);
  color: var(--notification-error-text);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
}

.login-error-notification .error-message {
  text-align: center;
  font-size: 16px;
  line-height: 1.5;
  color: #484848;
  margin-bottom: 24px;
}

.login-error-notification .error-actions {
  display: flex;
  justify-content: center;
}

.login-error-notification button {
  background: #E41E3F;
  color: white;
  border: none;
  border-radius: 8px;
  padding: 12px 32px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s;
}

.login-error-notification button:hover {
  background: #CC1E3F;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translate(-50%, -48%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}