/* =============================================
   مستر اير — نظام الرسائل الاحترافي
   Premium Toast + Empty States + Inline Validation
   ============================================= */

/* ── Toast container (top-right على الديسكتوب) ── */
.toast-container {
    position: fixed !important;
    top: 5rem !important;
    bottom: auto !important;
    left: auto !important;
    right: 1rem !important;
    transform: none !important;
    z-index: 99999 !important;
    display: flex !important;
    flex-direction: column !important;
    align-items: flex-end;          /* الكارت يلتف حول محتواه (RTL يمين) */
    gap: 0.6rem !important;
    pointer-events: none !important;
    width: calc(100% - 2rem);
    max-width: 380px;
}

/* ── TOAST CARD — شريط أفقي مدمج ── */
.toast {
    pointer-events: auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 8px 28px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.05);
    border: 1px solid rgba(0,0,0,0.06);
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 0.55rem;
    padding: 0.55rem 0.8rem 0.55rem 2.1rem;   /* مساحة يسار لزر الإغلاق */
    max-width: 100%;
    overflow: hidden;
    position: relative;
    animation: mrToastIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}
.toast.removing {
    animation: mrToastOut 0.35s ease forwards;
}

/* ── TOAST BODY (أيقونة + نص) ── */
.toast-body {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0;
    flex: 1;
    min-width: 0;
}

/* ── TOAST ICON ── */
.toast-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    flex-shrink: 0;
    animation: mrIconPop 0.4s 0.15s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

/* ── TOAST TEXT ── */
.toast-text {
    flex: 1;
    min-width: 0;
}
.toast-title {
    font-weight: 700;
    font-size: 0.85rem;
    line-height: 1.35;
    margin: 0;
}
.toast-msg {
    font-size: 0.76rem;
    color: #64748b;
    line-height: 1.4;
    margin-top: 1px;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ── TOAST CLOSE (يسار، في المنتصف عموديًا) ── */
.toast-close {
    position: absolute;
    top: 50%;
    left: 8px;
    transform: translateY(-50%);
    width: 22px;
    height: 22px;
    border: none;
    background: rgba(0,0,0,0.05);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.6rem;
    color: #94a3b8;
    transition: all 0.2s;
    flex-shrink: 0;
}
.toast-close:hover {
    background: rgba(0,0,0,0.1);
    color: #334155;
}

/* ── TOAST ACTIONS — أزرار مدمجة inline (بدون فاصل علوي) ── */
.toast-actions {
    display: flex;
    gap: 0.4rem;
    flex-shrink: 0;
}
.toast-action {
    padding: 0.4rem 0.7rem;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.76rem;
    font-weight: 700;
    color: #0077C8;
    background: #EAF7FF;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.2s, color 0.2s;
    font-family: inherit;
    display: inline-flex;
    align-items: center;
    gap: 4px;
}
.toast-action:hover {
    background: #d8eefc;
}
.toast-action.primary {
    color: #fff;
    background: #0077C8;
}
.toast-action.primary:hover {
    background: #005fa3;
}

/* ── PROGRESS BAR — خط رفيع أسفل الكارت ── */
.toast-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 2px;
    background: transparent;
    overflow: hidden;
}
.toast-progress-bar {
    height: 100%;
    border-radius: 0;
    animation: mrProgress linear forwards;
}

