/* ============================================================
   CIMS Toast Notification System
   Include: <link rel="stylesheet" href="{{ asset('css/toast.css') }}">
   ============================================================ */

/* ── Container ── */
#toast-container {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    gap: .65rem;
    max-width: 380px;
    width: calc(100vw - 3rem);
    pointer-events: none;
}

/* ── Toast Base ── */
.cims-toast {
    pointer-events: all;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: .85rem;
    background: #0f1f30;
    border: 1px solid rgba(255, 255, 255, .07);
    border-left: 3.5px solid transparent;
    border-radius: 10px;
    padding: .95rem 1rem .95rem 1rem;
    box-shadow:
        0 4px 6px rgba(0, 0, 0, .25),
        0 12px 28px rgba(0, 0, 0, .35),
        inset 0 1px 0 rgba(255, 255, 255, .04);
    cursor: default;
    overflow: hidden;
    /* Entry animation */
    animation: toast-in .32s cubic-bezier(.22, 1, .36, 1) both;
    transform-origin: right center;
}

/* Exit state applied by JS */
.cims-toast.toast-leaving {
    animation: toast-out .28s cubic-bezier(.55, 0, 1, .45) both;
}

/* ── Type Variants ── */
.cims-toast.toast-success { border-left-color: #3ecf8e; }
.cims-toast.toast-error   { border-left-color: #f55f5f; }
.cims-toast.toast-warning { border-left-color: #f0a53a; }
.cims-toast.toast-info    { border-left-color: #4ea8de; }

/* Subtle glow tint per type */
.cims-toast.toast-success::before,
.cims-toast.toast-error::before,
.cims-toast.toast-warning::before,
.cims-toast.toast-info::before {
    content: '';
    position: absolute;
    inset: 0;
    pointer-events: none;
    border-radius: inherit;
    opacity: .045;
}

.cims-toast.toast-success::before { background: #3ecf8e; }
.cims-toast.toast-error::before   { background: #f55f5f; }
.cims-toast.toast-warning::before { background: #f0a53a; }
.cims-toast.toast-info::before    { background: #4ea8de; }

/* ── Icon ── */
.toast-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .95rem;
    margin-top: .05rem;
}

.toast-success .toast-icon { background: rgba(62, 207, 142, .12); }
.toast-error   .toast-icon { background: rgba(245, 95,  95,  .12); }
.toast-warning .toast-icon { background: rgba(240, 165, 58,  .12); }
.toast-info    .toast-icon { background: rgba(78,  168, 222, .12); }

/* ── Body ── */
.toast-body {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: .83rem;
    font-weight: 500;
    line-height: 1.3;
    color: #f0f4f8;
    margin-bottom: .25rem;
    word-break: break-word;
}

/* Title-only (no message) — slightly larger */
.toast-body .toast-title:only-child {
    font-size: .86rem;
    margin-bottom: 0;
}

.toast-message {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: .78rem;
    font-weight: 300;
    line-height: 1.55;
    color: #7a91a8;
    word-break: break-word;
}

/* ── Dismiss Button ── */
.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 0;
    width: 22px;
    height: 22px;
    border-radius: 5px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4a6070;
    font-size: .8rem;
    line-height: 1;
    transition: background .15s, color .15s;
    margin-top: .05rem;
    margin-right: -.1rem;
}

.toast-close:hover {
    background: rgba(255, 255, 255, .07);
    color: #aac0d0;
}

.toast-close::before {
    content: '✕';
    font-size: .7rem;
}

/* ── Progress Bar ── */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2.5px;
    border-radius: 0 0 0 8px;
    transform-origin: left;
    animation: toast-progress linear both;
}

.toast-success .toast-progress { background: #3ecf8e; }
.toast-error   .toast-progress { background: #f55f5f; }
.toast-warning .toast-progress { background: #f0a53a; }
.toast-info    .toast-progress { background: #4ea8de; }

/* Pause progress on hover */
.cims-toast:hover .toast-progress {
    animation-play-state: paused;
}

/* ── Actions (optional) ── */
.toast-actions {
    display: flex;
    gap: .45rem;
    margin-top: .65rem;
    flex-wrap: wrap;
}

.toast-action-btn {
    font-family: 'DM Sans', system-ui, sans-serif;
    font-size: .72rem;
    font-weight: 500;
    padding: .3rem .75rem;
    border-radius: 5px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: opacity .15s;
    text-decoration: none;
    display: inline-block;
    letter-spacing: .02em;
}

.toast-action-btn:hover { opacity: .8; }

.toast-action-btn.btn-primary {
    background: #c9a84c;
    color: #0d1b2a;
    border-color: #c9a84c;
}

.toast-action-btn.btn-ghost {
    background: transparent;
    color: #7a91a8;
    border-color: rgba(255, 255, 255, .1);
}

/* ── Animations ── */
@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(calc(100% + 1.5rem)) scale(.96);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
        max-height: 200px;
        margin-bottom: 0;
    }
    to {
        opacity: 0;
        transform: translateX(calc(100% + 1.5rem)) scale(.94);
        max-height: 0;
        margin-bottom: -.65rem;
        padding-top: 0;
        padding-bottom: 0;
    }
}

@keyframes toast-progress {
    from { width: 100%; }
    to   { width: 0%;   }
}

/* ── Responsive ── */
@media (max-width: 480px) {
    #toast-container {
        top: auto;
        bottom: 1rem;
        right: .75rem;
        left: .75rem;
        width: auto;
        max-width: none;
    }

    .cims-toast {
        animation-name: toast-in-mobile;
    }

    .cims-toast.toast-leaving {
        animation-name: toast-out-mobile;
    }

    @keyframes toast-in-mobile {
        from { opacity: 0; transform: translateY(1rem) scale(.97); }
        to   { opacity: 1; transform: translateY(0) scale(1); }
    }

    @keyframes toast-out-mobile {
        from { opacity: 1; transform: translateY(0); max-height: 200px; }
        to   { opacity: 0; transform: translateY(.5rem); max-height: 0; padding: 0; }
    }
}