/* ==========================================================================
   Toast component — Django Unfold-inspired notifications.

   Reusable across the app. Render one via `sfToast(...)` from
   js/components/toast.js. Styling leans on the project's --sf-* design
   tokens (defined in sass/project.scss) with safe fallbacks so the
   component also works on pages that don't expose them.

   Markup produced by sfToast():
     <div class="sf-toast sf-toast--warning toast" role="alert">
       <div class="sf-toast__icon">…svg…</div>
       <div class="sf-toast__body">
         <div class="sf-toast__title">…</div>
         <div class="sf-toast__message">…</div>
         <a class="sf-toast__link">…</a>       <!-- optional -->
       </div>
       <button class="sf-toast__close">×</button>
     </div>
   ========================================================================== */

/* Fixed, top-centered stack sitting above the sticky navbar. */
.sf-toast-container {
    position: fixed;
    top: 1.25rem;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    width: max-content;
    max-width: min(90vw, 460px);
    pointer-events: none; /* let clicks pass between toasts */
}

.sf-toast {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    width: 100%;
    min-width: 300px;
    padding: 0.875rem 1rem;
    background-color: var(--sf-surface, #ffffff);
    border: 1px solid var(--sf-border, #e5e7eb);
    border-radius: var(--sf-radius, 0.75rem);
    box-shadow:
        0 10px 15px -3px rgba(0, 0, 0, 0.1),
        0 4px 6px -4px rgba(0, 0, 0, 0.1);
    /* Slide in from the top. */
    opacity: 0;
    transform: translateY(calc(-100% - 1.5rem));
    transition:
        transform var(--duration-normal, 300ms) cubic-bezier(0.16, 1, 0.3, 1),
        opacity var(--duration-normal, 300ms) cubic-bezier(0.16, 1, 0.3, 1);
    will-change: transform, opacity;
    pointer-events: auto;
}

.sf-toast.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.sf-toast__icon {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    border-radius: var(--sf-radius-sm, 0.5rem);
}

.sf-toast__icon svg {
    width: 1.125rem;
    height: 1.125rem;
}

.sf-toast__body {
    flex: 1 1 auto;
    min-width: 0;
}

.sf-toast__title {
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25;
    color: var(--sf-text, #111827);
}

.sf-toast__message {
    margin-top: 0.125rem;
    font-size: 0.8125rem;
    line-height: 1.4;
    color: var(--sf-text-muted, #4b5563);
}

/* Optional action link (e.g. "Descarregar relatório"). */
.sf-toast__link {
    display: inline-block;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.4;
    color: var(--sf-primary, #ff731b);
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-color var(--duration-fast, 150ms) ease-out;
}

.sf-toast__link:hover,
.sf-toast__link:focus-visible {
    border-bottom-color: currentColor;
}

.sf-toast__close {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    padding: 0;
    border: 0;
    border-radius: 0.375rem;
    background: transparent;
    color: var(--sf-text-subtle, #9ca3af);
    font-size: 1.125rem;
    line-height: 1;
    cursor: pointer;
    transition: background-color var(--duration-fast, 150ms) ease-out;
}

.sf-toast__close:hover {
    background-color: var(--sf-border-light, #f3f4f6);
    color: var(--sf-text-muted, #4b5563);
}

/* Variants — the icon chip carries the semantic color. */
.sf-toast--warning .sf-toast__icon {
    color: #d97706; /* amber-600 */
    background-color: #fffbeb; /* amber-50 */
}
.sf-toast--danger .sf-toast__icon {
    color: #dc2626; /* red-600 */
    background-color: #fef2f2; /* red-50 */
}
.sf-toast--success .sf-toast__icon {
    color: #16a34a; /* green-600 */
    background-color: #f0fdf4; /* green-50 */
}
.sf-toast--info .sf-toast__icon {
    color: #2563eb; /* blue-600 */
    background-color: #eff6ff; /* blue-50 */
}
