/* Toast Container */
.toast-container {
  position: fixed;
  top: 30vh;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
  max-width: 400px;
  width: calc(100vw - 40px);
}

/* Individual Toast */
.toast {
  background: var(--bg-primary);
  border: 1px solid var(--border-color, #e0e0e0);
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  padding: 0;
  margin: 0;
  opacity: 0;
  transform: translateY(-20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: auto;
  overflow: hidden;
  max-width: 100%;
}

/* Toast Header */
.toast-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color, #e0e0e0);
  position: relative;
}

/* Toast Header Content */
.toast-header-content {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0; /* Allow text truncation */
}

/* Toast Title */
.toast-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.2;
}

/* Toast Body */
.toast-body {
  padding: 12px 16px 16px 16px;
}

/* Toast Icon */
.toast-icon {
  font-size: 16px;
  line-height: 1;
  flex-shrink: 0;
  width: 18px;
  text-align: center;
}

/* Toast Message */
.toast-message {
  font-size: 13px;
  line-height: 1.5;
  color: var(--text-secondary, #666);
  font-weight: 400;
  word-wrap: break-word;
  overflow-wrap: break-word;
  white-space: pre-wrap;
  max-height: 150px;
  overflow-y: auto;
  margin: 0;
}

/* Toast Close Button */
.toast-close {
  background: none;
  border: none;
  color: var(--text-tertiary, #999);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px;
  border-radius: 4px;
  transition: all 0.2s ease;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
}

.toast-close:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.toast-close:focus {
  outline: 2px solid var(--primary-color, #4b6bfb);
  outline-offset: 2px;
}

/* Toast Types */
.toast-error {
  border-left: 4px solid #dc3545;
  background: linear-gradient(135deg, #fff5f5 0%, #fff 100%);
}

.toast-error .toast-icon {
  color: #dc3545;
}

.toast-success {
  border-left: 4px solid #28a745;
  background: linear-gradient(135deg, #f0fff4 0%, #fff 100%);
}

.toast-success .toast-icon {
  color: #28a745;
}

.toast-warning {
  border-left: 4px solid #ffc107;
  background: linear-gradient(135deg, #fffbf0 0%, #fff 100%);
}

.toast-warning .toast-icon {
  color: #ffc107;
}

.toast-info {
  border-left: 4px solid #17a2b8;
  background: linear-gradient(135deg, #f0f9ff 0%, #fff 100%);
}

.toast-info .toast-icon {
  color: #17a2b8;
}

/* Toast Animations */
.toast-show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast-hide {
  opacity: 0;
  transform: translateY(-20px) scale(0.95);
}

/* Dark Theme Support */
[data-theme="dark"] .toast {
  background: var(--bg-secondary);
  border-color: var(--border-color, #404040);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .toast-header {
  border-bottom-color: var(--border-color, #404040);
}

[data-theme="dark"] .toast-error {
  background: linear-gradient(135deg, #2d1b1b 0%, var(--bg-secondary) 100%);
}

[data-theme="dark"] .toast-success {
  background: linear-gradient(135deg, #1b2d1b 0%, var(--bg-secondary) 100%);
}

[data-theme="dark"] .toast-warning {
  background: linear-gradient(135deg, #2d2a1b 0%, var(--bg-secondary) 100%);
}

[data-theme="dark"] .toast-info {
  background: linear-gradient(135deg, #1b2a2d 0%, var(--bg-secondary) 100%);
}

/* Responsive Design */
@media (max-width: 480px) {
  .toast-container {
    top: 25px;
    width: calc(100vw - 20px);
    max-width: none;
  }

  .toast-header {
    padding: 10px 12px;
    gap: 8px;
  }

  .toast-body {
    padding: 10px 12px 12px 12px;
  }

  .toast-message {
    font-size: 12px;
    max-height: 120px;
  }

  .toast-title {
    font-size: 13px;
  }

  .toast-icon {
    font-size: 14px;
    width: 16px;
  }

  .toast-close {
    font-size: 14px;
    width: 18px;
    height: 18px;
  }
}

/* High Contrast Mode Support */
@media (prefers-contrast: high) {
  .toast {
    border-width: 2px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  }

  .toast-error {
    border-left-width: 6px;
  }

  .toast-success {
    border-left-width: 6px;
  }

  .toast-warning {
    border-left-width: 6px;
  }

  .toast-info {
    border-left-width: 6px;
  }
}

/* Reduced Motion Support */
@media (prefers-reduced-motion: reduce) {
  .toast,
  .toast-close {
    transition: none;
  }

  .toast-show,
  .toast-hide {
    transform: none;
  }
}

/* Print Styles */
@media print {
  .toast-container {
    display: none;
  }
}
