/* ====== نظام إدارة الأصول التقنية - الواجهة ====== */
:root {
    --ink: #0f1b2d;
    --ink-2: #16263d;
    --accent: #0e9f8e;
    --accent-soft: #e3f6f3;
    --bg: #f4f6f9;
    --line: #e4e8ee;
    --muted: #6b7a90;
    --sidebar-w: 262px;
    --radius: 14px;
    --bs-primary: #0e9f8e;
    --bs-primary-rgb: 14, 159, 142;
    --bs-link-color: #0b8577;
    --bs-link-color-rgb: 11, 133, 119;
    --bs-body-font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
}

body { background: var(--bg); color: var(--ink); font-size: .935rem; }
a { text-decoration: none; }

.btn-primary { --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: #0b8577; --bs-btn-hover-border-color: #0b8577; --bs-btn-active-bg: #0a7569; --bs-btn-disabled-bg: var(--accent); --bs-btn-disabled-border-color: var(--accent); }
.btn-outline-primary { --bs-btn-color: var(--accent); --bs-btn-border-color: var(--accent); --bs-btn-hover-bg: var(--accent); --bs-btn-hover-border-color: var(--accent); --bs-btn-active-bg: var(--accent); }
.text-primary { color: var(--accent) !important; }
.bg-primary { background-color: var(--accent) !important; }
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }
.form-control:focus, .form-select:focus { border-color: #7fd3c8; box-shadow: 0 0 0 .2rem rgba(14,159,142,.15); }
.pagination { --bs-pagination-active-bg: var(--accent); --bs-pagination-active-border-color: var(--accent); --bs-pagination-color: var(--ink); }

/* ----- الشريط الجانبي ----- */
.sidebar {
    position: fixed; inset: 0 0 0 auto; width: var(--sidebar-w);
    background: var(--ink); color: #c4cfdd; display: flex; flex-direction: column; z-index: 1040;
    transition: transform .25s ease;
}
.brand { display: flex; align-items: center; gap: .75rem; padding: 1.15rem 1.25rem; color: #fff; border-bottom: 1px solid rgba(255,255,255,.06); }
.brand img { width: 42px; height: 42px; object-fit: contain; background: #fff; border-radius: 10px; padding: 4px; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 11px; background: var(--accent); font-size: 1.3rem; }
.brand strong { display: block; font-size: .98rem; line-height: 1.3; }
.brand small { color: #8a9bb3; font-size: .75rem; }
.side-nav { padding: .75rem .75rem 2rem; overflow-y: auto; flex: 1; }
.side-nav .nav-section { font-size: .72rem; color: #6f819b; padding: 1.1rem .75rem .4rem; letter-spacing: .02em; }
.side-nav a { display: flex; align-items: center; gap: .75rem; padding: .58rem .8rem; border-radius: 10px; color: #c4cfdd; margin-bottom: 2px; font-size: .9rem; }
.side-nav a i { font-size: 1.08rem; opacity: .85; }
.side-nav a:hover { background: var(--ink-2); color: #fff; }
.side-nav a.active { background: rgba(14,159,142,.16); color: #5fe0cf; font-weight: 600; box-shadow: inset -3px 0 0 var(--accent); }

.main { margin-right: var(--sidebar-w); min-height: 100vh; }
.topbar { position: sticky; top: 0; z-index: 1020; display: flex; align-items: center; gap: 1rem; padding: .7rem 1.75rem; background: rgba(255,255,255,.9); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); }
.global-search { position: relative; flex: 0 1 440px; }
.global-search i { position: absolute; right: .9rem; top: 50%; transform: translateY(-50%); color: var(--muted); }
.global-search input { width: 100%; border: 1px solid var(--line); background: var(--bg); border-radius: 10px; padding: .5rem 2.4rem .5rem 2.4rem; outline: none; }
.global-search input:focus { background: #fff; border-color: #7fd3c8; }
.global-search kbd { position: absolute; left: .6rem; top: 50%; transform: translateY(-50%); background: #fff; color: var(--muted); border: 1px solid var(--line); font-size: .7rem; padding: .05rem .4rem; }
.user-chip { display: flex; align-items: center; gap: .55rem; border: 0; padding: .25rem .4rem; border-radius: 10px; }
.user-chip:hover { background: var(--bg); }
.avatar { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.btn-icon { border: 0; padding: .25rem .4rem; }

.content { padding: 1.5rem 1.75rem 3rem; }
.page-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.page-head h1 { font-size: 1.45rem; font-weight: 700; margin: 0; }
.page-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.crumbs { font-size: .8rem; color: var(--muted); margin-bottom: .2rem; }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--accent); }

/* ----- البطاقات ----- */
.card { border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 1px 2px rgba(15,27,45,.03); }
.card-header { background: transparent; border-bottom: 1px solid var(--line); padding: .9rem 1.15rem; font-weight: 600; display: flex; align-items: center; justify-content: space-between; gap: .5rem; }
.card-body { padding: 1.15rem; }

.stat { padding: 1.1rem 1.2rem; display: flex; gap: .95rem; align-items: center; height: 100%; }
.stat-icon { width: 48px; height: 48px; border-radius: 12px; display: grid; place-items: center; font-size: 1.35rem; flex-shrink: 0; }
.stat .num { font-size: 1.55rem; font-weight: 700; line-height: 1.1; }
.stat .lbl { color: var(--muted); font-size: .82rem; }
.tone-teal { background: #e3f6f3; color: #0b8577; }
.tone-blue { background: #e6effd; color: #2563eb; }
.tone-amber { background: #fef3dc; color: #b26b00; }
.tone-violet { background: #efeafd; color: #6d42d8; }
.tone-rose { background: #fde8ec; color: #c22a4a; }
.tone-slate { background: #edf0f4; color: #475569; }

/* ----- الجداول ----- */
.table { --bs-table-bg: transparent; margin: 0; }
.table > thead th { background: #f8fafc; color: var(--muted); font-weight: 600; font-size: .8rem; border-bottom: 1px solid var(--line); white-space: nowrap; padding: .7rem .85rem; }
.table > tbody td { white-space: nowrap; padding: .7rem .85rem; vertical-align: middle; border-color: #eef1f5; }
.table-hover > tbody > tr:hover > * { --bs-table-bg-state: #f6faf9; }
.tag { font-family: ui-monospace, 'Cascadia Mono', Consolas, monospace; font-size: .82rem; font-weight: 600; color: var(--ink); background: #eef2f6; padding: .12rem .45rem; border-radius: 6px; direction: ltr; display: inline-block; white-space: nowrap; }
.mono { font-family: ui-monospace, Consolas, monospace; direction: ltr; display: inline-block; font-size: .85rem; }
td.mono { display: table-cell; direction: rtl; }
dd.mono { display: block; direction: rtl; }
.badge { font-weight: 500; padding: .38em .7em; border-radius: 7px; }
.badge-soft-success { background: #dcf5ea; color: #137a4b; }
.badge-soft-primary { background: #e3f6f3; color: #0b7a6d; }
.badge-soft-warning { background: #fef1d6; color: #9a5b00; }
.badge-soft-danger { background: #fde4e8; color: #b4233f; }
.badge-soft-info { background: #e0f0fe; color: #1d6fb8; }
.badge-soft-secondary { background: #eceff3; color: #556173; }
.badge-soft-dark { background: #dfe3e8; color: #1f2937; }
.cat-ico { width: 34px; height: 34px; border-radius: 9px; background: #eef2f6; display: inline-grid; place-items: center; color: #475569; font-size: 1rem; flex-shrink: 0; }

.filter-bar { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: .85rem; margin-bottom: 1rem; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); }
.empty i { font-size: 2.6rem; opacity: .4; display: block; margin-bottom: .5rem; }

.bulk-bar { position: sticky; bottom: 1rem; z-index: 10; background: var(--ink); color: #fff; border-radius: 12px; padding: .65rem 1rem; display: none; align-items: center; gap: .75rem; box-shadow: 0 10px 30px rgba(15,27,45,.25); margin-top: 1rem; flex-wrap: wrap; }
.bulk-bar.show { display: flex; }

.dl-grid { display: grid; grid-template-columns: 140px 1fr; row-gap: .6rem; column-gap: 1rem; margin: 0; }
.dl-grid dt { color: var(--muted); font-weight: 500; font-size: .85rem; }
.dl-grid dd { margin: 0; }

.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline li { position: relative; padding: 0 2rem 1.2rem 0; }
.timeline li::before { content: ''; position: absolute; right: 9px; top: 22px; bottom: 0; width: 2px; background: var(--line); }
.timeline li:last-child::before { display: none; }
.timeline .dot { position: absolute; right: 0; top: 2px; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; font-size: .65rem; color: #fff; }

.form-label { font-weight: 500; font-size: .86rem; margin-bottom: .3rem; }
.form-section-title { font-size: .95rem; font-weight: 600; margin-bottom: 1rem; display: flex; align-items: center; gap: .5rem; }
.form-section-title i { color: var(--accent); }
.required::after { content: ' *'; color: #dc3545; }

.type-switch { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .6rem; }
.type-switch a { border: 1.5px solid var(--line); border-radius: 12px; padding: .8rem; background: #fff; color: var(--ink); display: flex; align-items: center; gap: .6rem; font-weight: 500; }
.type-switch a.active { border-color: var(--accent); background: var(--accent-soft); color: #0b7a6d; }
.type-switch a i { font-size: 1.25rem; }

.picker-results { max-height: 340px; overflow-y: auto; }
.picker-item { display: flex; align-items: center; gap: .7rem; padding: .55rem .75rem; border-bottom: 1px solid #f0f2f5; cursor: pointer; }
.picker-item:hover { background: #f6faf9; }
.picker-item.selected { background: var(--accent-soft); }

.perm-group { border: 1px solid var(--line); border-radius: 12px; padding: .9rem 1rem; height: 100%; }
.perm-group h6 { font-size: .9rem; font-weight: 600; display: flex; justify-content: space-between; }

.confirm-icon { width: 56px; height: 56px; border-radius: 50%; background: #fde8ec; color: #c22a4a; display: grid; place-items: center; font-size: 1.5rem; margin: 0 auto; }

.ts-control { border-radius: var(--bs-border-radius); }
.ts-wrapper.single .ts-control { background-image: none; }

/* ----- الجوال ----- */
.sidebar-backdrop { display: none; }
@media (max-width: 991.98px) {
    .sidebar { transform: translateX(100%); }
    .main { margin-right: 0; }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop { display: block; position: fixed; inset: 0; background: rgba(0,0,0,.35); z-index: 1030; }
    .content { padding: 1rem; }
    .topbar { padding: .6rem 1rem; }
    .dl-grid { grid-template-columns: 110px 1fr; }
}

@media print {
    .sidebar, .topbar, .page-actions, .filter-bar, .no-print, .bulk-bar, .pagination { display: none !important; }
    .main { margin: 0; }
    .content { padding: 0; }
    .card { border: 0; box-shadow: none; }
    body { background: #fff; }
}
