/**
 * App Toast v3 — modern, high-contrast notification system.
 * Drop-in replacement for toastr 2.x (same public API, new markup + design).
 *
 * Markup (generated by lib/js/toast.js):
 *   <div class="app-toast-container app-toast-top-right" id="app-toast-container">
 *     <div class="app-toast app-toast--success">
 *       <span class="app-toast__icon">…svg…</span>
 *       <div class="app-toast__body">
 *         <p class="app-toast__title">Thành công</p>
 *         <p class="app-toast__message">…</p>
 *       </div>
 *       <button class="app-toast__close" type="button">…svg…</button>
 *       <span class="app-toast__progress"></span>
 *     </div>
 *   </div>
 */

.app-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: min(400px, calc(100vw - 32px));
    max-height: calc(100vh - 40px);
    pointer-events: none;
}

.app-toast-container.app-toast-bottom-right {
    top: auto;
    bottom: 20px;
    flex-direction: column-reverse;
}

.app-toast-container.app-toast-top-left {
    right: auto;
    left: 20px;
}

.app-toast-container.app-toast-bottom-left {
    top: auto;
    right: auto;
    bottom: 20px;
    left: 20px;
    flex-direction: column-reverse;
}

.app-toast-container.app-toast-top-center,
.app-toast-container.app-toast-bottom-center {
    right: auto;
    left: 50%;
    transform: translateX(-50%);
    align-items: center;
}

.app-toast-container.app-toast-bottom-center {
    top: auto;
    bottom: 20px;
    flex-direction: column-reverse;
}

/* ---------------------------------------------------------------- toast --- */

.app-toast {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: 100%;
    box-sizing: border-box;
    padding: 14px 40px 14px 14px;
    overflow: hidden;
    background: #fff;
    border: 1px solid #e6ebf1;
    border-left: 4px solid #94a3b8;
    border-radius: 10px;
    box-shadow:
        0 18px 36px -18px rgba(15, 23, 42, .30),
        0 2px 6px rgba(15, 23, 42, .06);
    pointer-events: auto;
    opacity: 0;
    transform: translate3d(24px, 0, 0) scale(.98);
    transition:
        opacity .22s ease,
        transform .3s cubic-bezier(.21, .8, .3, 1);
    will-change: opacity, transform;
}

.app-toast-container.app-toast-top-left .app-toast,
.app-toast-container.app-toast-bottom-left .app-toast {
    transform: translate3d(-24px, 0, 0) scale(.98);
}

.app-toast-container.app-toast-top-center .app-toast,
.app-toast-container.app-toast-bottom-center .app-toast {
    transform: translate3d(0, -16px, 0) scale(.98);
}

.app-toast.is-visible {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
}

.app-toast.is-leaving {
    opacity: 0;
    transform: translate3d(24px, 0, 0) scale(.98);
}

/* Re-fired notification: brief pulse so it is noticed again. */
.app-toast.is-repeat {
    animation: app-toast-pulse .34s ease;
}

@keyframes app-toast-pulse {
    0%   { transform: translate3d(0, 0, 0) scale(1); }
    45%  { transform: translate3d(0, 0, 0) scale(1.015); }
    100% { transform: translate3d(0, 0, 0) scale(1); }
}

.app-toast__icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 9px;
    background: #f1f5f9;
    color: #64748b;
}

.app-toast__icon svg {
    width: 19px;
    height: 19px;
    display: block;
}

.app-toast__body {
    flex: 1 1 auto;
    min-width: 0;
    padding-top: 1px;
}

.app-toast__title {
    margin: 0 0 3px;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
    letter-spacing: .01em;
    color: #1e293b;
}

.app-toast__title:last-child {
    margin-bottom: 0;
}

.app-toast__message {
    margin: 0;
    font-size: 13.5px;
    font-weight: 400;
    line-height: 1.5;
    color: #52606d;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.app-toast__message a {
    color: inherit;
    text-decoration: underline;
}

.app-toast__close {
    position: absolute;
    top: 9px;
    right: 9px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    transition: background-color .15s ease, color .15s ease;
}

.app-toast__close svg {
    width: 13px;
    height: 13px;
    display: block;
}

.app-toast__close:hover,
.app-toast__close:focus {
    background: #f1f5f9;
    color: #334155;
    outline: none;
}

.app-toast__progress {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 3px;
    background: currentColor;
    opacity: .5;
    transform-origin: left center;
    animation: app-toast-progress var(--app-toast-duration, 4000ms) linear forwards;
}

.app-toast:hover .app-toast__progress {
    animation-play-state: paused;
}

@keyframes app-toast-progress {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* ------------------------------------------------------------- variants --- */

.app-toast--success {
    border-left-color: #16a34a;
    color: #16a34a;
    background: linear-gradient(90deg, #f6fef9 0%, #fff 42%);
}

.app-toast--success .app-toast__icon {
    background: #dcfce7;
    color: #15803d;
}

.app-toast--error {
    border-left-color: #dc2626;
    color: #dc2626;
    background: linear-gradient(90deg, #fef6f6 0%, #fff 42%);
}

.app-toast--error .app-toast__icon {
    background: #fee2e2;
    color: #b91c1c;
}

.app-toast--warning {
    border-left-color: #d97706;
    color: #d97706;
    background: linear-gradient(90deg, #fffbf3 0%, #fff 42%);
}

.app-toast--warning .app-toast__icon {
    background: #fef3c7;
    color: #b45309;
}

.app-toast--info {
    border-left-color: #2563eb;
    color: #2563eb;
    background: linear-gradient(90deg, #f5f9ff 0%, #fff 42%);
}

.app-toast--info .app-toast__icon {
    background: #dbeafe;
    color: #1d4ed8;
}

/* ----------------------------------------------------------- responsive --- */

@media (max-width: 575.98px) {
    .app-toast-container {
        top: 12px;
        right: 12px;
        left: 12px;
        width: auto;
        transform: none;
        align-items: stretch;
    }

    .app-toast-container.app-toast-bottom-right,
    .app-toast-container.app-toast-bottom-left,
    .app-toast-container.app-toast-bottom-center {
        top: auto;
        bottom: 12px;
    }

    .app-toast {
        padding: 13px 38px 13px 13px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .app-toast {
        transition: opacity .01ms linear;
        transform: none;
    }

    .app-toast__progress {
        animation: none;
    }
}
