/* ===================================================
   Unified Toast Notification System
   Works with both light and dark mode using CSS variables
   =================================================== */

/* Container - Fixed top-right, stacked */
.dc-toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 10000;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: calc(100vh - 2rem);
  overflow-y: auto;
  overflow-x: hidden;
  pointer-events: none;

  /* Hide scrollbar but keep functionality */
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.dc-toast-container::-webkit-scrollbar {
  display: none;
}

/* Individual Toast */
.dc-toast {
  width: 380px;
  max-width: calc(100vw - 2rem);
  background: var(--theme-background-secondary-bg);
  border: 1px solid var(--theme-border-color);
  border-radius: var(--border-radius, 0.5rem);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.12), 0 2px 10px rgba(0, 0, 0, 0.08);
  pointer-events: auto;
  overflow: hidden;
  opacity: 0;
  transform: translateX(calc(100% + 1rem));
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
}

.dc-toast.dc-toast-show {
  opacity: 1;
  transform: translateX(0);
}

.dc-toast.dc-toast-hide {
  opacity: 0;
  transform: translateX(calc(100% + 1rem));
}

/* Toast Inner Container */
.dc-toast-inner {
  display: flex;
  align-items: flex-start;
  padding: 1rem;
  gap: 0.875rem;
}

/* Icon Wrapper */
.dc-toast-icon-wrapper {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dc-toast-icon {
  font-size: 1.125rem;
  line-height: 1;
}

/* Content Area */
.dc-toast-content {
  flex: 1;
  min-width: 0;
  padding-top: 0.125rem;
}

.dc-toast-title {
  font-weight: 600;
  font-size: 0.9375rem;
  color: var(--theme-foreground);
  margin-bottom: 0.25rem;
  line-height: 1.3;
}

.dc-toast-message {
  font-size: 0.875rem;
  color: var(--theme-subtle-foreground);
  word-wrap: break-word;
  overflow-wrap: break-word;
  line-height: 1.5;
}

/* Actions Container */
.dc-toast-actions {
  display: flex;
  align-items: flex-start;
  gap: 0.125rem;
  flex-shrink: 0;
  margin-left: auto;
}

/* Copy Button - Hidden by default, shown on hover */
.dc-toast-copy {
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.15s ease, visibility 0.15s ease, background-color 0.15s ease, color 0.15s ease;
  background: transparent;
  border: none;
  padding: 0.375rem;
  border-radius: 0.25rem;
  cursor: pointer;
  color: var(--theme-subtle-foreground);
  font-size: 0.875rem;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dc-toast:hover .dc-toast-copy {
  opacity: 1;
  visibility: visible;
}

.dc-toast-copy:hover {
  background: var(--theme-tertiary-bg);
  color: var(--theme-foreground);
}

.dc-toast-copy:active {
  background: var(--theme-dark-bg-subtle);
}

.dc-toast-copy.copied {
  color: var(--theme-status-success);
}

.dc-toast-copy.copied i::before {
  content: "\f00c"; /* fa-check */
}

/* Close Button */
.dc-toast-close {
  background: transparent;
  border: none;
  padding: 0.375rem;
  border-radius: 0.25rem;
  cursor: pointer;
  color: var(--theme-subtle-foreground);
  font-size: 0.875rem;
  line-height: 1;
  transition: background-color 0.15s ease, color 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.dc-toast-close:hover {
  background: var(--theme-tertiary-bg);
  color: var(--theme-foreground);
}

.dc-toast-close:active {
  background: var(--theme-dark-bg-subtle);
}

/* Progress Bar */
.dc-toast-progress {
  height: 3px;
  background: var(--theme-border-color);
  position: relative;
  overflow: hidden;
}

.dc-toast-progress-bar {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 100%;
  transform-origin: left;
  animation: dc-toast-progress-shrink linear forwards;
}

@keyframes dc-toast-progress-shrink {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

/* Toast without auto-dismiss (no progress bar) */
.dc-toast.dc-toast-persistent .dc-toast-progress {
  display: none;
}

/* ===== TOAST TYPE VARIANTS ===== */

/* Success Toast */
.dc-toast.dc-toast-success {
  border-left: 4px solid var(--theme-status-success);
}

.dc-toast.dc-toast-success .dc-toast-icon-wrapper {
  background: var(--theme-status-success-bg);
}

.dc-toast.dc-toast-success .dc-toast-icon {
  color: var(--theme-status-success);
}

.dc-toast.dc-toast-success .dc-toast-title {
  color: var(--theme-status-success-text, var(--theme-foreground));
}

.dc-toast.dc-toast-success .dc-toast-progress-bar {
  background: var(--theme-status-success);
}

/* Error Toast */
.dc-toast.dc-toast-error {
  border-left: 4px solid var(--theme-status-error);
}

.dc-toast.dc-toast-error .dc-toast-icon-wrapper {
  background: var(--theme-status-error-bg);
}

.dc-toast.dc-toast-error .dc-toast-icon {
  color: var(--theme-status-error);
}

.dc-toast.dc-toast-error .dc-toast-title {
  color: var(--theme-status-error-text, var(--theme-foreground));
}

.dc-toast.dc-toast-error .dc-toast-progress-bar {
  background: var(--theme-status-error);
}

/* Warning Toast */
.dc-toast.dc-toast-warning {
  border-left: 4px solid var(--theme-status-warning);
}

.dc-toast.dc-toast-warning .dc-toast-icon-wrapper {
  background: var(--theme-status-warning-bg);
}

.dc-toast.dc-toast-warning .dc-toast-icon {
  color: var(--theme-status-warning);
}

.dc-toast.dc-toast-warning .dc-toast-title {
  color: var(--theme-status-warning-text, var(--theme-foreground));
}

.dc-toast.dc-toast-warning .dc-toast-progress-bar {
  background: var(--theme-status-warning);
}

/* Info Toast */
.dc-toast.dc-toast-info {
  border-left: 4px solid var(--theme-status-info);
}

.dc-toast.dc-toast-info .dc-toast-icon-wrapper {
  background: var(--theme-status-info-bg);
}

.dc-toast.dc-toast-info .dc-toast-icon {
  color: var(--theme-status-info);
}

.dc-toast.dc-toast-info .dc-toast-title {
  color: var(--theme-status-info-text, var(--theme-foreground));
}

.dc-toast.dc-toast-info .dc-toast-progress-bar {
  background: var(--theme-status-info);
}

/* Loading Toast */
.dc-toast.dc-toast-loading {
  border-left: 4px solid var(--theme-primary-color);
}

.dc-toast.dc-toast-loading .dc-toast-icon-wrapper {
  background: var(--theme-primary-color-light);
}

.dc-toast.dc-toast-loading .dc-toast-icon {
  color: var(--theme-primary-color);
}

.dc-toast.dc-toast-loading .dc-toast-close {
  display: none;
}

/* ===== DARK MODE ADJUSTMENTS ===== */
.dark .dc-toast {
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4), 0 2px 10px rgba(0, 0, 0, 0.3);
}

.dark .dc-toast-copy:hover,
.dark .dc-toast-close:hover {
  background: var(--theme-tertiary-bg);
}

.dark .dc-toast-copy:active,
.dark .dc-toast-close:active {
  background: var(--theme-dark-bg-subtle);
}

/* ===== MOBILE RESPONSIVE ===== */
@media (max-width: 480px) {
  .dc-toast-container {
    left: 0.75rem;
    right: 0.75rem;
    top: 0.75rem;
  }

  .dc-toast {
    width: 100%;
    max-width: none;
  }

  .dc-toast-inner {
    padding: 0.875rem;
  }

  .dc-toast-icon-wrapper {
    width: 2rem;
    height: 2rem;
  }

  .dc-toast-icon {
    font-size: 1rem;
  }
}

/* ===== ANIMATIONS ===== */
@keyframes dc-toast-shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

.dc-toast.dc-toast-shake {
  animation: dc-toast-shake 0.3s ease-in-out;
}
