/* ===================================================================== */
/* Universal Notifications - Enhanced Pandoc-WASM Playground Integration */
/* Transforms Graph Builder legacy classes to match playground aesthetic  */
/* WCAG 2.2 AA Compliant with 4.5:1+ contrast ratios                    */
/* ===================================================================== */

/* ===== TOAST CONTAINER - PLAYGROUND SOPHISTICATED POSITIONING ===== */
.gb-toast-container,
.universal-toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2147483647; /* Maximum z-index for overlay */
  pointer-events: none;
  max-width: 420px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: all 0.3s ease;
}

/* Responsive positioning - mobile optimized */
@media (max-width: 768px) {
  .gb-toast-container,
  .universal-toast-container {
    top: 0.5rem;
    right: 0.5rem;
    left: 0.5rem;
    max-width: none;
    width: auto;
  }
}

/* High zoom / constrained viewport adjustments */
@media (max-height: 500px) {
  .gb-toast-container,
  .universal-toast-container {
    top: 0.25rem;
    gap: 0.5rem;
  }
}

/* ===== BASE TOAST STYLING - PLAYGROUND INTEGRATION ===== */
.gb-toast,
.gb-toast-base {
  background: var(--sidebar-bg); /* Playground sidebar background */
  border: 2px solid var(--sidebar-border); /* Playground border system */
  border-radius: 8px; /* Playground container border radius */
  box-shadow: 0 10px 30px var(--sidebar-shadow),
    0 4px 12px rgba(0, 19, 29, 0.15); /* Enhanced shadow system */
  color: var(--body-text);
  font-family: var(
    --font-family-sans,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    Roboto,
    sans-serif
  );
  font-size: 0.875rem;
  line-height: 1.5;
  margin-bottom: 0.75rem;
  min-height: 64px;
  padding: 0;
  pointer-events: auto;
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  overflow: hidden;
  transform: translateX(100%);
  opacity: 0;
  transition: all 0.3s ease;
  word-wrap: break-word;
  max-width: 100%;
}

/* Show animation using existing GB class */
.gb-toast-show {
  transform: translateX(0);
  opacity: 1;
}

/* ===== TOAST TYPE STYLING - PLAYGROUND GRADIENT SYSTEM ===== */

/* Success Toast - Matches playground success indicators */
.gb-toast-success {
  background: var(--success-color);
  color: var(--body-bg); /* High contrast white text */
  border-color: var(--success-color);
  box-shadow: 0 10px 30px rgba(10, 93, 58, 0.25), 0 0 20px rgba(10, 93, 58, 0.3);
}

/* Error Toast - Matches playground error indicators */
.gb-toast-error {
  background: var(--error-color);
  color: var(--body-bg); /* High contrast white text */
  border-color: var(--error-color);
  box-shadow: 0 10px 30px rgba(139, 38, 53, 0.25),
    0 0 20px rgba(139, 38, 53, 0.3);
}

/* Warning Toast - Matches playground warning indicators */
.gb-toast-warning {
  background: var(--warning-color);
  color: var(--body-bg); /* High contrast white text */
  border-color: var(--warning-color);
  box-shadow: 0 10px 30px rgba(139, 69, 19, 0.25),
    0 0 20px rgba(139, 69, 19, 0.3);
}

/* Info Toast - Matches playground primary colors */
.gb-toast-info {
  background: var(--link-color);
  color: var(--body-bg); /* High contrast white text */
  border-color: var(--body-bg);
  box-shadow: 0 10px 30px rgba(0, 46, 59, 0.25), 0 0 20px rgba(0, 46, 59, 0.3);
}

/* Loading Toast - Matches playground loading indicators */
.gb-toast-loading {
  background: var(--warning-color);
  color: var(--body-bg); /* High contrast white text */
  border-color: var(--warning-color);
  box-shadow: 0 10px 30px rgba(139, 69, 19, 0.25),
    0 0 20px rgba(139, 69, 19, 0.3);
  animation: pulse-glow 2s infinite;
}

/* ===== TOAST ICON CONTAINER - PLAYGROUND STYLING ===== */
.gb-toast-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  margin: 0.75rem 0 0.75rem 0.75rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid var(--body-bg);
  font-size: 1.25rem;
  font-weight: bold;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
}

/* Icon shimmer effect on toast hover */
.gb-toast:hover .gb-toast-icon::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    135deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  transform: translateX(-100%);
  animation: shimmer 0.6s ease-out;
}

