/* =====================================================================
   منظومة سجل الأفراد — قوة مكافحة الإرهاب
   تصميم عربي RTL منظّم
   ===================================================================== */
/* خط Cairo محمّل محلياً داخل المنظومة (لا يحتاج إنترنت) */
@font-face {
    font-family: 'Cairo';
    src: url('fonts/Cairo-Regular.woff') format('woff');
    font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Cairo';
    src: url('fonts/Cairo-Medium.woff') format('woff');
    font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
    font-family: 'Cairo';
    src: url('fonts/Cairo-Bold.woff') format('woff');
    font-weight: 700; font-style: normal; font-display: swap;
}

:root {
    --primary:      #4a5626;   /* أخضر زيتي */
    --primary-dark: #2e3617;
    --primary-light:#66753a;
    --accent:       #c9a227;   /* ذهبي فخم */
    --bg:           #f4f6f8;
    --panel:        #ffffff;
    --border:       #dfe4ea;
    --text:         #1f2933;
    --muted:        #6b7684;
    --danger:       #c0392b;
    --ok:           #1e7e46;
    --radius:       10px;
    --shadow:       0 1px 3px rgba(0,0,0,.08), 0 4px 12px rgba(0,0,0,.04);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Cairo', 'Segoe UI', Tahoma, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    font-size: 15px;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }
.muted { color: var(--muted); }

/* ============ الأزرار ============ */
.btn {
    display: inline-block;
    padding: 9px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius);
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: .15s;
    text-align: center;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); text-decoration: none; }
