/* Core toast — one place for all admin surfaces (CMS, Newsletter, Platform).
 *
 * Markup is emitted by render_toast() in core/lib/toast.php and the runtime
 * lives in core/lib/toast.js. Surfaces drop a #coreToast element on the page
 * and call window.toast(msg, type, title, duration, action).
 *
 * Positioning vars (override on a surface-specific stylesheet if needed):
 *   --core-toast-bottom : desktop bottom offset (default 24px)
 *   --core-toast-right  : desktop right offset (default 24px)
 *   --core-toast-z      : z-index (default 10001, sits above admin-bar 10000)
 */

#coreToast {
  --core-toast-bottom: var(--toast-bottom-offset, 24px);
  --core-toast-right:  24px;
  --core-toast-z:      10001;

  position: fixed;
  bottom: var(--core-toast-bottom);
  right:  var(--core-toast-right);
  min-width: 280px;
  max-width: 400px;
  background: var(--bg-2, #2a2620);
  border: 1px solid var(--border-2, rgba(255,255,255,0.1));
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
  z-index: var(--core-toast-z);
  overflow: hidden;
  transform: translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1),
              opacity   0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
  color: var(--text, #f6f1ed);
  font-family: var(--sans, -apple-system, BlinkMacSystemFont, "Segoe UI", Manrope, sans-serif);
}
#coreToast.show    { transform: translateY(0); opacity: 1; pointer-events: auto; }
#coreToast.success { border-color: rgba(16, 185, 129, 0.45); }
#coreToast.error   { border-color: rgba(239, 68,  68,  0.45); }
#coreToast.warning { border-color: rgba(245, 158, 11,  0.45); }
#coreToast.info    { border-color: rgba(192, 103, 58,  0.45); }

.core-toast-inner {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
}
.core-toast-icon {
  font-size: 16px;
  flex-shrink: 0;
  margin-top: 1px;
  line-height: 1;
}
#coreToast.success .core-toast-icon { color: #34d399; }
#coreToast.error   .core-toast-icon { color: #f87171; }
#coreToast.warning .core-toast-icon { color: #fbbf24; }
#coreToast.info    .core-toast-icon { color: #d68b5e; }

.core-toast-body { flex: 1; min-width: 0; }
.core-toast-title-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 2px;
  gap: 6px;
}
.core-toast-title {
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 0.02em;
  color: var(--text, #f6f1ed);
}
.core-toast-countdown {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3, rgba(246, 241, 237, 0.5));
  flex-shrink: 0;
  padding-left: 6px;
  font-variant-numeric: tabular-nums;
}
.core-toast-msg {
  font-size: 12px;
  color: var(--text-2, rgba(246, 241, 237, 0.78));
  line-height: 1.5;
  word-break: break-word;
}

.core-toast-action {
  flex-shrink: 0;
  align-self: center;
  background: var(--accent-glow, rgba(192, 103, 58, 0.18));
  border: 1px solid var(--accent, rgba(192, 103, 58, 0.6));
  color: var(--accent-2, #ffb088);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.core-toast-action:hover { background: var(--accent, #c0673a); color: #fff; }
#coreToast.warning .core-toast-action { background: rgba(245,158,11,0.15); border-color: rgba(245,158,11,0.5); color: #fbbf24; }
#coreToast.warning .core-toast-action:hover { background: rgba(245,158,11,0.85); color: #fff; }

.core-toast-copy {
  flex-shrink: 0;
  align-self: flex-start;
  background: transparent;
  border: 1px solid var(--border, rgba(255,255,255,0.12));
  color: var(--text-3, rgba(246, 241, 237, 0.5));
  font-family: inherit;
  font-size: 12px;
  line-height: 1;
  padding: 4px 6px;
  border-radius: 5px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.core-toast-copy:hover {
  background: var(--bg-3, rgba(255,255,255,0.04));
  color: var(--text-2, rgba(246, 241, 237, 0.78));
  border-color: var(--border-2, rgba(255,255,255,0.2));
}

.core-toast-progress {
  height: 3px;
  width: 100%;
  transform-origin: left;
}
#coreToast.success .core-toast-progress { background: #34d399; }
#coreToast.error   .core-toast-progress { background: #f87171; }
#coreToast.warning .core-toast-progress { background: #fbbf24; }
#coreToast.info    .core-toast-progress { background: #c0673a; }
@keyframes core-toast-progress {
  from { transform: scaleX(1); }
  to   { transform: scaleX(0); }
}

/* Mobile: top instead of bottom so it stays out of the on-screen keyboard.
   Flip the slide direction, cap width so it never overflows. */
@media (max-width: 768px) {
  #coreToast {
    top: 60px !important;
    bottom: auto !important;
    right: 12px;
    left: auto;
    min-width: 0;
    max-width: calc(100vw - 24px);
    max-height: 140px;
    transform: translateY(-20px);
  }
  #coreToast.show { transform: translateY(0); }
  .core-toast-title {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .core-toast-msg {
    white-space: normal;
    overflow: hidden;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
  }
}