/* ===== TOAST CONTENT AREA ===== */
.gb-toast-content {
  flex: 1;
  padding: 0.75rem 0;
  color: inherit;
  font-weight: 500;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

/* Ensure proper text contrast for accessibility */
.gb-toast-success .gb-toast-content,
.gb-toast-error .gb-toast-content,
.gb-toast-warning .gb-toast-content,
.gb-toast-info .gb-toast-content,
.gb-toast-loading .gb-toast-content {
  color: var(
    --body-bg
  ); /* Ensures 4.5:1+ contrast against gradient backgrounds */
}

/* ===== CLOSE BUTTON - PLAYGROUND SOPHISTICATED STYLING ===== */
.gb-toast-close {
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid var(--body-bg);
  border-radius: 8px; /* Playground border radius */
  color: inherit;
  cursor: pointer;
  font-size: 1.25rem;
  font-weight: bold;
  margin: 0.75rem 0.75rem 0.75rem 0;
  padding: 0.5rem;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  flex-shrink: 0;
}

/* Close button shimmer effect */
.gb-toast-close::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    135deg,
    transparent,
    rgba(255, 255, 255, 0.1),
    transparent
  );
  transform: translateX(-100%);
  transition: transform 0.6s ease;
}

.gb-toast-close:hover::before {
  transform: translateX(100%);
}

.gb-toast-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px) scale(1.05);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
}

.gb-toast-close:active {
  transform: translateY(0) scale(1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

/* Focus states for close button - WCAG compliant */
.gb-toast-close:focus-visible {
  outline: 3px solid var(--body-bg); /* High contrast outline */
  outline-offset: 2px;
  background: rgba(255, 255, 255, 0.4);
}

/* ===== PROGRESS BAR - PLAYGROUND GRADIENT SYSTEM ===== */
.gb-toast-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 0 0 8px 8px;
  overflow: hidden;
  transition: width linear;
}

.gb-toast-progress::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.4),
    rgba(255, 255, 255, 0.7),
    rgba(255, 255, 255, 0.4)
  );
  animation: shimmer 2s ease-in-out infinite;
}