.btn-ghost { background: #fff; color: var(--text); border-color: var(--border); }
.btn-ghost:hover { background: #f0f2f5; text-decoration: none; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #a53125; text-decoration: none; }
.btn-block { width: 100%; }

/* ============ شريط علوي ============ */
.topbar {
    background: linear-gradient(135deg, #07080a 0%, #1c2110 45%, #3d4a20 100%);
    color: #fff;
    box-shadow: 0 2px 14px rgba(0,0,0,.35);
    border-bottom: 3px solid var(--accent);
}
.topbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    align-items: center;
    gap: 20px;
    min-height: 80px;
    flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 19px; }
.brand-badge { font-size: 22px; }
.brand-logo { height: 64px; width: 64px; object-fit: contain; background: #fff;
    border-radius: 12px; padding: 4px; box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.mainnav { display: flex; gap: 4px; margin-inline-start: auto; flex-wrap: wrap; }
.mainnav a {
    color: #e8f0ec;
    padding: 8px 14px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
}
.mainnav a:hover { background: rgba(255,255,255,.12); text-decoration: none; }
.mainnav a.active { background: rgba(255,255,255,.2); color: #fff; }
.userbox { display: flex; align-items: center; gap: 10px; }
.user-name { font-weight: 600; }
.user-role {
    font-size: 12px; background: var(--accent); color: #fff;
    padding: 2px 9px; border-radius: 20px;
}
.btn-logout {
    background: rgba(255,255,255,.15); color: #fff;
    padding: 6px 12px; border-radius: 8px; font-size: 13px; font-weight: 600;
}
.btn-logout:hover { background: rgba(255,255,255,.28); text-decoration: none; }

/* ============ الحاوية ============ */
.container { max-width: 1200px; margin: 0 auto; padding: 26px 20px 60px; }
.page-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 14px; margin-bottom: 22px; flex-wrap: wrap;
}
.page-head h1 { margin: 0; font-size: 23px; }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.count-pill {
    background: var(--primary); color: #fff; font-size: 14px;
    padding: 1px 12px; border-radius: 20px; vertical-align: middle;
}

/* ============ بطاقات الإحصاء ============ */
.stats-grid {
    display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
    gap: 16px; margin-bottom: 26px;
}
.stat-card {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
    border-inline-start: 4px solid var(--primary);
}
.stat-num { font-size: 30px; font-weight: 700; color: var(--primary); }
.stat-lbl { color: var(--muted); font-size: 14px; margin-top: 4px; }

.cols-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
@media (max-width: 800px){ .cols-2 { grid-template-columns: 1fr; } }

.panel {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow);
}
.panel-title { margin: 0 0 16px; font-size: 17px; border-bottom: 2px solid var(--border); padding-bottom: 10px; }

/* أشرطة التوزيع */
.bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 14px; }
.bar-lbl { width: 130px; flex-shrink: 0; }
.bar-track { flex: 1; background: #eef1f4; border-radius: 20px; height: 12px; overflow: hidden; }
.bar-fill { display: block; height: 100%; background: linear-gradient(90deg, var(--primary), var(--primary-light)); }
.bar-val { width: 34px; text-align: left; font-weight: 600; color: var(--muted); }

.mini-table { width: 100%; border-collapse: collapse; }
.mini-table th { text-align: right; font-size: 13px; color: var(--muted); padding: 6px 8px; border-bottom: 2px solid var(--border); }
.mini-table td { padding: 8px; border-bottom: 1px solid #eef1f4; font-size: 14px; }
.link-sm { font-size: 13px; font-weight: 600; }

/* ============ شريط البحث ============ */
.search-bar {
    display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 20px;
    background: var(--panel); padding: 14px; border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow);
}
.search-input { flex: 1; min-width: 240px; }
.search-bar select { min-width: 150px; }

/* ============ الحقول ============ */
input[type=text], input[type=password], input[type=email], input[type=date],
input[type=number], select, textarea {
    width: 100%; padding: 9px 11px; border: 1px solid var(--border);
    border-radius: 8px; font-family: inherit; font-size: 14px; background: #fff;
    color: var(--text); transition: .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none; border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(74,86,38,.16);
}
textarea { resize: vertical; }

/* ============ الجداول ============ */
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table thead th {
    background: var(--primary); color: #fff; text-align: right;
    padding: 12px 14px; font-weight: 600; white-space: nowrap;
}
.data-table tbody td { padding: 11px 14px; border-bottom: 1px solid #eef1f4; }
.data-table tbody tr:hover { background: #f6f7f0; }
.cell-strong { font-weight: 600; }
.cell-actions { white-space: nowrap; }
.cell-actions a { margin-inline-end: 10px; }

.empty-state { text-align: center; padding: 50px 20px; color: var(--muted); background: var(--panel); border: 1px dashed var(--border); border-radius: var(--radius); }

/* ترقيم الصفحات */
.pagination { display: flex; gap: 6px; justify-content: center; margin-top: 20px; flex-wrap: wrap; }
.pagination a {
    padding: 7px 13px; border: 1px solid var(--border); border-radius: 8px;
    background: #fff; font-weight: 600; font-size: 14px;
}
.pagination a:hover { background: #f0f2f5; text-decoration: none; }
.pagination a.active { background: var(--primary); color: #fff; border-color: var(--primary); }

/* ============ نموذج الإدخال ============ */
.person-form { display: flex; flex-direction: column; gap: 18px; }
.form-section {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 8px 20px 20px; box-shadow: var(--shadow);
}
.form-section legend {
    font-weight: 700; color: var(--primary); font-size: 16px;
    padding: 4px 12px; background: #eef0e2; border-radius: 8px;
}
.form-grid {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 14px; margin-top: 10px;
}
.field { display: flex; flex-direction: column; gap: 5px; }
.field-wide { grid-column: 1 / -1; }
.field label { font-size: 13px; font-weight: 600; color: #45505c; }
.req { color: var(--danger); }
.form-actions { display: flex; gap: 10px; padding: 4px 0 10px; }

.narrow-form { max-width: 480px; display: flex; flex-direction: column; gap: 14px;
    background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 24px; box-shadow: var(--shadow); }
.narrow-form label { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; }
.check-label { flex-direction: row !important; align-items: center; gap: 8px !important; }
.check-label input { width: auto; }

/* ============ ملف الفرد (العرض) ============ */
.profile-sheet {
    background: var(--panel); border: 1px solid var(--border);
    border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden;
}
.profile-header {
    display: flex; align-items: center; gap: 16px;
    background: linear-gradient(135deg, #07080a 0%, #1c2110 45%, #3d4a20 100%);
    color: #fff; padding: 22px 26px; border-bottom: 3px solid var(--accent);
}
.profile-badge {
    width: 60px; height: 60px; background: rgba(255,255,255,.15);
    border-radius: 12px; display: flex; align-items: center; justify-content: center;
    font-size: 30px;
}
.profile-badge-img {
    width: 66px; height: 66px; object-fit: contain; background: #fff;
    border-radius: 12px; padding: 4px;
}
.profile-org { font-size: 13px; opacity: .85; }
.profile-name { margin: 2px 0; font-size: 24px; }
.profile-sub { font-size: 14px; opacity: .9; }
.profile-section { padding: 8px 26px 20px; }
.profile-section h3 {
    color: var(--primary); font-size: 16px; border-bottom: 2px solid var(--border);
    padding-bottom: 8px; margin: 18px 0 14px;
}
.profile-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px 20px; }
.pf-row { display: flex; gap: 8px; padding: 7px 0; border-bottom: 1px dashed #eef1f4; font-size: 14px; }
.pf-wide { grid-column: 1 / -1; }
.pf-label { color: var(--muted); min-width: 130px; font-weight: 600; }
.pf-value { color: var(--text); }
.profile-foot { padding: 16px 26px; background: #f6f7f0; color: var(--muted); font-size: 13px; border-top: 1px solid var(--border); }

/* ============ وسوم الأدوار والحالة ============ */
.role-tag { font-size: 12px; padding: 3px 10px; border-radius: 20px; font-weight: 600; color: #fff; }
.role-admin { background: var(--accent); }
.role-data_entry { background: var(--primary); }
.role-viewer { background: #5b6b7b; }
.role-group { background: var(--primary); }
.status-on { color: var(--ok); font-weight: 600; }
.status-off { color: var(--danger); font-weight: 600; }

/* ============ المجموعات وسجل الحركات ============ */
.perm-yes { color: var(--ok); font-weight: 700; font-size: 16px; }
.perm-no { color: #c3cad3; }
.scope-full { font-size: 12px; padding: 3px 10px; border-radius: 20px; font-weight: 600;
    background: #e7f6ee; color: var(--ok); }
.scope-basic { font-size: 12px; padding: 3px 10px; border-radius: 20px; font-weight: 600;
    background: #fdf3d7; color: #8a6d0b; }
.perm-box { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 16px; }
.perm-box legend { font-weight: 700; font-size: 14px; color: var(--primary); padding: 0 8px; }
.perm-box .check-label { margin-bottom: 8px; }
.act-tag { font-size: 12px; padding: 2px 9px; border-radius: 14px; font-weight: 600;
    background: #eef1f4; color: #45505c; white-space: nowrap; }
.act-add_person { background: #e7f6ee; color: var(--ok); }
.act-edit_person { background: #fdf3d7; color: #8a6d0b; }
.act-delete_person { background: #fdecea; color: var(--danger); }
.act-login { background: #e8f0fb; color: #1f5aa8; }
.act-export { background: #efe9f7; color: #6b3fa0; }

/* ============ التنبيهات ============ */
.alert { padding: 12px 16px; border-radius: 8px; margin-bottom: 14px; font-size: 14px; font-weight: 600; }
.alert-error { background: #fdecea; color: #a53125; border: 1px solid #f5c6c0; }
.alert-ok { background: #e7f6ee; color: #1e7e46; border: 1px solid #b8e6ca; }

/* ============ الفوتر ============ */
.sitefoot { text-align: center; color: var(--muted); font-size: 13px; padding: 24px; }

/* ============ صفحات الدخول/التنصيب ============ */
.auth-body { display: flex; align-items: center; justify-content: center; min-height: 100vh;
    background: linear-gradient(135deg, #060708 0%, #161a0d 40%, #333e1b 80%, #4a5626 100%); padding: 20px; }
.auth-card {
    background: #fff; border-radius: 16px; padding: 36px 32px; width: 100%;
    max-width: 400px; box-shadow: 0 20px 50px rgba(0,0,0,.3);
}
.auth-logo { text-align: center; font-size: 48px; }
.auth-logo-img { display: block; width: 210px; height: 210px; object-fit: contain; margin: 0 auto 8px; }
.auth-title { text-align: center; margin: 6px 0 2px; font-size: 30px; font-weight: 700; color: var(--primary-dark); }
.auth-card label { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; font-weight: 600; font-size: 14px; }
.auth-card form { margin-top: 18px; }
code { background: #eef1f4; padding: 1px 6px; border-radius: 5px; font-size: 13px; }

/* ============ الطباعة ============ */
@media print {
    .topbar, .sitefoot, .no-print, .head-actions { display: none !important; }
    body { background: #fff; }
    .container { padding: 0; max-width: 100%; }
    .profile-sheet { box-shadow: none; border: 1px solid #999; }
    .profile-header { background: var(--primary-dark) !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
