/* public/assets/ui/framework/21_toasts.css
   KomodUI Toasts v0.1
   Global toast system + XP toast bridge.
   Goals:
   - fixed stack, safe on mobile
   - reduced motion support
   - no layout overflow, no pointer issues
*/

/* =========================
   Design tokens (local defaults)
   ========================= */

:root {
  --toast-z: 1200;
  --toast-gap: var(--space-3, 12px);
  --toast-max-w: 360px;
  --toast-radius: var(--radius-lg, 16px);
  --toast-shadow: var(--shadow-lg, 0 20px 25px -5px rgba(0, 0, 0, .10), 0 10px 10px -5px rgba(0, 0, 0, .04));
  --toast-border: var(--color-border, #E5E7EB);
  --toast-bg: var(--color-bg-white, #FFFFFF);
  --toast-text: var(--color-text, #111827);
  --toast-muted: var(--color-text-muted, #6B7280);

  --toast-success: #10B981;
  --toast-danger: #EF4444;
  --toast-warning: #F59E0B;
  --toast-info: #3B82F6;
}

/* =========================
   Toast stack (preferred)
   ========================= */

.toast-stack {
  position: fixed;
  z-index: var(--toast-z);
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: var(--toast-gap);
  max-width: min(var(--toast-max-w), calc(100vw - 24px));

  /* default position */
  top: 16px;
  right: 16px;
}

.toast-stack--tr { top: 16px; right: 16px; left: auto; bottom: auto; }
.toast-stack--tl { top: 16px; left: 16px; right: auto; bottom: auto; }
.toast-stack--br { bottom: 16px; right: 16px; top: auto; left: auto; }
.toast-stack--bl { bottom: 16px; left: 16px; top: auto; right: auto; }

@media (max-width: 576px) {
  .toast-stack,
  .toast-stack--tr,
  .toast-stack--tl,
  .toast-stack--br,
  .toast-stack--bl {
    left: 12px;
    right: 12px;
    max-width: calc(100vw - 24px);
  }

  .toast-stack { top: 12px; }
  .toast-stack--br,
  .toast-stack--bl { bottom: 12px; top: auto; }
}

/* =========================
   Toast card
   ========================= */

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3, 12px);

  width: 100%;
  max-width: var(--toast-max-w);

  background: var(--toast-bg);
  color: var(--toast-text);
  border: 1px solid var(--toast-border);
  border-radius: var(--toast-radius);
  box-shadow: var(--toast-shadow);

  padding: var(--space-4, 14px);
  overflow: hidden;

  animation: toast-in 160ms ease-out both;
}

.toast__icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border-radius: 999px;
  background: var(--toast-info);
}

.toast__body {
  min-width: 0;
  flex: 1 1 auto;
}

.toast__title {
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1.25;
  margin: 0 0 4px 0;
}

.toast__text {
  font-size: 0.9rem;
  line-height: 1.35;
  color: var(--toast-muted);
  margin: 0;
  word-break: break-word;
}

.toast__actions {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.toast__close {
  pointer-events: auto;
  border: 0;
  background: transparent;
  color: var(--toast-muted);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  cursor: pointer;
}

.toast__close:hover {
  background: rgba(0, 0, 0, .04);
  color: var(--toast-text);
}

/* Variants */
.toast--success .toast__icon { background: var(--toast-success); }
.toast--danger  .toast__icon { background: var(--toast-danger); }
.toast--warning .toast__icon { background: var(--toast-warning); }
.toast--info    .toast__icon { background: var(--toast-info); }

.toast--compact { padding: 12px; }
.toast--compact .toast__title { font-size: 0.92rem; }
.toast--compact .toast__text  { font-size: 0.86rem; }

/* =========================
   Animation
   ========================= */

@keyframes toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to   { opacity: 0; transform: translateY(-6px); }
}

.toast.is-hiding {
  animation: toast-out 140ms ease-in both;
}

@media (prefers-reduced-motion: reduce) {
  .toast,
  .toast.is-hiding {
    animation: none !important;
    transition: none !important;
  }
}

/* =========================
   XP Toast bridge (xp-toast.js)
   Supports common containers + item classnames.
   ========================= */

#xp-toast-container,
.xp-toast-container,
#toast-container,
.toast-container {
  position: fixed;
  z-index: var(--toast-z);
  pointer-events: none;
  top: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: var(--toast-gap);
  max-width: min(var(--toast-max-w), calc(100vw - 24px));
}

@media (max-width: 576px) {
  #xp-toast-container,
  .xp-toast-container,
  #toast-container,
  .toast-container {
    left: 12px;
    right: 12px;
    top: 12px;
    max-width: calc(100vw - 24px);
  }
}

/* Toast item variants */
.xp-toast,
.toast-item,
.toast-notice {
  pointer-events: auto;
  width: 100%;
  max-width: var(--toast-max-w);

  background: var(--toast-bg);
  color: var(--toast-text);
  border: 1px solid var(--toast-border);
  border-radius: var(--toast-radius);
  box-shadow: var(--toast-shadow);

  padding: var(--space-4, 14px);
  overflow: hidden;

  animation: toast-in 160ms ease-out both;
}

.xp-toast.is-hiding,
.toast-item.is-hiding,
.toast-notice.is-hiding {
  animation: toast-out 140ms ease-in both;
}

.xp-toast-title,
.toast-title {
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1.25;
  margin: 0 0 4px 0;
}

.xp-toast-text,
.toast-text {
  font-size: 0.9rem;
  line-height: 1.35;
  color: var(--toast-muted);
  margin: 0;
  word-break: break-word;
}

/* Optional progress bar */
.xp-toast-progress,
.toast-progress {
  height: 3px;
  background: rgba(0, 0, 0, .08);
  margin-top: 10px;
  border-radius: 999px;
  overflow: hidden;
}

.xp-toast-progress > span,
.toast-progress > span {
  display: block;
  height: 100%;
  width: 100%;
  background: var(--toast-info);
}

/* Optional close button */
.xp-toast-close,
.toast-close {
  pointer-events: auto;
  border: 0;
  background: transparent;
  color: var(--toast-muted);
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  cursor: pointer;
}

.xp-toast-close:hover,
.toast-close:hover {
  background: rgba(0, 0, 0, .04);
  color: var(--toast-text);
}  