/* ==========================================================================
   Digits Toast Override — Modern Notification System
   Replaces the default Digits popup with a clean, modern toast notification
   ========================================================================== */

/* --- Container --- */
.digits-toast-container {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99999999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    pointer-events: none;
    max-width: calc(100vw - 32px);
}

/* --- Toast Card --- */
.digits-toast {
    pointer-events: auto;
    box-sizing: border-box;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: 300px;
    max-width: 480px;
    padding: 14px 16px 18px;
    background: #ffffff;
    border-radius: 12px;
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.12),
        0 2px 8px rgba(0, 0, 0, 0.08);
    border-left: 4px solid #e53935;
    position: relative;
    overflow: hidden;
    font-family: inherit;
    will-change: transform, opacity;
    animation: digitsToastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
    cursor: default;
}

/* --- Type Variants --- */
.digits-toast--error {
    border-left-color: #e53935;
}
.digits-toast--success {
    border-left-color: #43a047;
}
.digits-toast--notice {
    border-left-color: #ffb300;
}

/* --- RTL: border on the right --- */
html[dir="rtl"] .digits-toast {
    border-left: none;
    border-right: 4px solid #e53935;
}
html[dir="rtl"] .digits-toast--error {
    border-right-color: #e53935;
}
html[dir="rtl"] .digits-toast--success {
    border-right-color: #43a047;
}
html[dir="rtl"] .digits-toast--notice {
    border-right-color: #ffb300;
}

/* --- Icon --- */
.digits-toast__icon {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.digits-toast--error .digits-toast__icon {
    background: #fdecea;
    color: #e53935;
}
.digits-toast--success .digits-toast__icon {
    background: #e8f5e9;
    color: #43a047;
}
.digits-toast--notice .digits-toast__icon {
    background: #fff8e1;
    color: #ffb300;
}

/* --- Body --- */
.digits-toast__body {
    flex: 1;
    min-width: 0;
}
.digits-toast__title {
    font-size: 13px;
    font-weight: 700;
    margin-bottom: 2px;
    line-height: 1.4;
}
.digits-toast--error .digits-toast__title {
    color: #c62828;
}
.digits-toast--success .digits-toast__title {
    color: #2e7d32;
}
.digits-toast--notice .digits-toast__title {
    color: #ef6c00;
}
.digits-toast__message {
    font-size: 14px;
    color: #424242;
    line-height: 1.5;
    word-wrap: break-word;
}

/* --- Close Button --- */
.digits-toast__close {
    flex-shrink: 0;
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #9e9e9e;
    line-height: 0;
    border-radius: 4px;
    transition: color 0.2s, background 0.2s;
    margin-top: -2px;
}
.digits-toast__close:hover {
    color: #616161;
    background: rgba(0, 0, 0, 0.06);
}
.digits-toast__close:focus-visible {
    outline: 2px solid #90caf9;
    outline-offset: 2px;
}

/* --- Progress Bar --- */
.digits-toast__progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 100%;
    transform-origin: left;
}
.digits-toast--error .digits-toast__progress {
    background: #e53935;
}
.digits-toast--success .digits-toast__progress {
    background: #43a047;
}
.digits-toast--notice .digits-toast__progress {
    background: #ffb300;
}
html[dir="rtl"] .digits-toast__progress {
    left: auto;
    right: 0;
    transform-origin: right;
}

/* --- Animations --- */
@keyframes digitsToastIn {
    from {
        transform: translateY(120%) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}
@keyframes digitsToastOut {
    from {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
    to {
        transform: translateY(120%) scale(0.95);
        opacity: 0;
    }
}
@keyframes digitsToastProgress {
    from {
        transform: scaleX(1);
    }
    to {
        transform: scaleX(0);
    }
}
.digits-toast__progress--running {
    animation: digitsToastProgress linear forwards;
}
.digits-toast--removing {
    animation: digitsToastSlideOut 0.3s cubic-bezier(0.4, 0, 1, 1) forwards;
}
@keyframes digitsToastSlideOut {
    from {
        transform: translateY(0);
        opacity: 1;
    }
    to {
        transform: translateY(120%);
        opacity: 0;
    }
}

/* --- Hover pauses progress bar --- */
.digits-toast:hover .digits-toast__progress--running {
    animation-play-state: paused;
}

/* --- Dark Mode --- */
@media (prefers-color-scheme: dark) {
    .digits-toast {
        background: #1e1e1e;
        box-shadow:
            0 8px 32px rgba(0, 0, 0, 0.4),
            0 2px 8px rgba(0, 0, 0, 0.3);
    }
    .digits-toast__message {
        color: #e0e0e0;
    }
    .digits-toast__close {
        color: #757575;
    }
    .digits-toast__close:hover {
        color: #bdbdbd;
        background: rgba(255, 255, 255, 0.08);
    }
    .digits-toast--error .digits-toast__icon {
        background: rgba(229, 57, 53, 0.15);
    }
    .digits-toast--success .digits-toast__icon {
        background: rgba(67, 160, 71, 0.15);
    }
    .digits-toast--notice .digits-toast__icon {
        background: rgba(255, 179, 0, 0.15);
    }
}

/* --- Mobile --- */
@media (max-width: 600px) {
    .digits-toast-container {
        bottom: 16px;
        max-width: calc(100vw - 24px);
    }
    .digits-toast {
        min-width: unset;
        width: 100%;
        padding: 12px 14px 16px;
    }
    .digits-toast__icon {
        width: 32px;
        height: 32px;
    }
    .digits-toast__title {
        font-size: 12px;
    }
    .digits-toast__message {
        font-size: 13px;
    }
}

/* --- Respect reduced motion --- */
@media (prefers-reduced-motion: reduce) {
    .digits-toast,
    .digits-toast--removing {
        animation-duration: 0.01s;
    }
    .digits-toast__progress--running {
        animation: none;
        opacity: 0.3;
    }
}