/* =========================================================
   ux-system.css — برنج پارسی (فاز 10)
   Toast / Modal / Confirm / Loading / Alert
   ========================================================= */

.ux-toast-host {
    position: fixed;
    top: 88px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10050;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    width: min(420px, calc(100vw - 1.5rem));
    pointer-events: none;
}
@media (min-width: 769px) {
    .ux-toast-host {
        left: auto;
        right: 1.25rem;
        transform: none;
        width: 380px;
    }
}

.ux-toast {
    pointer-events: auto;
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.65rem;
    padding: 0.85rem 0.9rem;
    border-radius: 14px;
    background: #fff;
    color: #232823;
    box-shadow: 0 12px 32px rgba(0,0,0,0.14);
    border: 1px solid rgba(0,0,0,0.06);
    overflow: hidden;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.ux-toast-in { opacity: 1; transform: translateY(0); }
.ux-toast-out { opacity: 0; transform: translateY(-6px); }
.ux-toast.ux-no-motion { transition: none; }

.ux-toast-icon { font-size: 1.15rem; margin-top: 0.1rem; flex-shrink: 0; }
.ux-toast-success .ux-toast-icon { color: #00a085; }
.ux-toast-error .ux-toast-icon { color: #d63031; }
.ux-toast-warning .ux-toast-icon { color: #e17055; }
.ux-toast-info .ux-toast-icon,
.ux-toast-neutral .ux-toast-icon { color: #0984e3; }

.ux-toast-body { flex: 1; min-width: 0; }
.ux-toast-title { font-weight: 700; font-size: 0.9rem; margin-bottom: 0.15rem; }
.ux-toast-msg { font-size: 0.9rem; line-height: 1.45; }
.ux-toast-action {
    margin-top: 0.4rem;
    border: none;
    background: transparent;
    color: var(--green-primary, #1f8a5f);
    font-weight: 600;
    cursor: pointer;
    padding: 0;
    font-size: 0.85rem;
}
.ux-toast-close {
    border: none;
    background: transparent;
    color: #9aa39c;
    cursor: pointer;
    padding: 0.15rem;
    line-height: 1;
    flex-shrink: 0;
}
.ux-toast-close:hover { color: #232823; }
.ux-toast-progress {
    position: absolute;
    bottom: 0;
    right: 0;
    left: 0;
    height: 3px;
    background: rgba(0,0,0,0.12);
    transform-origin: right center;
    animation: ux-progress linear forwards;
}
.ux-toast-success .ux-toast-progress { background: #00b894; }
.ux-toast-error .ux-toast-progress { background: #e17055; }
.ux-toast-warning .ux-toast-progress { background: #fdcb6e; }
.ux-toast-info .ux-toast-progress { background: #0984e3; }

@keyframes ux-progress {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}
@media (prefers-reduced-motion: reduce) {
    .ux-toast-progress { animation: none !important; display: none; }
    .ux-toast { transition: none; }
}

/* Modal / Confirm */
.ux-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 20, 0.45);
    z-index: 10100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    transition: opacity 0.2s ease;
}
.ux-modal-overlay.ux-open { opacity: 1; }
.ux-modal {
    background: #fff;
    border-radius: 16px;
    width: min(440px, 100%);
    max-height: min(90vh, 640px);
    overflow: auto;
    padding: 1.35rem 1.25rem 1.15rem;
    position: relative;
    box-shadow: 0 20px 50px rgba(0,0,0,0.2);
    transform: translateY(10px) scale(0.98);
    transition: transform 0.2s ease;
}
.ux-modal-overlay.ux-open .ux-modal { transform: none; }
.ux-modal-lg { width: min(640px, 100%); }
.ux-modal-title { margin: 0 0 0.5rem; font-size: 1.15rem; color: #232823; }
.ux-modal-desc { margin: 0 0 1rem; color: #6b736c; line-height: 1.65; font-size: 0.95rem; }
.ux-modal-body { margin-bottom: 0.75rem; }
.ux-modal-x {
    position: absolute;
    top: 0.75rem;
    left: 0.75rem;
    border: none;
    background: transparent;
    color: #9aa39c;
    cursor: pointer;
    font-size: 1rem;
}
.ux-modal-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: flex-start;
    margin-top: 0.5rem;
}
.ux-btn {
    border: none;
    border-radius: 10px;
    padding: 0.65rem 1.1rem;
    font-weight: 600;
    font-size: 0.92rem;
    cursor: pointer;
    font-family: inherit;
}
.ux-btn-primary {
    background: linear-gradient(135deg, #00b894, #00a085);
    color: #fff;
}
.ux-btn-danger {
    background: linear-gradient(135deg, #e17055, #d63031);
    color: #fff;
}
.ux-btn-ghost {
    background: #f0f2f0;
    color: #232823;
}
.ux-btn:focus-visible {
    outline: 2px solid #00b894;
    outline-offset: 2px;
}

body.ux-scroll-lock { overflow: hidden; }

/* Loading */
.ux-loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.55);
    z-index: 10200;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ux-loading-overlay[hidden] { display: none !important; }
.ux-loading-box {
    background: #fff;
    border-radius: 14px;
    padding: 1.25rem 1.5rem;
    box-shadow: 0 12px 32px rgba(0,0,0,0.12);
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.ux-spinner {
    width: 22px;
    height: 22px;
    border: 3px solid #e2e5e1;
    border-top-color: #00b894;
    border-radius: 50%;
    animation: ux-spin 0.7s linear infinite;
}
@keyframes ux-spin { to { transform: rotate(360deg); } }
.ux-loading-label { font-size: 0.9rem; color: #232823; }

/* Inline alert */
.ux-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.6rem;
    padding: 0.75rem 0.9rem;
    border-radius: 12px;
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    line-height: 1.5;
}
.ux-alert-success { background: #e8f8f3; color: #0b6b56; }
.ux-alert-error { background: #fdecea; color: #9b2c2c; }
.ux-alert-warning { background: #fff6e8; color: #9a5b12; }
.ux-alert-info { background: #eaf4ff; color: #1a5276; }
.ux-alert-close {
    margin-right: auto;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 1.1rem;
    color: inherit;
    opacity: 0.7;
}

/* Dark mode */
body.dark-mode .ux-toast,
html.dark .ux-toast {
    background: #1e2420;
    color: #f2f4f2;
    border-color: rgba(255,255,255,0.08);
}
body.dark-mode .ux-modal,
html.dark .ux-modal {
    background: #1e2420;
    color: #f2f4f2;
}
body.dark-mode .ux-modal-title { color: #f2f4f2; }
body.dark-mode .ux-btn-ghost { background: #2a322c; color: #f2f4f2; }
body.dark-mode .ux-loading-box { background: #1e2420; color: #f2f4f2; }

@media (max-width: 480px) {
    .ux-modal {
        width: 100%;
        border-radius: 16px 16px 0 0;
        margin-top: auto;
        max-height: 85vh;
    }
    .ux-modal-overlay {
        align-items: flex-end;
        padding: 0;
    }
}
