/* Shared confirm-dialog + toast skins (JS/ui.js). Loads on many pages, so it is
   fully self-contained on the consent.css recipe: every rule namespaced
   .tp-ui-* / .tp-toast-*, every var() carries a literal fallback, and one
   body.dark block covers both the public and console dark palettes (console
   pages always carry both classes).
   Z-order (see consent.css ladder): confirm overlay 1100 — a blocking decision
   the user just triggered outranks the consent modal (700) and the chat panel
   (1000). Toast host 1200: transient feedback must never be buried. */

.tp-ui-overlay[hidden],
.tp-toast-host[hidden] { display: none !important; }

.tp-ui-overlay {
  position: fixed;
  inset: 0;
  z-index: 1100;
  background: rgba(2, 12, 69, 0.45);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.tp-ui-dialog {
  background: var(--surface, #ffffff);
  color: var(--text, #0f1f4b);
  border: 1px solid var(--border, #e8edf6);
  border-radius: 12px;
  box-shadow: 0 24px 60px rgba(2, 12, 69, 0.25);
  max-width: 440px;
  width: 100%;
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  padding: 24px;
  font-family: 'DM Sans', sans-serif;
}

.tp-ui-title {
  font-family: 'Sora', sans-serif;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--ink, #0f1f4b);
  margin: 0 0 10px;
}
.tp-ui-danger .tp-ui-title { color: var(--red, #b91c1c); }

.tp-ui-message {
  font-size: 0.92rem;
  line-height: 1.55;
  color: var(--text-muted, #64748b);
  margin: 0 0 12px;
}

.tp-ui-detail {
  margin: 0 0 14px;
  padding-left: 18px;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--text-muted, #64748b);
}

.tp-ui-field { display: block; margin: 0 0 14px; }
.tp-ui-field-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text, #0f1f4b);
  margin-bottom: 6px;
}
.tp-ui-field input,
.tp-ui-field textarea {
  width: 100%;
  box-sizing: border-box;
  border: 1.5px solid var(--border, #d7dfee);
  border-radius: 8px;
  padding: 9px 12px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--text, #0f1f4b);
  background: var(--surface, #ffffff);
  resize: vertical;
}
.tp-ui-field input:focus,
.tp-ui-field textarea:focus {
  outline: none;
  border-color: var(--blue, #3b82f6);
  box-shadow: 0 0 0 3px rgba(80, 162, 255, 0.15);
}

.tp-ui-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}
.tp-ui-btn {
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 8px;
  cursor: pointer;
  border: 1.5px solid transparent;
}
.tp-ui-btn:focus-visible { outline: 2px solid var(--blue, #3b82f6); outline-offset: 2px; }
.tp-ui-cancel {
  background: transparent;
  color: var(--text, #0f1f4b);
  border-color: var(--border, #d7dfee);
}
.tp-ui-cancel:hover { background: var(--bg, #f4f7fd); }
.tp-ui-confirm {
  background: var(--blue, #3b82f6);
  color: #ffffff;
}
.tp-ui-confirm:hover { filter: brightness(0.92); }
.tp-ui-danger .tp-ui-confirm { background: var(--red, #dc2626); }
.tp-ui-confirm:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  filter: none;
}

/* ---------------- toasts ---------------- */

.tp-toast-host {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 1200;
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-width: min(360px, calc(100vw - 32px));
  pointer-events: none; /* only the toasts themselves are interactive */
}

.tp-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  background: var(--surface, #ffffff);
  color: var(--text, #0f1f4b);
  border: 1px solid var(--border, #e8edf6);
  border-left: 4px solid var(--blue, #3b82f6);
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(2, 12, 69, 0.18);
  padding: 12px 12px 12px 14px;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.88rem;
  line-height: 1.45;
  animation: tp-toast-in 0.2s ease;
}
.tp-toast-success { border-left-color: var(--green, #00915c); }
.tp-toast-success .tp-toast-icon { color: var(--green, #00915c); }
.tp-toast-error { border-left-color: var(--red, #dc2626); }
.tp-toast-error .tp-toast-icon { color: var(--red, #dc2626); }
.tp-toast-info .tp-toast-icon { color: var(--blue, #3b82f6); }

.tp-toast-icon { display: flex; flex-shrink: 0; margin-top: 1px; }
.tp-toast-text { flex: 1; }
.tp-toast-close {
  background: none;
  border: none;
  color: var(--text-muted, #64748b);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 2px;
  flex-shrink: 0;
}
.tp-toast-close:hover { color: var(--text, #0f1f4b); }
.tp-toast-close:focus-visible { outline: 2px solid var(--blue, #3b82f6); outline-offset: 2px; }

.tp-toast-out { opacity: 0; transform: translateY(6px); transition: opacity 0.25s, transform 0.25s; }

@keyframes tp-toast-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .tp-toast { animation: none; }
  .tp-toast-out { transition: none; }
}

/* Dark theme — same literal values both palettes flip to (consent.css model). */
body.dark .tp-ui-dialog,
body.dark .tp-toast {
  background: #101a38;
  color: #e8eefc;
  border-color: #26325c;
}
body.dark .tp-ui-title { color: #e8eefc; }
body.dark .tp-ui-danger .tp-ui-title { color: #f87171; }
body.dark .tp-ui-message,
body.dark .tp-ui-detail,
body.dark .tp-toast-close { color: #9fb0d8; }
body.dark .tp-ui-field-label { color: #e8eefc; }
body.dark .tp-ui-field input,
body.dark .tp-ui-field textarea {
  background: #0b1226;
  color: #e8eefc;
  border-color: #26325c;
}
body.dark .tp-ui-cancel { color: #e8eefc; border-color: #26325c; }
body.dark .tp-ui-cancel:hover { background: #182348; }
body.dark .tp-toast-close:hover { color: #e8eefc; }
