/* ═══════════ مكوّنات واجهة موحّدة (أزرار الإجراءات، نوافذ التأكيد، الإشعارات) ═══════════ */

/* ── أزرار الإجراءات داخل الجداول: نص + أيقونة + لون مميّز لكل نوع ── */
.btn-edit, .btn-delete, .btn-view {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 12px !important; border-radius: 8px !important;
    font-size: 0.82rem !important; font-weight: 700; line-height: 1.2;
    border: 1.5px solid transparent !important; box-shadow: none !important;
    transition: background .15s, color .15s, border-color .15s !important;
    transform: none !important; cursor: pointer;
}
.btn-edit   { background: #eff6ff !important; color: #1d4ed8 !important; border-color: #bfdbfe !important; }
.btn-edit:hover   { background: #1d4ed8 !important; color: #fff !important; border-color: #1d4ed8 !important; }
.btn-delete { background: #fef2f2 !important; color: #b91c1c !important; border-color: #fecaca !important; }
.btn-delete:hover { background: #dc2626 !important; color: #fff !important; border-color: #dc2626 !important; }
.btn-view   { background: #f0fdf4 !important; color: #15803d !important; border-color: #bbf7d0 !important; }
.btn-view:hover   { background: #16a34a !important; color: #fff !important; border-color: #16a34a !important; }
.btn-edit i, .btn-delete i, .btn-view i { font-size: 0.85em; }

/* خلية الإجراءات: مسافة ثابتة، تلتف على الشاشات الصغيرة، الحذف دائماً في الأخير */
td .btn-delete { margin-inline-start: 4px; }
td:has(> .btn-edit), td:has(> .btn-delete) { white-space: nowrap; }
@media (max-width: 700px) {
    td:has(> .btn-edit), td:has(> .btn-delete) { white-space: normal; }
    .btn-edit, .btn-delete, .btn-view { padding: 6px 9px !important; }
}

/* ── زر الخروج في الشريط العلوي ── */
.btn-logout {
    display: inline-flex; align-items: center; gap: 6px; margin-inline-start: 10px;
    background: #fff !important; color: #b91c1c !important; border: 1.5px solid #fecaca !important;
    box-shadow: none !important; transform: none !important;
}
.btn-logout:hover { background: #dc2626 !important; color: #fff !important; border-color: #dc2626 !important; }
.nav-logout { opacity: .85; }
.nav-logout:hover { opacity: 1; }

/* ── نافذة الحوار (تأكيد / إدخال) ── */
.ui-dialog-backdrop {
    position: fixed; inset: 0; z-index: 10000;
    background: rgba(15, 23, 42, .55); backdrop-filter: blur(2px);
    display: flex; align-items: center; justify-content: center; padding: 16px;
    animation: ui-fade .15s ease-out;
}
.ui-dialog {
    background: #fff; width: 100%; max-width: 440px; border-radius: 16px;
    box-shadow: 0 25px 60px rgba(0,0,0,.25); overflow: hidden; text-align: right;
    font-family: var(--font, 'Tajawal', sans-serif); animation: ui-pop .18s ease-out;
}
.ui-dialog-body { padding: 24px 24px 8px; display: flex; gap: 16px; align-items: flex-start; }
.ui-dialog-icon {
    flex: 0 0 46px; height: 46px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: 800;
}
.ui-dialog-icon.danger  { background: #fee2e2; color: #dc2626; }
.ui-dialog-icon.info    { background: #dbeafe; color: #2563eb; }
.ui-dialog-icon.success { background: #dcfce7; color: #16a34a; }
.ui-dialog h3 { margin: 0 0 6px; font-size: 1.1rem; color: #0f172a; }
.ui-dialog p  { margin: 0; color: #475569; font-size: .95rem; line-height: 1.7; white-space: pre-line; }
.ui-dialog-fields { padding: 4px 24px 0; }
.ui-dialog-fields label { display: block; font-size: .85rem; font-weight: 700; color: #334155; margin: 12px 0 5px; }
.ui-dialog-fields input, .ui-dialog-fields textarea {
    width: 100%; padding: 10px 12px; border: 1.5px solid #e2e8f0; border-radius: 10px;
    font-family: inherit; font-size: .95rem; outline: none; transition: border-color .15s;
}
.ui-dialog-fields input:focus, .ui-dialog-fields textarea:focus { border-color: #2563eb; }
.ui-dialog-fields label.ui-check {
    display: flex; align-items: center; gap: 8px; font-weight: 600; cursor: pointer; margin-top: 14px;
}
.ui-dialog-fields label.ui-check input { width: 18px; height: 18px; padding: 0; flex: 0 0 auto; accent-color: #2563eb; }
.ui-dialog-error { color: #dc2626; font-size: .85rem; margin-top: 8px; min-height: 1em; }
.ui-secret {
    display: flex; gap: 8px; align-items: center; margin-top: 12px;
    background: #f8fafc; border: 1.5px dashed #94a3b8; border-radius: 10px; padding: 10px 12px;
}
.ui-secret code { flex: 1; font-size: 1.3rem; letter-spacing: 2px; direction: ltr; text-align: left; font-weight: 800; color: #0f172a; }
.ui-dialog-actions {
    display: flex; gap: 10px; justify-content: flex-start; padding: 20px 24px 22px;
    flex-direction: row;
}
.ui-btn {
    padding: 10px 20px; border-radius: 10px; font-family: inherit; font-weight: 700; font-size: .92rem;
    cursor: pointer; border: 1.5px solid transparent; transition: background .15s, border-color .15s;
}
.ui-btn-primary { background: #2563eb; color: #fff; }
.ui-btn-primary:hover { background: #1d4ed8; }
.ui-btn-danger  { background: #dc2626; color: #fff; }
.ui-btn-danger:hover  { background: #b91c1c; }
.ui-btn-ghost   { background: #fff; color: #334155; border-color: #e2e8f0; }
.ui-btn-ghost:hover   { background: #f1f5f9; }
.ui-btn:focus-visible { outline: 3px solid #93c5fd; outline-offset: 2px; }

/* ── إشعارات منبثقة (بدل alert) ── */
.ui-toasts {
    position: fixed; z-index: 10001; bottom: 20px; left: 20px;
    display: flex; flex-direction: column; gap: 10px; max-width: min(380px, calc(100vw - 40px));
}
.ui-toast {
    display: flex; gap: 10px; align-items: flex-start;
    background: #fff; border-radius: 12px; padding: 12px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.15);
    border-right: 5px solid #2563eb; font-family: var(--font, 'Tajawal', sans-serif); font-size: .92rem;
    color: #0f172a; animation: ui-slide .2s ease-out; white-space: pre-line; text-align: right;
}
.ui-toast.success { border-right-color: #16a34a; }
.ui-toast.error   { border-right-color: #dc2626; }
.ui-toast .ui-toast-mark { font-weight: 900; }
.ui-toast.success .ui-toast-mark { color: #16a34a; }
.ui-toast.error   .ui-toast-mark { color: #dc2626; }
.ui-toast.info    .ui-toast-mark { color: #2563eb; }
.ui-toast button { margin-inline-start: auto; background: none; border: none; color: #94a3b8; cursor: pointer; font-size: 16px; }

@keyframes ui-fade  { from { opacity: 0; } }
@keyframes ui-pop   { from { opacity: 0; transform: scale(.96) translateY(6px); } }
@keyframes ui-slide { from { opacity: 0; transform: translateY(10px); } }
