/* ==========================================================================
   KARBARA NEWS — UNIFIED MODERN NOTIFICATION & STATE LOGIC (POP-UPS)
   Specifications:
   - Solid white or off-white floating card with sharp shadows
   - Clear state icon on the left inside a solid subtle-bordered square
   - Clear bold typography (Title + Message)
   - Prominent solid colored status accent bar anchored at the bottom edge
   - Unified across Success, Error, Info, Warning states & Confirmation actions
   ========================================================================== */

/* 1. Floating Toast Stack Container */
.modern-toast-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 100000;
  display: flex;
  flex-direction: column;
  gap: 12px;
  pointer-events: none;
  max-width: calc(100vw - 32px);
  width: 390px;
}

@media (max-width: 640px) {
  .modern-toast-container {
    top: 16px;
    left: 16px;
    right: 16px;
    width: auto;
  }
}

/* 2. Floating Card */
.modern-toast-card {
  pointer-events: auto;
  background: #ffffff;
  border-radius: 6px;
  box-shadow: 0 14px 34px -4px rgba(15, 23, 42, 0.16), 0 4px 14px -2px rgba(15, 23, 42, 0.08), 0 0 0 1px rgba(15, 23, 42, 0.08);
  position: relative;
  overflow: hidden;
  animation: modernToastSlideIn 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

[data-theme="dark"] .modern-toast-card {
  background: #111827;
  box-shadow: 0 14px 34px -4px rgba(0, 0, 0, 0.45), 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.modern-toast-inner {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 40px 18px 16px;
}

/* 3. State Icon Square on the Left */
.modern-toast-icon-square {
  width: 38px;
  height: 38px;
  min-width: 38px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Error State */
.modern-toast-card--error .modern-toast-icon-square {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
}

/* Success State */
.modern-toast-card--success .modern-toast-icon-square {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #059669;
}

/* Warning State */
.modern-toast-card--warning .modern-toast-icon-square {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #d97706;
}

/* Info State */
.modern-toast-card--info .modern-toast-icon-square {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #2563eb;
}

/* Dark Mode Icon Squares */
[data-theme="dark"] .modern-toast-card--error .modern-toast-icon-square {
  background: rgba(220, 38, 38, 0.15);
  border-color: rgba(220, 38, 38, 0.35);
  color: #f87171;
}

[data-theme="dark"] .modern-toast-card--success .modern-toast-icon-square {
  background: rgba(5, 150, 105, 0.15);
  border-color: rgba(5, 150, 105, 0.35);
  color: #34d399;
}

[data-theme="dark"] .modern-toast-card--warning .modern-toast-icon-square {
  background: rgba(217, 119, 6, 0.15);
  border-color: rgba(217, 119, 6, 0.35);
  color: #fbbf24;
}

[data-theme="dark"] .modern-toast-card--info .modern-toast-icon-square {
  background: rgba(37, 99, 235, 0.15);
  border-color: rgba(37, 99, 235, 0.35);
  color: #60a5fa;
}

/* 4. Bold Typography */
.modern-toast-content {
  flex: 1;
  min-width: 0;
}

.modern-toast-title {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.92rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.3;
  margin: 0 0 3px 0;
  letter-spacing: -0.2px;
}

[data-theme="dark"] .modern-toast-title {
  color: #f8fafc;
}

.modern-toast-message {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.84rem;
  font-weight: 500;
  color: #475569;
  line-height: 1.45;
  margin: 0;
  word-break: break-word;
}

[data-theme="dark"] .modern-toast-message {
  color: #94a3b8;
}

/* 5. Close Button */
.modern-toast-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 26px;
  height: 26px;
  border: none;
  background: transparent;
  color: #94a3b8;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  padding: 0;
}

.modern-toast-close:hover {
  color: #0f172a;
  background: #f1f5f9;
}

[data-theme="dark"] .modern-toast-close:hover {
  color: #ffffff;
  background: #1f2937;
}

/* 6. Prominent Solid Colored Status Accent Bar Anchored at Bottom */
.modern-toast-accent-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  width: 100%;
}

.modern-toast-card--error .modern-toast-accent-bar {
  background-color: #dc2626; /* Crisp Red / Orange-Red */
}

.modern-toast-card--success .modern-toast-accent-bar {
  background-color: #10b981; /* Emerald Green */
}

.modern-toast-card--warning .modern-toast-accent-bar {
  background-color: #f59e0b; /* Amber / Orange */
}

.modern-toast-card--info .modern-toast-accent-bar {
  background-color: #2563eb; /* Blue / Cobalt */
}

/* 7. Modal Confirmation / Action Pop-Up */
.modern-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100001;
  background: rgba(15, 23, 42, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: modernFadeIn 0.2s ease forwards;
}

.modern-modal-card {
  background: #ffffff;
  width: 100%;
  max-width: 440px;
  border-radius: 6px;
  box-shadow: 0 20px 40px -8px rgba(15, 23, 42, 0.3), 0 0 0 1px rgba(15, 23, 42, 0.08);
  position: relative;
  overflow: hidden;
  padding: 24px 24px 28px 24px;
  animation: modernScaleIn 0.22s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

[data-theme="dark"] .modern-modal-card {
  background: #111827;
  box-shadow: 0 20px 40px -8px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.modern-modal-inner {
  display: flex;
  align-items: flex-start;
  gap: 16px;
}

.modern-modal-icon-square {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.modern-modal-card--error .modern-modal-icon-square {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #dc2626;
}

.modern-modal-card--success .modern-modal-icon-square {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #059669;
}

.modern-modal-card--warning .modern-modal-icon-square {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #d97706;
}

.modern-modal-card--info .modern-modal-icon-square,
.modern-modal-card--loading .modern-modal-icon-square {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #2563eb;
}

[data-theme="dark"] .modern-modal-card--error .modern-modal-icon-square {
  background: rgba(220, 38, 38, 0.15);
  border-color: rgba(220, 38, 38, 0.35);
  color: #f87171;
}

[data-theme="dark"] .modern-modal-card--success .modern-modal-icon-square {
  background: rgba(5, 150, 105, 0.15);
  border-color: rgba(5, 150, 105, 0.35);
  color: #34d399;
}

[data-theme="dark"] .modern-modal-card--warning .modern-modal-icon-square {
  background: rgba(217, 119, 6, 0.15);
  border-color: rgba(217, 119, 6, 0.35);
  color: #fbbf24;
}

[data-theme="dark"] .modern-modal-card--info .modern-modal-icon-square,
[data-theme="dark"] .modern-modal-card--loading .modern-modal-icon-square {
  background: rgba(37, 99, 235, 0.15);
  border-color: rgba(37, 99, 235, 0.35);
  color: #60a5fa;
}

.modern-modal-title {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 1.05rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.3;
  margin: 0 0 6px 0;
}

[data-theme="dark"] .modern-modal-title {
  color: #f8fafc;
}

.modern-modal-message {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 0.9rem;
  font-weight: 500;
  color: #475569;
  line-height: 1.5;
  margin: 0;
}

[data-theme="dark"] .modern-modal-message {
  color: #94a3b8;
}

.modern-modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

.modern-modal-btn {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  padding: 10px 20px;
  font-size: 0.88rem;
  font-weight: 700;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  border: none;
}

.modern-modal-btn--cancel {
  border: 1px solid #cbd5e1;
  background: #ffffff;
  color: #334155;
}

.modern-modal-btn--cancel:hover {
  background: #f8fafc;
  color: #0f172a;
  border-color: #94a3b8;
}

[data-theme="dark"] .modern-modal-btn--cancel {
  background: #1f2937;
  border-color: #374151;
  color: #cbd5e1;
}

[data-theme="dark"] .modern-modal-btn--cancel:hover {
  background: #374151;
  color: #ffffff;
}

.modern-modal-btn--danger {
  background: #dc2626;
  color: #ffffff;
}

.modern-modal-btn--danger:hover {
  background: #b91c1c;
}

.modern-modal-btn--success {
  background: #059669;
  color: #ffffff;
}

.modern-modal-btn--success:hover {
  background: #047857;
}

.modern-modal-btn--primary {
  background: #0f172a;
  color: #ffffff;
}

.modern-modal-btn--primary:hover {
  background: #1e293b;
}

[data-theme="dark"] .modern-modal-btn--primary {
  background: #2563eb;
  color: #ffffff;
}

[data-theme="dark"] .modern-modal-btn--primary:hover {
  background: #1d4ed8;
}

/* Status Accent Bar for Modal */
.modern-modal-accent-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 4px;
  width: 100%;
}

.modern-modal-card--error .modern-modal-accent-bar {
  background-color: #dc2626;
}

.modern-modal-card--success .modern-modal-accent-bar {
  background-color: #10b981;
}

.modern-modal-card--warning .modern-modal-accent-bar {
  background-color: #f59e0b;
}

.modern-modal-card--info .modern-modal-accent-bar,
.modern-modal-card--loading .modern-modal-accent-bar {
  background-color: #2563eb;
}

/* Spinner */
.modern-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(37, 99, 235, 0.2);
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: modernSpin 0.75s linear infinite;
}

@keyframes modernSpin {
  to { transform: rotate(360deg); }
}

@keyframes modernToastSlideIn {
  from {
    opacity: 0;
    transform: translateX(20px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes modernFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes modernScaleIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}
