/**
 * Velocity Commerce — Toast Notification CSS
 * Self-contained critical styles + animations + responsive + accessibility
 * These styles ensure toasts render correctly even if Tailwind CDN is offline.
 */

/* ─── Container ────────────────────────────────────────────────────────── */
#toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 200;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-width: 24rem;
    width: calc(100% - 2rem);
    pointer-events: none;
    padding-top: env(safe-area-inset-top, 0);
}

/* ─── Individual Toast — self-contained base styles ─────────────────────── */
#toast-container > div {
    pointer-events: auto;
    position: relative;
    overflow: hidden;
    word-break: break-word;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 1rem;
    box-shadow: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
    border: 1px solid rgba(0,0,0,.06);
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 0.875rem;
    line-height: 1.4;
    color: #fff;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Color variants — use CSS variables so admin customisation applies */
#toast-container > div[role="alert"],
#toast-container > div._toast-error {
    background-color: var(--vc-danger, #dc2626);
    color: #fff;
}
#toast-container > div._toast-success {
    background-color: var(--vc-success, #15803D);
    color: #fff;
}
#toast-container > div._toast-warning {
    background-color: var(--vc-warning, #B7791F);
    color: #fff;
}
#toast-container > div._toast-info,
#toast-container > div._toast-loading {
    background-color: var(--vc-text-secondary, #1f2937);
    color: #fff;
}

/* Icon */
#toast-container > div > .material-symbols-outlined {
    flex-shrink: 0;
    margin-top: 2px;
    font-size: 1.25rem;
}

/* Dismiss button */
#toast-container > div > button {
    flex-shrink: 0;
    padding: 4px;
    border-radius: 9999px;
    border: none;
    background: transparent;
    color: inherit;
    cursor: pointer;
    transition: background 0.15s;
}
#toast-container > div > button:hover {
    background: rgba(255,255,255,.15);
}

/* Text content */
#toast-container > div > div {
    flex: 1;
    min-width: 0;
}
#toast-container > div > div > p {
    margin: 0;
}
#toast-container > div > div > p:first-child {
    font-weight: 600;
    font-size: 0.875rem;
    line-height: 1.3;
}
#toast-container > div > div > p:last-child {
    font-size: 0.875rem;
    line-height: 1.35;
}

/* ─── Enter Animation ──────────────────────────────────────────────────── */
@keyframes toast-slide-in {
    from { opacity: 0; transform: translateX(24px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ─── Exit Animation ───────────────────────────────────────────────────── */
@keyframes toast-slide-out {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(24px); }
}

/* ─── Loading Pulse ────────────────────────────────────────────────────── */
@keyframes toast-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.6; }
}

/* ─── Progress Bar ─────────────────────────────────────────────────────── */
#toast-container > div > div:last-child[style*="width: 0"] {
    opacity: 0;
}

/* ─── Reduced Motion ───────────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    #toast-container > div {
        transition: none !important;
        animation: none !important;
    }
    #toast-container > div > div:last-child {
        transition: none !important;
        animation: none !important;
    }
}

/* ─── Mobile Adjustments ───────────────────────────────────────────────── */
@media (max-width: 640px) {
    #toast-container {
        top: 0.5rem;
        right: 0.5rem;
        left: 0.5rem;
        max-width: none;
        width: auto;
    }
}

/* ─── Print ────────────────────────────────────────────────────────────── */
@media print {
    #toast-container {
        display: none !important;
    }
}

/* ─── Mobile Bottom Nav Padding ──────────────────────────────────────── */
@media (max-width: 767px) {
    main#main-content {
        padding-bottom: 4.5rem;
    }
}

/* ─── Focus visible for accessibility ──────────────────────────────────── */
#toast-container button:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
    border-radius: 4px;
}

/* ─── Fallback banner when Toast library is unavailable ────────────────── */
.vc-toast-fallback {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 200;
    max-width: 24rem;
    width: calc(100% - 2rem);
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    box-shadow: 0 4px 12px rgba(0,0,0,.15);
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.875rem;
    line-height: 1.4;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: toast-slide-in 0.3s ease;
}
.vc-toast-fallback._success {
    background: #1a73e8;
    color: #fff;
}
.vc-toast-fallback._error {
    background: #dc2626;
    color: #fff;
}
.vc-toast-fallback._warning {
    background: #d97706;
    color: #fff;
}
.vc-toast-fallback._info {
    background: #1f2937;
    color: #fff;
}
