/*
 * Pavitra Portal — pvToast.css
 * ===============================
 * Marathi toast notification system.
 * Supports: success, error, warning, info types.
 * Stacks multiple toasts, auto-dismisses, respects prefers-reduced-motion.
 * Theme-aware: works in both light and dark mode via CSS variables.
 */

/* ── Toast container (top-right, fixed) ──────────────── */
#pvToastContainer {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: 380px;
    width: calc(100vw - 40px);
    pointer-events: none; /* container transparent; items clickable */
}

/* ── Individual toast card ────────────────────────────── */
.pv-toast {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--pv-surface, #ffffff);
    border: 1px solid var(--pv-border, #e2e8f0);
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12), 0 2px 8px rgba(0, 0, 0, 0.06);
    pointer-events: all;
    position: relative;
    overflow: hidden;
    min-width: 280px;

    /* Enter animation */
    animation: pvToastSlideIn 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* Exit animation class added by JS */
.pv-toast.pv-toast--exit {
    animation: pvToastSlideOut 0.28s ease-in forwards;
}

/* ── Left accent bar ──────────────────────────────────── */
.pv-toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    border-radius: 12px 0 0 12px;
    background: currentColor;
}

/* ── Icon wrapper ─────────────────────────────────────── */
.pv-toast__icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* ── Body ─────────────────────────────────────────────── */
.pv-toast__body {
    flex: 1;
    min-width: 0;
}

.pv-toast__type {
    font-size: 0.7rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    margin-bottom: 3px;
    opacity: 0.8;
}

.pv-toast__message {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--pv-text, #1a2332);
    line-height: 1.45;
    word-break: break-word;
}

/* ── Close button ─────────────────────────────────────── */
.pv-toast__close {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    border: none;
    background: transparent;
    color: var(--pv-text-muted, #718096);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    flex-shrink: 0;
    transition: background 0.15s ease, color 0.15s ease;
    padding: 0;
    line-height: 1;
}

.pv-toast__close:hover {
    background: var(--pv-border, #e2e8f0);
    color: var(--pv-text, #1a2332);
}

/* ── Progress bar (auto-dismiss countdown) ────────────── */
.pv-toast__progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    border-radius: 0 0 0 12px;
    background: currentColor;
    opacity: 0.35;
    transform-origin: left;
    animation: pvToastProgress linear forwards;
}

/* ── TYPE VARIANTS ────────────────────────────────────── */

/* SUCCESS */
.pv-toast--success {
    color: #16a34a;
    border-left-color: #16a34a;
}
.pv-toast--success .pv-toast__icon {
    background: #dcfce7;
    color: #16a34a;
}
.pv-toast--success .pv-toast__type { color: #16a34a; }

/* ERROR */
.pv-toast--error {
    color: #dc2626;
    border-left-color: #dc2626;
}
.pv-toast--error .pv-toast__icon {
    background: #fee2e2;
    color: #dc2626;
}
.pv-toast--error .pv-toast__type { color: #dc2626; }

/* WARNING */
.pv-toast--warning {
    color: #d97706;
    border-left-color: #d97706;
}
.pv-toast--warning .pv-toast__icon {
    background: #fef3c7;
    color: #d97706;
}
.pv-toast--warning .pv-toast__type { color: #d97706; }

/* INFO */
.pv-toast--info {
    color: #0891b2;
    border-left-color: #0891b2;
}
.pv-toast--info .pv-toast__icon {
    background: #e0f2fe;
    color: #0891b2;
}
.pv-toast--info .pv-toast__type { color: #0891b2; }

/* DELETE (special variant — red with trash icon) */
.pv-toast--delete {
    color: #b91c1c;
    border-left-color: #b91c1c;
}
.pv-toast--delete .pv-toast__icon {
    background: #fee2e2;
    color: #b91c1c;
}
.pv-toast--delete .pv-toast__type { color: #b91c1c; }

/* ── DARK MODE overrides ──────────────────────────────── */
[data-theme="dark"] .pv-toast {
    background: var(--pv-surface, #1a2a40);
    border-color: var(--pv-border, #2a3a52);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4), 0 2px 8px rgba(0, 0, 0, 0.25);
}

[data-theme="dark"] .pv-toast__message {
    color: var(--pv-text, #e2eaf8);
}

[data-theme="dark"] .pv-toast--success .pv-toast__icon { background: rgba(22, 163, 74, 0.18); }
[data-theme="dark"] .pv-toast--error   .pv-toast__icon { background: rgba(220, 38, 38, 0.18); }
[data-theme="dark"] .pv-toast--warning .pv-toast__icon { background: rgba(217, 119, 6, 0.18); }
[data-theme="dark"] .pv-toast--info    .pv-toast__icon { background: rgba(8, 145, 178, 0.18); }
[data-theme="dark"] .pv-toast--delete  .pv-toast__icon { background: rgba(185, 28, 28, 0.18); }

[data-theme="dark"] .pv-toast__close:hover {
    background: var(--pv-border, #2a3a52);
}

/* ── ANIMATIONS ───────────────────────────────────────── */
@keyframes pvToastSlideIn {
    from {
        opacity: 0;
        transform: translateX(100%) scale(0.92);
    }
    to {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes pvToastSlideOut {
    from {
        opacity: 1;
        transform: translateX(0) scale(1);
        max-height: 120px;
        margin-bottom: 0;
    }
    to {
        opacity: 0;
        transform: translateX(110%) scale(0.9);
        max-height: 0;
        margin-bottom: -10px;
        padding-top: 0;
        padding-bottom: 0;
    }
}

@keyframes pvToastProgress {
    from { width: 100%; }
    to   { width: 0%; }
}

/* ── Reduced motion ───────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .pv-toast,
    .pv-toast.pv-toast--exit {
        animation: none !important;
    }
    .pv-toast__progress { animation: none !important; width: 0; }
}

/* ── Mobile responsive ────────────────────────────────── */
@media (max-width: 480px) {
    #pvToastContainer {
        top: auto;
        bottom: 16px;
        right: 12px;
        left: 12px;
        max-width: 100%;
        width: auto;
    }

    @keyframes pvToastSlideIn {
        from {
            opacity: 0;
            transform: translateY(40px) scale(0.95);
        }
        to {
            opacity: 1;
            transform: translateY(0) scale(1);
        }
    }

    @keyframes pvToastSlideOut {
        from { opacity: 1; transform: translateY(0); max-height: 120px; }
        to   { opacity: 0; transform: translateY(40px); max-height: 0; padding: 0; }
    }
}
