/* ============================================================
   ديكور لاب - نظام الإدارة المتكامل
   ورقة الأنماط الرئيسية | RTL | خط Cairo محلي
   ============================================================ */
@font-face {
  font-family: 'Cairo';
  src: url('../fonts/Cairo-Regular.ttf') format('truetype');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Cairo';
  src: url('../fonts/Cairo-SemiBold.ttf') format('truetype');
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'Cairo';
  src: url('../fonts/Cairo-Bold.ttf') format('truetype');
  font-weight: 700; font-style: normal; font-display: swap;
}

:root {
  --charcoal: #2b2620;
  --charcoal-2: #3a332b;
  --ink: #241f19;
  --beige: #d9cbb3;
  --beige-light: #efe7d8;
  --cream: #faf6ee;
  --gold: #b08d3e;
  --gold-soft: #c9a961;
  --gold-pale: #e8dcc0;
  --white: #ffffff;
  --text: #2b2620;
  --muted: #7a7061;
  --line: #e5dcc9;
  --ok: #3e7a4e;
  --warn: #b07f28;
  --danger: #a8442f;
  --info: #6b6f3f;
  --radius: 10px;
  --shadow: 0 2px 10px rgba(43, 38, 32, .08);
  --sidebar-w: 268px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { direction: rtl; }
body {
  font-family: 'Cairo', 'Segoe UI', Tahoma, sans-serif;
  background: var(--cream);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.7;
  min-height: 100vh;
}
a { color: var(--gold); text-decoration: none; }
a:hover { color: var(--charcoal); }

/* ============================================================
   الشعار - قواعد صارمة:
   1) حجم ثابت صغير داخل رأس الصفحة فقط.
   2) ممنوع استخدام الشعار كخلفية (background) في أي صفحة.
   3) الحفاظ على النسب: height ثابت + width تلقائي + object-fit: contain.
   4) لا تكرار ولا حجب للمحتوى.
   ============================================================ */
.brand-logo {
  height: 44px;               /* حجم ثابت مناسب داخل الشريط العلوي */
  width: auto;                /* العرض يتبع النسبة الأصلية */
  max-width: 200px;
  object-fit: contain;        /* منع التمديد أو التشويه */
  display: block;
  flex: 0 0 auto;
  border-radius: 6px;
  background: transparent;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand .brand-name {
  font-size: 17px; font-weight: 700; color: var(--charcoal); line-height: 1.3;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.brand .brand-sub { font-size: 11.5px; color: var(--muted); line-height: 1.2; }

/* شعار صفحة الدخول: عنصر صغير أنيق أعلى البطاقة وليس خلفية */
.login-logo { width: 190px; height: auto; max-height: 88px; object-fit: contain; display: block; margin: 0 auto 10px; }

/* شعار داخل الطباعة وPDF عبر صورة <img> بأبعاد ثابتة صغيرة */
.print-logo { height: 34px; width: auto; max-width: 150px; object-fit: contain; }

/* ============================================================
   الشريط العلوي
   ============================================================ */
.topbar {
  position: fixed; top: 0; right: 0; left: 0; z-index: 60;
  height: 64px;
  background: var(--white);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 18px;
  padding: 0 20px;
  box-shadow: var(--shadow);
}
.topbar .spacer { flex: 1; }
.topbar .top-user { display: flex; align-items: center; gap: 10px; }
.topbar .top-user .who { text-align: left; line-height: 1.3; }
.topbar .top-user .who b { font-size: 13.5px; color: var(--charcoal); display: block; }
.topbar .top-user .who span { font-size: 11.5px; color: var(--muted); }
.avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--charcoal); color: var(--gold-pale);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex: 0 0 auto;
}
.btn-logout {
  border: 1px solid var(--line); background: var(--beige-light);
  color: var(--charcoal); border-radius: 8px; padding: 7px 14px;
  font-family: inherit; font-size: 13px; cursor: pointer;
}
.btn-logout:hover { background: var(--gold-pale); }
.alerts-badge {
  position: relative; border: 1px solid var(--line); background: var(--white);
  border-radius: 8px; padding: 6px 12px; font-size: 13px; color: var(--charcoal);
}
.alerts-badge b { background: var(--danger); color: #fff; border-radius: 10px; padding: 0 8px; font-size: 12px; margin-inline-start: 6px; }

/* ============================================================
   القائمة الجانبية - يمين الصفحة
   ============================================================ */
.sidebar {
  position: fixed; top: 64px; right: 0; bottom: 0; width: var(--sidebar-w);
  background: var(--charcoal); color: var(--beige);
  overflow-y: auto; z-index: 50; padding: 10px 0 30px;
  scrollbar-width: thin; scrollbar-color: var(--gold) var(--charcoal-2);
}
.sidebar::-webkit-scrollbar { width: 8px; }
.sidebar::-webkit-scrollbar-thumb { background: var(--gold); border-radius: 4px; }
.nav-group { border-bottom: 1px solid rgba(217, 203, 179, .08); }
.nav-group > button {
  width: 100%; text-align: right; background: none; border: none; cursor: pointer;
  color: var(--beige); font-family: inherit; font-size: 14px; font-weight: 600;
  padding: 11px 18px; display: flex; justify-content: space-between; align-items: center;
}
.nav-group > button:hover { color: var(--gold-soft); }
.nav-group > button .arrow { font-size: 11px; color: var(--gold-soft); }
.nav-group > button .arrow.open { transform: rotate(180deg); }
.nav-group .nav-links { display: none; padding: 2px 0 8px; }
.nav-group .nav-links.open { display: block; }
.nav-group .nav-links a {
  display: block; color: var(--beige); font-size: 13.5px; padding: 7px 28px;
  border-right: 3px solid transparent;
}
.nav-group .nav-links a:hover { color: var(--gold-soft); border-right-color: var(--gold); background: rgba(255,255,255,.03); }
.nav-group .nav-links a.active {
  color: var(--gold-soft); border-right-color: var(--gold);
  background: linear-gradient(to left, rgba(176,141,62,.18), transparent);
}
.sidebar .side-title {
  padding: 12px 18px 6px; font-size: 11px; letter-spacing: .5px; color: rgba(217,203,179,.55);
}

/* المحتوى */
.main {
  margin-top: 64px; margin-right: var(--sidebar-w);
  padding: 24px 26px 60px; min-height: calc(100vh - 64px);
}
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; flex-wrap: wrap; }
.page-head h1 { font-size: 21px; color: var(--charcoal); font-weight: 700; }
.page-head .crumb { font-size: 12px; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ============================================================
   البطاقات والجداول والنماذج
   ============================================================ */
.card { background: var(--white); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; }
.card .card-head { padding: 13px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.card .card-head h2 { font-size: 15.5px; color: var(--charcoal); }
.card .card-body { padding: 18px; }
.card .card-body.p0 { padding: 0; }

.table-wrap { overflow-x: auto; }
table.tbl { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.tbl th {
  background: var(--beige-light); color: var(--charcoal); font-weight: 700;
  padding: 10px 12px; text-align: right; border-bottom: 2px solid var(--gold-pale); white-space: nowrap;
}
table.tbl td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.tbl tr:hover td { background: #fdfaf3; }
table.tbl .num { text-align: left; font-variant-numeric: tabular-nums; direction: ltr; display: inline-block; }
table.tbl tfoot td { background: var(--cream); font-weight: 700; border-top: 2px solid var(--gold-pale); }
.badge { display: inline-block; padding: 2px 10px; border-radius: 20px; font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.b-gray  { background: #eee9df; color: #6b6357; }
.b-yellow{ background: #f6ecd2; color: #8a6d1f; }
.b-amber { background: #fbe9d0; color: #96581c; }
.b-green { background: #ddecdd; color: #2f6b3c; }
.b-lgreen{ background: #e8f2e4; color: #487a3a; }
.b-red   { background: #f6ddd6; color: #963a26; }
.b-dark  { background: #e2ddd3; color: #3a332b; }

.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.field label { display: block; font-size: 12.5px; font-weight: 600; color: var(--charcoal); margin-bottom: 5px; }
.field .req::after { content: ' *'; color: var(--danger); }
input[type=text], input[type=number], input[type=date], input[type=email], input[type=password], input[type=tel], select, textarea {
  width: 100%; padding: 8px 11px; border: 1px solid var(--line); border-radius: 8px;
  font-family: inherit; font-size: 13.5px; background: var(--white); color: var(--text);
}
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--gold); box-shadow: 0 0 0 3px rgba(176,141,62,.13); }
textarea { min-height: 84px; resize: vertical; }
fieldset { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 14px; }
legend { font-size: 13px; font-weight: 700; color: var(--gold); padding: 0 8px; }

.btn {
  display: inline-block; border: none; cursor: pointer; font-family: inherit;
  background: var(--charcoal); color: var(--gold-pale); padding: 9px 20px;
  border-radius: 8px; font-size: 13.5px; font-weight: 600; text-align: center;
}
.btn:hover { background: var(--charcoal-2); color: var(--gold-soft); }
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: #96762f; color: #fff; }
.btn-line { background: var(--white); color: var(--charcoal); border: 1px solid var(--line); }
.btn-line:hover { background: var(--beige-light); color: var(--charcoal); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #8d3826; color: #fff; }
.btn-sm { padding: 5px 12px; font-size: 12.5px; border-radius: 6px; }

.msg { border-radius: 8px; padding: 11px 15px; margin-bottom: 16px; font-size: 13.5px; border: 1px solid; }
.msg-ok { background: #e8f2e4; color: #2f6b3c; border-color: #bcd8bf; }
.msg-err { background: #f9e3dc; color: #963a26; border-color: #e8c0b4; }
.msg-warn { background: #faf0d8; color: #7d621b; border-color: #e5d3a1; }

/* بطاقات الإحصاء */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(215px, 1fr)); gap: 14px; margin-bottom: 20px; }
.stat {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 15px 17px; box-shadow: var(--shadow); border-right: 4px solid var(--gold);
}
.stat .v { font-size: 21px; font-weight: 700; color: var(--charcoal); line-height: 1.4; }
.stat .l { font-size: 12.5px; color: var(--muted); }
.stat a { font-size: 11.5px; }

/* دائرة الإنجاز */
.prog-wrap { display: flex; align-items: center; gap: 10px; }
.prog-ring { --p: 0; width: 46px; height: 46px; border-radius: 50%;
  background: conic-gradient(var(--ring-c, var(--gold)) calc(var(--p)*1%), var(--beige-light) 0);
  display: flex; align-items: center; justify-content: center; flex: 0 0 auto; }
.prog-ring::before { content: attr(data-p) '%'; width: 34px; height: 34px; border-radius: 50%;
  background: var(--white); display: flex; align-items: center; justify-content: center;
  font-size: 10.5px; font-weight: 700; color: var(--charcoal); }
.prog-bar { height: 8px; background: var(--beige-light); border-radius: 6px; overflow: hidden; min-width: 90px; }
.prog-bar i { display: block; height: 100%; background: var(--ring-c, var(--gold)); border-radius: 6px; }

/* تبويبات */
.tabs { display: flex; gap: 4px; border-bottom: 2px solid var(--line); margin-bottom: 16px; flex-wrap: wrap; }
.tabs a { padding: 8px 16px; font-size: 13.5px; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a.active { color: var(--charcoal); font-weight: 700; border-bottom-color: var(--gold); }

/* تنبيهات مدمجة */
.alert-row { display: flex; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--line); align-items: flex-start; }
.alert-row:last-child { border-bottom: none; }
.alert-row .dot { width: 10px; height: 10px; border-radius: 50%; margin-top: 7px; flex: 0 0 auto; }
.sev-high { background: var(--danger); } .sev-med { background: var(--warn); } .sev-low { background: var(--info); }

/* تسجيل الدخول */
.login-page { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
  background: linear-gradient(135deg, var(--charcoal) 0%, var(--charcoal-2) 55%, #4a4033 100%); }
.login-card { background: var(--white); border-radius: 14px; box-shadow: 0 18px 50px rgba(0,0,0,.35);
  width: 100%; max-width: 420px; padding: 34px 32px; }
.login-card h1 { font-size: 19px; text-align: center; color: var(--charcoal); margin-bottom: 4px; }
.login-card .sub { text-align: center; color: var(--muted); font-size: 12.5px; margin-bottom: 22px; }
.login-note { background: var(--beige-light); border-radius: 8px; padding: 8px 12px; font-size: 12px; color: var(--muted); margin-top: 16px; text-align: center; }

/* ============================================================
   التجاوب: الكمبيوتر المكتبي / الأجهزة اللوحية / الجوال
   ============================================================ */
.menu-toggle { display: none; }
@media (max-width: 1024px) {
  /* لوحي: شعار أصغر قليلا */
  .brand-logo { height: 38px; max-width: 170px; }
  .main { padding: 18px 16px 50px; }
}
@media (max-width: 768px) {
  .menu-toggle {
    display: inline-block; border: 1px solid var(--line); background: var(--white);
    border-radius: 8px; padding: 7px 13px; font-family: inherit; font-size: 14px; cursor: pointer; color: var(--charcoal);
  }
  .sidebar { transform: translateX(100%); transition: transform .25s ease; width: 280px; }
  .sidebar.open { transform: translateX(0); box-shadow: -6px 0 24px rgba(0,0,0,.25); }
  .main { margin-right: 0; }
  .brand-logo { height: 34px; max-width: 150px; }   /* جوال: أصغر لتبقى داخل الشريط */
  .brand .brand-sub { display: none; }
  .brand .brand-name { font-size: 15px; }
  .topbar { padding: 0 12px; gap: 8px; height: 58px; overflow: hidden; }
  .topbar .top-user .who { display: none; }   /* الاسم يختفي على الجوال، تبقى الصورة الرمزية */
  .alerts-badge { padding: 5px 9px; font-size: 12px; }
  .btn-logout { padding: 6px 10px; font-size: 12px; }
  .avatar { width: 34px; height: 34px; font-size: 12.5px; }
  .sidebar { top: 58px; }
  .main { margin-top: 58px; }
  .page-head h1 { font-size: 18px; }
  table.tbl { font-size: 12.5px; }
  .login-logo { width: 150px; }
}
@media (max-width: 380px) {
  .brand-logo { height: 30px; max-width: 128px; }
}

/* ============================================================
   الطباعة: A4 + إخفاء عناصر النظام + تكرار رؤوس الجداول
   ============================================================ */
.print-header { display: none; }
.print-footer { display: none; }
@media print {
  @page { size: A4 portrait; margin: 12mm 10mm; }
  .sidebar, .topbar, .menu-toggle, .actions, .btn, .no-print,
  .form-grid, .filters, .msg, nav, aside { display: none !important; }
  body { background: #fff; font-size: 12px; }
  .main { margin: 0 !important; padding: 0 !important; }
  .card { box-shadow: none; border: 1px solid #bbb; }
  .print-header {
    display: flex !important; align-items: center; gap: 14px;
    border-bottom: 2.5px solid var(--charcoal); padding-bottom: 8px; margin-bottom: 14px;
  }
  .print-header img.print-logo { height: 34px; width: auto; object-fit: contain; }
  .print-header .ph-title { font-size: 17px; font-weight: 700; color: #000; }
  .print-header .ph-meta { font-size: 11px; color: #333; }
  table.tbl { font-size: 11px; }
  table.tbl th { background: #efe7d8 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  thead { display: table-header-group; }   /* تكرار رأس الجدول في كل صفحة */
  tr { page-break-inside: avoid; }          /* منع تقطيع الصفوف */
  tfoot { display: table-footer-group; }
  .print-footer { display: flex !important; position: fixed; bottom: 0; left: 0; right: 0;
    font-size: 10px; color: #444; border-top: 1px solid #999; padding-top: 4px;
    justify-content: space-between; background: #fff; }
}
