/* Toast notifications (components/toast) and the legacy .toast element.
   Split from the former public/css/pos.css. Global. */

/* ==========================================================================
   TOAST NOTIFICATION
   ========================================================================== */
.toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--bg-toast);
    color: var(--text-toast);
    padding: 12px 18px;
    border-radius: var(--radius-lg);
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: var(--shadow-xl);
    transform: translateY(80px);
    opacity: 0;
    transition:
        transform var(--transition-slow) cubic-bezier(0.22, 1, 0.36, 1),
        opacity var(--transition-slow);
    z-index: var(--z-toast);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #4ade80;
    flex-shrink: 0;
}

/* ==========================================================================
   TOAST NOTIFICATIONS
   ========================================================================== */

/* Container — viewport-fixed top-right stack (never scrolls with the page) */
.toast-container {
    position: fixed;
    top: max(20px, env(safe-area-inset-top));
    right: max(20px, env(safe-area-inset-right));
    bottom: auto;
    left: auto;
    z-index: 2147483000;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-width: calc(100vw - 32px);
    pointer-events: none;
}

[dir="rtl"] .toast-container {
    right: auto;
    left: max(20px, env(safe-area-inset-left));
}

@media (max-width: 575.98px) {
    .toast-container,
    [dir="rtl"] .toast-container {
        top: max(12px, env(safe-area-inset-top));
        left: max(12px, env(safe-area-inset-left));
        right: max(12px, env(safe-area-inset-right));
        max-width: none;
    }
}

/* Individual toast card */
.toast-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    min-width: min(300px, calc(100vw - 32px));
    max-width: min(380px, calc(100vw - 32px));
    overflow-wrap: anywhere;
    word-break: break-word;
    padding: 14px 14px 18px;
    border-radius: var(--radius-xl, 12px);
    background: var(--bg-card, #ffffff);
    border: 1px solid var(--border-color, #e2e8f0);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    position: relative;
    overflow: hidden;
    pointer-events: all;

    /* Enter/Exit state */
    opacity: 0;
    transform: translateX(40px);
    transition:
        opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1),
        transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.toast-item.toast-show {
    opacity: 1;
    transform: translateX(0);
}

.toast-item.toast-hide {
    opacity: 0;
    transform: translateX(40px);
}

/* ── Per-type left border accent ─────────────────────────────── */
.toast-success {
    border-left: 4px solid var(--success-color, #22c55e);
}
.toast-warning {
    border-left: 4px solid var(--warning-color, #f59e0b);
}
.toast-error {
    border-left: 4px solid var(--danger-color, #ef4444);
}
.toast-info {
    border-left: 4px solid var(--primary-color, #06b6d4);
}

/* ── Icon wrapper ────────────────────────────────────────────── */
.toast-icon-wrap {
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    margin-top: 1px;
}

.toast-success .toast-icon-wrap {
    background: var(--success-light, #dcfce7);
    color: var(--success-color, #22c55e);
}
.toast-warning .toast-icon-wrap {
    background: #fef3c7;
    color: var(--warning-color, #f59e0b);
}
.toast-error .toast-icon-wrap {
    background: var(--danger-light, #fee2e2);
    color: var(--danger-color, #ef4444);
}
.toast-info .toast-icon-wrap {
    background: var(--primary-light, #e8f1f8);
    color: var(--primary-color, #06b6d4);
}

/* ── Body ────────────────────────────────────────────────────── */
.toast-body {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-gray-dark, #111827);
    margin-bottom: 2px;
}

.toast-message {
    font-size: 13px;
    color: var(--text-muted, #6b7280);
    line-height: 1.45;
    word-break: break-word;
}

/* ── Close button ────────────────────────────────────────────── */
.toast-close {
    flex-shrink: 0;
    background: none;
    border: none;
    color: var(--text-light, #9ca3af);
    cursor: pointer;
    padding: 0;
    font-size: 14px;
    line-height: 1;
    margin-top: 2px;
    transition: color 0.2s;
}

.toast-close:hover {
    color: var(--text-dark, #374151);
}

/* ── Progress bar (auto-dismiss countdown) ───────────────────── */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: var(--border-light, #f1f5f9);
}

.toast-progress-bar {
    height: 100%;
    width: 100%;
    animation: toast-countdown 4s linear forwards;
}

.toast-success .toast-progress-bar {
    background: var(--success-color, #22c55e);
}
.toast-warning .toast-progress-bar {
    background: var(--warning-color, #f59e0b);
}
.toast-error .toast-progress-bar {
    background: var(--danger-color, #ef4444);
}
.toast-info .toast-progress-bar {
    background: var(--primary-color, #06b6d4);
}

@keyframes toast-countdown {
    from {
        width: 100%;
    }
    to {
        width: 0%;
    }
}

@media print {
    .no-print,
    .print-btn {
        display: none !important;
    }
}
