/* ==========================================================
   CEVA Logistics - Shared Toast CSS
   Used by both client (fe) and admin layouts.
   Loaded after the layout's main stylesheet.
   ========================================================== */

/* ---------- Toast container (fixed top, stacks toasts) ---------- */
.toast-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 14px 14px 0 14px;
    pointer-events: none;     /* allow clicks through gaps; toasts re-enable */
}

.toast {
    position: relative;
    pointer-events: auto;
    width: 100%;
    max-width: 480px;
    min-height: 52px;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 44px 12px 14px;
    background: #ffffff;
    color: #1c1e21;
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 6px rgba(0, 0, 0, 0.06);
    border-left: 4px solid #3b82f6;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.45;
    font-family: inherit;

    /* Hidden state (start above the viewport) */
    opacity: 0;
    transform: translateY(-120%);
    will-change: transform, opacity;
}

.toast--show {
    animation: toastSlideIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.toast--hide {
    animation: toastSlideOut 0.25s ease-in forwards;
}

/* Type-specific accent colours */
.toast--success { border-left-color: #10b981; }
.toast--success .toast__icon { color: #10b981; }

.toast--error   { border-left-color: #ef4444; }
.toast--error   .toast__icon { color: #ef4444; }

.toast--warning { border-left-color: #f59e0b; }
.toast--warning .toast__icon { color: #f59e0b; }

.toast--info    { border-left-color: #3b82f6; }
.toast--info    .toast__icon { color: #3b82f6; }

.toast__icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.toast__body {
    flex: 1 1 auto;
    min-width: 0;
    word-break: break-word;
    white-space: pre-wrap;
    color: #1c1e21;
}

.toast__close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: #64748b;
    cursor: pointer;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease, color 0.15s ease;
    padding: 0;
}
.toast__close:hover {
    background: rgba(0, 0, 0, 0.06);
    color: #1c1e21;
}
.toast__close:focus-visible {
    outline: 2px solid #0ea5e9;
    outline-offset: 1px;
}

/* Auto-hide progress bar at the bottom of each toast */
.toast__progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: rgba(0, 0, 0, 0.04);
    overflow: hidden;
}
.toast__progress-bar {
    display: block;
    height: 100%;
    width: 100%;
    transform-origin: left center;
    background: currentColor;
    opacity: 0.35;
    animation: toastProgress 5s linear forwards;
}
.toast--success .toast__progress-bar { color: #10b981; }
.toast--error   .toast__progress-bar { color: #ef4444; }
.toast--warning .toast__progress-bar { color: #f59e0b; }
.toast--info    .toast__progress-bar { color: #3b82f6; }

/* Animations */
@keyframes toastSlideIn {
    0%   { opacity: 0; transform: translateY(-120%); }
    60%  { opacity: 1; transform: translateY(6px);    }
    100% { opacity: 1; transform: translateY(0);      }
}
@keyframes toastSlideOut {
    0%   { opacity: 1; transform: translateY(0);     max-height: 200px; margin-top: 0; }
    100% { opacity: 0; transform: translateY(-120%); max-height: 0;     margin-top: -10px; }
}
@keyframes toastProgress {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    .toast--show,
    .toast--hide {
        animation-duration: 0.01s;
    }
    .toast__progress-bar {
        animation-duration: 5s;
    }
}

/* Dark mode — keep contrast on dark backgrounds (e.g. login) */
@media (prefers-color-scheme: dark) {
    .toast {
        background: #1f2937;
        color: #f3f4f6;
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    }
    .toast__body { color: #f3f4f6; }
    .toast__close { color: #cbd5e1; }
    .toast__close:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
}

/* Admin context: toast sits above the sidebar/topbar and is slightly narrower */
.admin-app .toast-container,
body.admin-app .toast-container,
.admin-content ~ .toast-container {
    z-index: 9999;
}