/* ── TYPE COLORS ── */
.toast-success .toast-icon { background: #d1fae5; color: #059669; }
.toast-success .toast-title { color: #065f46; }
.toast-success .toast-progress-bar { background: linear-gradient(90deg, #10b981, #059669); }
.toast-success .toast-icon i { animation: mrIconPop 0.4s 0.15s cubic-bezier(0.34, 1.56, 0.64, 1) both; }

.toast-error .toast-icon { background: #fee2e2; color: #dc2626; }
.toast-error .toast-title { color: #991b1b; }
.toast-error .toast-progress-bar { background: linear-gradient(90deg, #ef4444, #dc2626); }
.toast-error .toast-icon i { animation: mrIconShake 0.4s 0.15s ease both; }

.toast-warning .toast-icon { background: #fef3c7; color: #d97706; }
.toast-warning .toast-title { color: #92400e; }
.toast-warning .toast-progress-bar { background: linear-gradient(90deg, #f59e0b, #d97706); }

.toast-info .toast-icon { background: #dbeafe; color: #2563eb; }
.toast-info .toast-title { color: #1e40af; }
.toast-info .toast-progress-bar { background: linear-gradient(90deg, #3b82f6, #2563eb); }

/* ── ANIMATIONS ── */
@keyframes mrToastIn {
    from { opacity: 0; transform: translateX(40px) scale(0.95); }
    to { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes mrToastOut {
    from { opacity: 1; transform: translateX(0) scale(1); max-height: 200px; margin-bottom: 0; }
    to { opacity: 0; transform: translateX(60px) scale(0.9); max-height: 0; margin-bottom: -10px; padding: 0; }
}
@keyframes mrIconPop {
    from { transform: scale(0); }
    to { transform: scale(1); }
}
@keyframes mrIconShake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-3px); }
    40%, 80% { transform: translateX(3px); }
}
@keyframes mrProgress {
    from { width: 100%; }
    to { width: 0%; }
}

/* =============================================
   EMPTY STATES
   ============================================= */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    max-width: 420px;
    margin: 2rem auto;
    animation: mrFadeUp 0.5s ease both;
}
.empty-state-icon {
    width: 80px;
    height: 80px;
    margin: 0 auto 1.25rem;
    border-radius: 50%;
    background: linear-gradient(135deg, #f0f8ff, #e0f2fe);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    color: #0077C8;
}
.empty-state h3 {
    font-size: 1.15rem;
    font-weight: 800;
    color: #1a2a3a;
    margin-bottom: 0.5rem;
}
.empty-state p {
    font-size: 0.88rem;
    color: #64748b;
    margin-bottom: 1.5rem;
    line-height: 1.6;
}
.empty-state .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.7rem 1.5rem;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.88rem;
    text-decoration: none;
    transition: all 0.25s;
}
.empty-state .btn-primary {
    background: linear-gradient(135deg, #0077C8, #005fa3);
    color: #fff;
    border: none;
}
.empty-state .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,119,200,0.3);
}
.empty-state .btn-outline {
    background: #fff;
    color: #0077C8;
    border: 2px solid #0077C8;
}
.empty-state .btn-outline:hover {
    background: #f0f8ff;
}
.empty-state-actions {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    flex-wrap: wrap;
}

@keyframes mrFadeUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =============================================
   INLINE VALIDATION
   ============================================= */
.field-error {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239,68,68,0.1) !important;
}
.field-error-msg {
    display: flex;
    align-items: center;
    gap: 4px;
    color: #dc2626;
    font-size: 0.75rem;
    font-weight: 600;
    margin-top: 4px;
    animation: mrFadeUp 0.25s ease;
}
.field-error-msg i {
    font-size: 0.7rem;
}
.field-success {
    border-color: #10b981 !important;
    box-shadow: 0 0 0 3px rgba(16,185,129,0.1) !important;
}

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
    /* متمركز فوق الشريط السفلي — لا يغطّي الشريط ولا يملأ الشاشة */
    .toast-container {
        top: auto !important;
        bottom: calc(var(--bottom-nav-height, 60px) + env(safe-area-inset-bottom, 0px) + 0.6rem) !important;
        left: 50% !important;
        right: auto !important;
        transform: translateX(-50%) !important;
        width: calc(100% - 1.5rem) !important;
        max-width: 380px !important;
        align-items: stretch;
    }
    .toast-title { font-size: 0.82rem; }
    .toast-msg { font-size: 0.74rem; }
    .toast-action { font-size: 0.74rem; padding: 0.4rem 0.65rem; }

    .empty-state { padding: 2rem 1rem; }
    .empty-state-icon { width: 64px; height: 64px; font-size: 1.5rem; }
    .empty-state h3 { font-size: 1.05rem; }
}

/* ── REDUCED MOTION ── */
@media (prefers-reduced-motion: reduce) {
    .toast, .toast.removing, .toast-icon, .toast-icon i,
    .toast-progress-bar, .empty-state { animation: none !important; }
    .toast { opacity: 1; transform: none; }
}
