/**
 * ============================================================================
 * COMMISSARYOS UNIVERSAL TOAST & ALERT ENGINE STYLES (toast-engine.css)
 * High-performance, stacked, glassmorphic notifications with glowing micro-accents.
 * ============================================================================
 */

#toast-engine-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 99999999;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    width: 380px;
    max-width: calc(100vw - 32px);
    pointer-events: none;
    box-sizing: border-box;
}

/* Clear All Button */
.toast-clear-all-wrap {
    display: flex;
    justify-content: flex-end;
    pointer-events: auto;
    animation: toastFadeIn 0.25s ease-out;
}

.toast-clear-all-btn {
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(51, 65, 85, 0.7);
    color: var(--text-muted);
    font-size: 0.74rem;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.toast-clear-all-btn:hover {
    color: var(--text-main);
    background: var(--bg-panel);
    border-color: var(--text-faint);
    transform: translateY(-1px);
}

/* Individual Toast Card */
.toast-item {
    pointer-events: auto;
    position: relative;
    display: flex;
    flex-direction: column;
    width: 380px;
    min-width: 300px;
    max-width: 100%;
    background: rgba(15, 23, 42, 0.94);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.7), 0 4px 12px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    transform-origin: top right;
    animation: toastSlideIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    transition: transform 0.25s ease, opacity 0.25s ease, max-height 0.3s ease, margin 0.3s ease;
    box-sizing: border-box;
}

.toast-item.toast-dismissing {
    animation: toastSlideOut 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
    pointer-events: none;
}

.toast-item.toast-shake {
    animation: toastShake 0.45s ease-in-out;
}

/* Type Accent Border & Glows */
.toast-item.toast-success {
    border-left: 4px solid var(--success-accent);
    border-color: rgba(16, 185, 129, 0.35);
    box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.7), 0 0 16px rgba(16, 185, 129, 0.2);
}

.toast-item.toast-error {
    border-left: 4px solid var(--danger);
    border-color: rgba(239, 68, 68, 0.4);
    box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.7), 0 0 20px rgba(239, 68, 68, 0.25);
}

.toast-item.toast-warning {
    border-left: 4px solid var(--warning);
    border-color: rgba(245, 158, 11, 0.4);
    box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.7), 0 0 16px rgba(245, 158, 11, 0.2);
}

.toast-item.toast-info {
    border-left: 4px solid var(--accent);
    border-color: rgba(56, 189, 248, 0.35);
    box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.7), 0 0 16px rgba(56, 189, 248, 0.2);
}

/* Card Content Layout */
.toast-inner {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 14px 12px 14px;
    width: 100%;
    box-sizing: border-box;
}

/* Glowing Icon Badge */
.toast-icon-badge {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 1.1rem;
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.toast-success .toast-icon-badge {
    background: rgba(16, 185, 129, 0.16);
    color: var(--accent-emerald);
}

.toast-error .toast-icon-badge {
    background: rgba(239, 68, 68, 0.18);
    color: var(--danger-light);
}

.toast-warning .toast-icon-badge {
    background: rgba(245, 158, 11, 0.18);
    color: var(--warning-light);
}

.toast-info .toast-icon-badge {
    background: rgba(56, 189, 248, 0.16);
    color: var(--accent);
}

/* Text Body */
.toast-body {
    flex: 1 1 auto;
    width: 0;
    min-width: 220px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    box-sizing: border-box;
}

.toast-header-line {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    width: 100%;
    box-sizing: border-box;
}

.toast-title {
    font-weight: 700;
    font-size: 0.88rem;
    color: var(--text-main);
    letter-spacing: -0.01em;
    line-height: 1.3;
    overflow-wrap: break-word;
    word-break: normal;
}

.toast-meta-badges {
    display: flex;
    align-items: center;
    gap: 5px;
}

.toast-source-tag {
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 1px 6px;
    border-radius: 4px;
    background: rgba(51, 65, 85, 0.75);
    color: var(--text-muted);
    white-space: nowrap;
}

.toast-repeat-badge {
    font-size: 0.68rem;
    font-weight: 800;
    padding: 1px 6px;
    border-radius: 10px;
    background: rgba(56, 189, 248, 0.25);
    color: var(--accent);
    border: 1px solid rgba(56, 189, 248, 0.4);
    animation: toastScaleIn 0.2s ease-out;
}

.toast-message {
    font-size: 0.85rem;
    color: var(--text-subtle);
    line-height: 1.45;
    display: block;
    width: 100%;
    min-width: 200px;
    box-sizing: border-box;
    word-break: normal;
    overflow-wrap: break-word;
    white-space: pre-line;
}

/* Actions Row */
.toast-action-btn {
    align-self: flex-start;
    margin-top: 6px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.15);
    color: var(--text-main);
    font-size: 0.74rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toast-action-btn:hover {
    background: rgba(255, 255, 255, 0.18);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Close Button */
.toast-close-btn {
    background: transparent;
    border: none;
    color: var(--text-faint);
    font-size: 1.15rem;
    line-height: 1;
    cursor: pointer;
    padding: 2px 4px;
    border-radius: 4px;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-left: 2px;
}

.toast-close-btn:hover {
    color: var(--text-main);
    background: rgba(255, 255, 255, 0.08);
    transform: rotate(90deg);
}

/* Countdown Progress Bar */
.toast-progress-wrap {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.06);
    position: relative;
    overflow: hidden;
}

.toast-progress-fill {
    height: 100%;
    width: 100%;
    transform-origin: left;
    transition: transform linear;
}

.toast-success .toast-progress-fill {
    background: linear-gradient(90deg, var(--success-accent), var(--accent-emerald));
}

.toast-error .toast-progress-fill {
    background: linear-gradient(90deg, var(--danger), var(--danger-light));
}

.toast-warning .toast-progress-fill {
    background: linear-gradient(90deg, var(--warning), var(--warning-light));
}

.toast-info .toast-progress-fill {
    background: linear-gradient(90deg, var(--accent-blue), var(--accent));
}

/* Micro-Animations */
@keyframes toastSlideIn {
    from {
        opacity: 0;
        transform: translate3d(50px, 0, 0) scale(0.94);
    }
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
    }
}

@keyframes toastSlideOut {
    0% {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
        max-height: 200px;
        margin-bottom: 0;
    }
    100% {
        opacity: 0;
        transform: translate3d(80px, 0, 0) scale(0.88);
        max-height: 0;
        margin-bottom: -10px;
        padding-top: 0;
        padding-bottom: 0;
        border-width: 0;
    }
}

@keyframes toastFadeIn {
    from { opacity: 0; transform: translateY(-4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes toastScaleIn {
    from { transform: scale(0.5); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

@keyframes toastShake {
    0%, 100% { transform: translate3d(0, 0, 0); }
    20%, 60% { transform: translate3d(-6px, 0, 0); }
    40%, 80% { transform: translate3d(6px, 0, 0); }
}

/* Responsive adjustment for small / mobile kiosks */
@media (max-width: 480px) {
    #toast-engine-container {
        top: 10px;
        right: 10px;
        left: 10px;
        width: auto;
        max-width: 100%;
        align-items: stretch;
    }
    .toast-item {
        width: 100%;
        min-width: 0;
    }
}
