/* مكونات مشتركة (أزرار، خانات، جداول، شارات) */
:root {
    --brand: #059669;
    --brand-dark: #047857;
    --ink: #0b1220;
    --line: #e5e7eb;
    --muted: #64748b;
}

html, body { -webkit-font-smoothing: antialiased; }
body { font-family: "Plus Jakarta Sans", "IBM Plex Sans Arabic", system-ui, sans-serif; }
.num { font-variant-numeric: tabular-nums; }
[x-cloak], .is-hidden { display: none !important; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 8px; border: 2px solid transparent; background-clip: padding-box; }
::-webkit-scrollbar-track { background: transparent; }

/* أزرار */
.btn-primary, .btn-secondary, .btn-danger, .btn-ghost {
    display: inline-flex; align-items: center; justify-content: center; gap: .5rem;
    height: 2.5rem; padding: 0 1rem; border-radius: .625rem;
    font-size: .8125rem; font-weight: 600; line-height: 1; white-space: nowrap;
    transition: background-color .15s, border-color .15s, color .15s, box-shadow .15s;
    cursor: pointer;
}
.btn-primary { background: var(--brand); color: #fff; box-shadow: 0 1px 2px rgba(5,150,105,.25); }
.btn-primary:hover { background: var(--brand-dark); }
.btn-secondary { background: #fff; color: #334155; border: 1px solid #d0d5dd; box-shadow: 0 1px 2px rgba(16,24,40,.05); }
.btn-secondary:hover { background: #f8fafc; color: #0f172a; }
.btn-danger { background: #e11d48; color: #fff; }
.btn-danger:hover { background: #be123c; }
.btn-ghost { color: #475569; height: 2.25rem; padding: 0 .75rem; }
.btn-ghost:hover { background: #f1f5f9; color: #0f172a; }
.btn-primary:disabled, .btn-secondary:disabled, .btn-danger:disabled { opacity: .6; cursor: not-allowed; }
.btn-primary:focus-visible, .btn-secondary:focus-visible, .btn-danger:focus-visible, .btn-ghost:focus-visible, .icon-btn:focus-visible {
    outline: none; box-shadow: 0 0 0 3px rgba(16,185,129,.35);
}

.icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 2rem; height: 2rem; border-radius: .5rem; color: #64748b; transition: background-color .15s, color .15s;
}
.icon-btn:hover { background: #f1f5f9; color: #0f172a; }
.icon-btn.danger:hover { background: #fff1f2; color: #e11d48; }

/* خانات الإدخال */
.field-label { display: block; font-size: .75rem; font-weight: 600; color: #344054; margin-bottom: .375rem; }
.field-hint { font-size: .7rem; color: var(--muted); margin-top: .25rem; }
.input {
    width: 100%; height: 2.5rem; padding: 0 .75rem; border-radius: .625rem;
    background: #fff; border: 1px solid #d0d5dd; font-size: .8125rem; color: #0f172a;
    box-shadow: 0 1px 2px rgba(16,24,40,.04); transition: border-color .15s, box-shadow .15s;
}
textarea.input { height: auto; padding: .625rem .75rem; }
.input::placeholder { color: #98a2b3; }
.input:focus { outline: none; border-color: #34d399; box-shadow: 0 0 0 3px rgba(16,185,129,.18); }
.input:disabled { background: #f8fafc; color: #64748b; }
.input-icon { position: relative; }
.input-icon > i { position: absolute; left: .8rem; top: 50%; transform: translateY(-50%); color: #98a2b3; font-size: .8rem; pointer-events: none; }
.input-icon > .input { padding-left: 2.25rem; }

/* بطاقات */
.card { background: #fff; border: 1px solid #eaecf0; border-radius: 1rem; box-shadow: 0 1px 2px rgba(16,24,40,.04); }
.card-header { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 1rem 1.25rem; border-bottom: 1px solid #eaecf0; }
.card-title { font-size: .875rem; font-weight: 700; color: #0f172a; }
.card-subtitle { font-size: .75rem; color: var(--muted); margin-top: .125rem; }

/* جداول */
.table { width: 100%; border-collapse: separate; border-spacing: 0; font-size: .8125rem; }
.table thead th {
    position: sticky; top: 0; z-index: 1; background: #f9fafb; text-align: left;
    font-size: .6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: #667085;
    padding: .75rem 1rem; border-bottom: 1px solid #eaecf0; white-space: nowrap;
}
.table tbody td { padding: .75rem 1rem; border-bottom: 1px solid #f2f4f7; color: #344054; vertical-align: middle; }
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #fcfcfd; }
.table .text-right, .table th.text-right { text-align: right; }

/* شارات */
.badge { display: inline-flex; align-items: center; gap: .3rem; padding: .125rem .5rem; border-radius: 999px; font-size: .6875rem; font-weight: 600; white-space: nowrap; }
.badge::before { content: ""; width: .375rem; height: .375rem; border-radius: 999px; background: currentColor; opacity: .8; }
.badge.plain::before { display: none; }
.badge-green { background: #ecfdf3; color: #067647; }
.badge-amber { background: #fffaeb; color: #b54708; }
.badge-red { background: #fef3f2; color: #b42318; }
.badge-gray { background: #f2f4f7; color: #475467; }
.badge-blue { background: #eff8ff; color: #175cd3; }
.badge-violet { background: #f5f3ff; color: #6d28d9; }
.badge-dark { background: #0b1220; color: #fff; }

/* التنقل الجانبي */
.nav-item {
    position: relative; display: flex; align-items: center; gap: .75rem; width: 100%;
    padding: .55rem .75rem; border-radius: .625rem; font-size: .8125rem; font-weight: 500;
    color: #94a3b8; transition: background-color .15s, color .15s; text-align: left;
}
.nav-item i { width: 1rem; text-align: center; font-size: .85rem; }
.nav-item:hover { background: rgba(255,255,255,.05); color: #e2e8f0; }
.nav-item.active { background: rgba(16,185,129,.12); color: #fff; }
.nav-item.active i { color: #34d399; }
.nav-item.active::before { content: ""; position: absolute; left: -.75rem; top: .45rem; bottom: .45rem; width: 3px; border-radius: 0 3px 3px 0; background: #34d399; }
.nav-group { font-size: .625rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: #475569; padding: 1rem .75rem .4rem; }

/* مفتاح تشغيل */
.switch { position: relative; display: inline-flex; width: 2.25rem; height: 1.25rem; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #d0d5dd; border-radius: 999px; transition: .2s; cursor: pointer; }
.switch span::after { content: ""; position: absolute; top: 2px; left: 2px; width: 1rem; height: 1rem; background: #fff; border-radius: 999px; transition: .2s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--brand); }
.switch input:checked + span::after { transform: translateX(1rem); }
.switch input:disabled + span { opacity: .5; cursor: not-allowed; }
.switch input:focus-visible + span { box-shadow: 0 0 0 3px rgba(16,185,129,.35); }

/* بطاقة الصلاحيات */
.perm-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .6rem .75rem; border-radius: .625rem; }
.perm-row:hover { background: #f9fafb; }

/* طباعة بطاقة الرف */
@media print {
    body * { visibility: hidden; }
    #printableQrCard, #printableQrCard * { visibility: visible; }
    #printableQrCard { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); width: 80mm; border: 2px dashed #000; padding: 15px; }
}