/* ===== DARK MODE ENHANCEMENTS ===== */
[data-theme="dark"] .gb-toast,
[data-theme="dark"] .gb-toast-base {
  background: var(--surface-color);
  border-color: var(--sidebar-border);
  box-shadow: 0 10px 30px rgba(179, 219, 210, 0.1),
    0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .gb-toast-success {
  background: var(--success-color);
  box-shadow: 0 10px 30px rgba(74, 222, 128, 0.25),
    0 0 20px rgba(74, 222, 128, 0.3);
}

[data-theme="dark"] .gb-toast-error {
  background: var(--error-color);
  box-shadow: 0 10px 30px rgba(248, 113, 113, 0.25),
    0 0 20px rgba(248, 113, 113, 0.3);
}

[data-theme="dark"] .gb-toast-warning {
  background: var(--warning-color);
  box-shadow: 0 10px 30px rgba(252, 188, 77, 0.25),
    0 0 20px rgba(252, 188, 77, 0.3);
}

[data-theme="dark"] .gb-toast-info {
  background: var(--link-color);
  box-shadow: 0 10px 30px rgba(60, 186, 198, 0.25),
    0 0 20px rgba(60, 186, 198, 0.3);
}

[data-theme="dark"] .gb-toast-loading {
  background: var(--warning-color);
  box-shadow: 0 10px 30px rgba(252, 188, 77, 0.25),
    0 0 20px rgba(252, 188, 77, 0.3);
}

/* ===== ANIMATIONS - PLAYGROUND CONSISTENCY ===== */
@keyframes shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

@keyframes pulse-glow {
  0%,
  100% {
    box-shadow: 0 10px 30px rgba(139, 69, 19, 0.25),
      0 0 20px rgba(139, 69, 19, 0.3);
  }
  50% {
    box-shadow: 0 10px 30px rgba(139, 69, 19, 0.4),
      0 0 30px rgba(139, 69, 19, 0.5);
  }
}

/* ===== RESPONSIVE DESIGN - MOBILE OPTIMIZATIONS ===== */
@media (max-width: 768px) {
  .gb-toast,
  .gb-toast-base {
    min-height: 56px;
    font-size: 0.8rem;
    gap: 0.5rem;
  }

  .gb-toast-icon {
    width: 32px;
    height: 32px;
    margin: 0.5rem 0 0.5rem 0.5rem;
    font-size: 1rem;
  }

  .gb-toast-content {
    padding: 0.5rem 0;
  }

  .gb-toast-close {
    width: 32px;
    height: 32px;
    margin: 0.5rem 0.5rem 0.5rem 0;
    font-size: 1rem;
    padding: 0.25rem;
  }

  .gb-toast-progress {
    height: 3px;
  }
}

/* ===== HIGH CONTRAST MODE SUPPORT ===== */
@media (prefers-contrast: high) {
  .gb-toast,
  .gb-toast-base {
    border-width: 3px;
    font-weight: 700;
  }

  .gb-toast-close {
    border-width: 3px;
    font-weight: 700;
  }

  .gb-toast-close:focus-visible {
    outline-width: 4px;
  }

  .gb-toast-icon {
    border-width: 3px;
  }
}

/* ===== REDUCED MOTION SUPPORT ===== */
@media (prefers-reduced-motion: reduce) {
  .gb-toast,
  .gb-toast-base,
  .gb-toast-icon,
  .gb-toast-close,
  .gb-toast-progress {
    transition: none;
  }

  .gb-toast-close:hover {
    transform: none;
  }

  .gb-toast-loading {
    animation: none;
  }

  .gb-toast-icon::before,
  .gb-toast-close::before,
  .gb-toast-progress::after {
    display: none;
  }

  @keyframes shimmer {
    0%,
    100% {
      transform: translateX(0);
    }
  }

  @keyframes pulse-glow {
    0%,
    100% {
      box-shadow: 0 10px 30px rgba(139, 69, 19, 0.25),
        0 0 20px rgba(139, 69, 19, 0.3);
    }
  }
}

/* ===== SCREEN READER ANNOUNCEMENTS ===== */
.sr-only,
#universal-toast-announcer {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

/* ===== TOAST HOVER EFFECTS - PLAYGROUND SOPHISTICATION ===== */
.gb-toast:hover {
  transform: translateY(-2px);
  box-shadow: 0 15px 40px rgba(0, 0, 0, 0.15), 0 8px 20px rgba(0, 0, 0, 0.1);
}

.gb-toast-success:hover {
  box-shadow: 0 15px 40px rgba(10, 93, 58, 0.35), 0 0 25px rgba(10, 93, 58, 0.4);
}

.gb-toast-error:hover {
  box-shadow: 0 15px 40px rgba(139, 38, 53, 0.35),
    0 0 25px rgba(139, 38, 53, 0.4);
}

.gb-toast-warning:hover {
  box-shadow: 0 15px 40px rgba(139, 69, 19, 0.35),
    0 0 25px rgba(139, 69, 19, 0.4);
}

.gb-toast-info:hover {
  box-shadow: 0 15px 40px rgba(0, 46, 59, 0.35), 0 0 25px rgba(0, 46, 59, 0.4);
}

.gb-toast-loading:hover {
  box-shadow: 0 15px 40px rgba(139, 69, 19, 0.35),
    0 0 25px rgba(139, 69, 19, 0.4);
}

/* Dark mode hover adjustments */
[data-theme="dark"] .gb-toast-success:hover {
  box-shadow: 0 15px 40px rgba(74, 222, 128, 0.35),
    0 0 25px rgba(74, 222, 128, 0.4);
}

[data-theme="dark"] .gb-toast-error:hover {
  box-shadow: 0 15px 40px rgba(248, 113, 113, 0.35),
    0 0 25px rgba(248, 113, 113, 0.4);
}

[data-theme="dark"] .gb-toast-warning:hover {
  box-shadow: 0 15px 40px rgba(252, 188, 77, 0.35),
    0 0 25px rgba(252, 188, 77, 0.4);
}

[data-theme="dark"] .gb-toast-info:hover {
  box-shadow: 0 15px 40px rgba(60, 186, 198, 0.35),
    0 0 25px rgba(60, 186, 198, 0.4);
}

[data-theme="dark"] .gb-toast-loading:hover {
  box-shadow: 0 15px 40px rgba(252, 188, 77, 0.35),
    0 0 25px rgba(252, 188, 77, 0.4);
}

/* ===== INTEGRATION WITH EXISTING PLAYGROUND PATTERNS ===== */

/* Ensure toasts don't interfere with modals */
.universal-modal[open] ~ .gb-toast-container,
.universal-modal[open] ~ .universal-toast-container {
  z-index: 2147483646; /* Below modals but above everything else */
}

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

/* Improve keyboard navigation */
.gb-toast-close:focus {
  outline: 3px solid var(--body-bg);
  outline-offset: 2px;
}
