/* Toast notifications */

/* Entry: slides down from the top */
@keyframes slideInDown {
  from {
    transform: translateY(-0.75rem);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Exit: slides up and fades out */
@keyframes slideOutUp {
  from {
    transform: translateY(0);
    opacity: 1;
  }
  to {
    transform: translateY(-0.75rem);
    opacity: 0;
  }
}

.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
  animation: slideInDown 0.25s ease-out;
  min-width: 250px;
  max-width: 400px;
}

/* Colors come from theme tokens — adapt to light and dark mode automatically */
.toast.toast-success {
  background-color: hsl(var(--status-success));
  color: hsl(var(--primary-foreground));
}

.toast.toast-error {
  background-color: hsl(var(--destructive));
  color: hsl(var(--destructive-foreground));
}

.toast.toast-info {
  background-color: hsl(var(--primary));
  color: hsl(var(--primary-foreground));
}

.toast.toast-warning {
  background-color: hsl(var(--warning));
  color: hsl(var(--warning-foreground));
}

.toast.hiding {
  animation: slideOutUp 0.2s ease-in forwards;
}

.toast-icon {
  flex-shrink: 0;
  width: 1rem;
  height: 1rem;
}

.toast-message {
  flex: 1;
  font-size: 0.875rem;
  font-weight: 500;
  /* Messages interpolate user text (field names) — wrap long words instead
     of overflowing the toast */
  overflow-wrap: anywhere;
}

/* A11y: no slide animation under reduced motion — the toast just appears/disappears */
@media (prefers-reduced-motion: reduce) {
  .toast,
  .toast.hiding {
    animation: none;
  }
}

/* =========================================================================
   Checkbox — #852
   Centralizes all states of the "Send to me" checkbox.
   Uses only theme variables: zero hardcoded colors.
   ========================================================================= */

.styled-checkbox {
  -webkit-appearance: none;
  appearance: none;
  width: 1rem;
  height: 1rem;
  min-width: 1rem;
  /* min-height mirrors min-width: without it, template_editor.css's global
     mobile rule (min-height: 44px on button/.cursor-pointer) stretches the
     checkbox into a 16×44 rectangle when someone adds .cursor-pointer
     alongside this class. This file loads after the tailwind bundle, so
     these minimums win the cascade. */
  min-height: 1rem;
  max-width: 1rem;
  max-height: 1rem;
  border: 1px solid hsl(var(--input));
  border-radius: 0.25rem;
  background-color: hsl(var(--background));
  flex-shrink: 0;
  cursor: pointer;
  transition: border-color 150ms, background-color 150ms, box-shadow 150ms;
}

.styled-checkbox:checked {
  background-color: hsl(var(--primary));
  border-color: hsl(var(--primary));
  background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 16 16' fill='white' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M12.207 4.793a1 1 0 010 1.414l-5 5a1 1 0 01-1.414 0l-2-2a1 1 0 011.414-1.414L6.5 9.086l4.293-4.293a1 1 0 011.414 0z'/%3e%3c/svg%3e");
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
}

.styled-checkbox:hover:not(:disabled) {
  border-color: hsl(var(--primary));
  box-shadow: 0 0 0 2px hsl(var(--primary) / 0.15);
}

.styled-checkbox:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

.styled-checkbox:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* =========================================================================
   Success modal scrollbar — #853
   Thin, theme-aware scrollbar for when "More Options" expands the modal.
   ========================================================================= */

[data-easy-form-target="successModal"],
[data-easy-form-preview-fields-target="successModal"] {
  scrollbar-width: thin;
  scrollbar-color: hsl(var(--border)) transparent;
}

[data-easy-form-target="successModal"]::-webkit-scrollbar,
[data-easy-form-preview-fields-target="successModal"]::-webkit-scrollbar {
  width: 6px;
}

[data-easy-form-target="successModal"]::-webkit-scrollbar-thumb,
[data-easy-form-preview-fields-target="successModal"]::-webkit-scrollbar-thumb {
  background-color: hsl(var(--border));
  border-radius: 3px;
}

/* Details chevron rotation */
section[name="easy-form-new"] details summary {
  cursor: pointer;
  user-select: none;
}

section[name="easy-form-new"] details[open] summary [data-lucide="chevron-down"] {
  transform: rotate(180deg);
}

/* Responsive — mobile: full width at the top, honoring notch/safe areas */
@media (max-width: 640px) {
  .toast-container {
    top: max(1rem, env(safe-area-inset-top));
    left: max(1rem, env(safe-area-inset-left));
    right: max(1rem, env(safe-area-inset-right));
  }

  .toast {
    width: 100%;
    min-width: 0; /* the desktop 250px min-width must not lock narrow screens */
    max-width: none;
  }
}
