/* Toasts
   Toast notifications */

/* ======= TOAST NOTIFICATIONS (Modern pill style) ======= */
.app-toast-stack {
    position: fixed;
    top: 4.5rem; /* default: top-right, below navbar */
    right: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    /* Must outrank .modal-backdrop-formal (6000) and the JS confirm/prompt dialogs (10000) so
       errors raised while a modal is open (e.g. a failed status update) are still visible. */
    z-index: 10500;
    pointer-events: none;
    overflow: visible !important; /* Ensure toasts are not clipped */
    max-height: calc(100vh - 5rem); /* Prevent container from being too tall */
}

html[dir="rtl"] .app-toast-stack {
    right: auto;
    left: 2rem;
}

/* Position variants controlled from JS via class names */
.app-toast-stack--top-right {
    top: 4.5rem;
    bottom: auto;
    right: 2rem;
    left: auto;
}

.app-toast-stack--top-left {
    top: 4.5rem;
    bottom: auto;
    left: 2rem;
    right: auto;
}

.app-toast-stack--bottom-right {
    top: auto;
    bottom: 1.75rem;
    right: 2rem;
    left: auto;
}

.app-toast-stack--bottom-left {
    top: auto;
    bottom: 1.75rem;
    left: 2rem;
    right: auto;
}

.app-toast-stack--top-center {
    top: 4.5rem;
    bottom: auto;
    left: 50%;
    right: auto;
    transform: translateX(-20%); /* Shift much more to the right (was -35%) */
    max-width: 90vw; /* Prevent container from being too wide */
    overflow: visible; /* Allow content to be fully visible */
}

.app-toast {
    pointer-events: auto;
    min-width: 340px;
    max-width: 520px;
    display: grid;
    grid-template-columns: 40px 1fr 32px;
    gap: 0.75rem;
    align-items: center;
    padding: 1.05rem 1.4rem;
    border-radius: 0 !important; /* no rounded corners */
    background: #ffffff; /* solid white for maximum readability */
    border: 1px solid rgba(15, 23, 42, 0.06);
    box-shadow:
        0 12px 30px rgba(15, 23, 42, 0.12),
        0 2px 6px rgba(15, 23, 42, 0.08);
    animation: toast-enter 0.2s ease-out;
    position: relative;
    overflow: visible; /* Changed from hidden to visible to prevent text cutoff */
}

.app-toast::before {
    content: "";
    position: absolute;
    inset: 0 auto 0 0;
    width: 4px;
    background: var(--info-color);
}

html[dir="rtl"] .app-toast::before {
    inset: 0 0 0 auto;
}

.app-toast__icon {
    width: 38px;
    height: 38px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: rgba(52, 152, 219, 0.10);
    color: var(--info-color);
    font-size: 1rem;
}

.app-toast__content {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    text-align: start;
    min-width: 0; /* Allows flex item to shrink below content size */
    flex: 1; /* Takes available space */
}

.app-toast__title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--black-color);
}

.app-toast__message {
    font-size: 0.92rem;
    color: var(--text-light);
    line-height: 1.4;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Large error toast for center position - wider and more visible */
.app-toast--large-error {
    min-width: 500px;
    max-width: min(800px, 90vw);
    border-radius: 0 !important; /* no rounded corners */
    padding: 1.5rem 1.8rem;
    overflow: visible !important; /* Ensure content is not cut off */
    align-items: flex-start; /* Align to top to prevent vertical cutoff */
}

.app-toast--large-error .app-toast__message {
    font-size: 1rem;
    font-weight: 500;
    color: var(--black-color);
    line-height: 1.6;
    white-space: normal;
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

.app-toast--large-error .app-toast__title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    white-space: normal;
}

.app-toast--large-error .app-toast__content {
    overflow: visible;
    max-width: 100%;
}

@media (max-width: 768px) {
    .app-toast--large-error {
        min-width: auto;
        max-width: 95vw;
        padding: 1.2rem 1.4rem;
    }
}

.app-toast__close {
    width: 26px;
    height: 26px;
    border: none;
    background: rgba(148, 163, 184, 0.12);
    border-radius: 999px;
    display: grid;
    place-items: center;
    color: #6b7280;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.app-toast__close:hover {
    background: rgba(148, 163, 184, 0.2);
    color: #111827;
    transform: translateY(-1px);
}

/* Type-specific colors (soft pastel background + accent border + icon chip) */
.app-toast--success {
    background: #ffffff;
}
.app-toast--success::before {
    background: var(--success-color);
}

.app-toast--success .app-toast__icon {
    background: rgba(22, 163, 74, 0.12);
    color: var(--success-color);
}

.app-toast--warning {
    background: #ffffff;
}

.app-toast--warning::before {
    background: var(--warning-color);
}

.app-toast--warning .app-toast__icon {
    background: rgba(245, 158, 11, 0.14);
    color: var(--warning-color);
}

.app-toast--error,
.app-toast--delete {
    background: #ffffff;
}

.app-toast--error::before,
.app-toast--delete::before {
    background: var(--error-color);
}

.app-toast--error .app-toast__icon,
.app-toast--delete .app-toast__icon {
    background: rgba(239, 68, 68, 0.14);
    color: var(--error-color);
}

.app-toast--info {
    background: #ffffff;
}

.app-toast--info::before {
    background: var(--info-color);
}

.app-toast--info .app-toast__icon {
    background: rgba(59, 130, 246, 0.14);
    color: var(--info-color);
}

.app-toast--hide {
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

@keyframes toast-enter {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
