@import url('../fonts/cairo/fonts.css');

/* إشغال – نظام التصميم الموحد | ProExcel Business Systems */
:root {
  --navy: #123A63;
  --navy-dark: #0d2c4c;
  --navy-soft: #2C5A88;
  --green: #21A366;
  --green-dark: #1B7A4C;
  --red: #C62828;
  --orange: #E65100;
  --bg: #f4f6f9;
  --card: #ffffff;
  --line: #e2e6ee;
  --text: #1c2430;
  --muted: #5b6575;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(18, 58, 99, .08);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: 'Cairo', Tahoma, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14.5px;
  line-height: 1.75;
}
a { color: var(--navy); }
img { max-width: 100%; }
h1, h2, h3, h4 { margin: 0 0 10px; color: var(--navy); line-height: 1.5; }
.na { color: #8a94a6; font-size: .92em; }
.muted { color: var(--muted); }
.link { color: var(--navy); font-weight: 600; text-decoration: none; }
.link:hover { text-decoration: underline; }
.empty-cell { text-align: center; color: var(--muted); padding: 26px 10px !important; }
.empty-note { background: #fff; border: 1px dashed var(--line); border-radius: var(--radius); padding: 16px; color: var(--muted); text-align: center; }
.empty-note.big { padding: 42px; font-size: 16px; }
.note-line { font-size: 12.8px; color: var(--muted); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 10px 14px; margin: 12px 0; }
.req { color: var(--red); }

/* ------------------------- شريط الديمو ------------------------- */
.demo-banner {
  background: #FFF3E0;
  color: #7a4a00;
  border-bottom: 2px solid var(--orange);
  padding: 8px 18px;
  font-size: 13.5px;
  text-align: center;
  position: sticky;
  top: 0;
  z-index: 60;
}

/* ------------------------- الشريط العلوي ------------------------- */
.topbar {
  background: var(--navy);
  color: #fff;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 18px;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 50;
}
.topbar-brand a { color: #fff; font-size: 21px; font-weight: 800; text-decoration: none; letter-spacing: .3px; }
.env-chip { font-size: 11.5px; padding: 3px 12px; border-radius: 20px; margin-inline-start: 10px; font-weight: 700; }
.chip-admin { background: var(--green); color: #fff; }
.chip-demo { background: var(--orange); color: #fff; }
.topbar-title { font-size: 15.5px; font-weight: 600; opacity: .95; flex: 1; text-align: center; }
.topbar-side { display: flex; align-items: center; gap: 8px; }
.user-box { display: flex; align-items: center; gap: 10px; }
.user-name { font-size: 12.8px; line-height: 1.3; text-align: left; }
.user-name small { display: block; opacity: .75; }

/* زر الجوال ثلاثي الأشرطة (الاستثناء الوحيد المسموح) */
.hamburger {
  display: none;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  width: 42px;
  height: 42px;
  background: transparent;
  border: 1px solid rgba(255, 255, 255, .35);
  border-radius: 8px;
  cursor: pointer;
  padding: 9px 10px;
}
.hamburger span { display: block; height: 2.5px; width: 100%; background: #fff; border-radius: 2px; transition: .25s; }
.hamburger.open span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }

/* ------------------------- التخطيط ------------------------- */
.layout { display: flex; min-height: calc(100vh - 56px); }
.sidebar {
  width: 248px;
  background: var(--navy);
  color: #fff;
  flex-shrink: 0;
  padding: 14px 0 20px;
  position: relative;
  z-index: 40;
}
.side-nav { max-height: calc(100vh - 130px); overflow-y: auto; padding: 0 10px; }
.nav-group { margin-bottom: 4px; border-radius: 8px; }
.nav-group-btn {
  width: 100%;
  background: transparent;
  color: #dbe6f2;
  border: 0;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  text-align: start;
  padding: 10px 12px;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.nav-group-btn:hover { background: rgba(255, 255, 255, .08); color: #fff; }
.caret { border: solid #9fb6cd; border-width: 0 2px 2px 0; padding: 3.5px; transform: rotate(-45deg); transition: .2s; margin-inline-end: 4px; }
.nav-group.open .caret { transform: rotate(45deg); margin-top: -4px; }
.nav-sub { display: none; padding: 2px 8px 6px; }
.nav-group.open .nav-sub { display: block; }
.nav-link {
  display: block;
  color: #b9cadd;
  text-decoration: none;
  font-size: 13.6px;
  padding: 8px 12px;
  border-radius: 7px;
  margin: 2px 0;
}
.nav-link:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.nav-link.active { background: var(--green); color: #fff; font-weight: 700; }
.sidebar-foot { padding: 14px 16px 0; font-size: 11.5px; color: #9fb6cd; border-top: 1px solid rgba(255, 255, 255, .12); margin-top: 10px; line-height: 1.8; }
.side-overlay { display: none; }
.content { flex: 1; padding: 20px 22px 40px; min-width: 0; }

/* ------------------------- الرسائل ------------------------- */
.flash-area { margin-bottom: 14px; }
.flash { padding: 11px 16px; border-radius: 9px; margin-bottom: 9px; font-size: 14px; border: 1px solid transparent; }
.flash-ok { background: #e8f6ef; border-color: #bfe6d2; color: #186a43; }
.flash-error { background: #fdecea; border-color: #f5c6c0; color: #8f2020; }
.flash-info { background: #eef3fa; border-color: #c9d8ea; color: var(--navy); }

/* ------------------------- البطاقات والأقسام ------------------------- */
.panel { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); margin-bottom: 18px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px 0; }
.panel-head h3 { font-size: 15.5px; margin: 0; }
.panel-body { padding: 12px 18px 18px; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; }
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; }

/* ------------------------- مؤشرات KPI ------------------------- */
.kpi-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 18px; }
.kpi-grid.kpi-3 { grid-template-columns: repeat(3, 1fr); }
.kpi { background: var(--card); border: 1px solid var(--line); border-inline-start: 4px solid var(--navy-soft); border-radius: var(--radius); padding: 13px 16px; box-shadow: var(--shadow); }
.kpi-label { font-size: 12.6px; color: var(--muted); font-weight: 600; }
.kpi-value { font-size: 19px; font-weight: 800; color: var(--navy); margin-top: 3px; line-height: 1.5; word-break: break-word; }
.kpi-sub { font-size: 11.8px; color: var(--muted); margin-top: 2px; }
.kpi.tone-green { border-inline-start-color: var(--green); }
.kpi.tone-green .kpi-value { color: var(--green-dark); }
.kpi.tone-red { border-inline-start-color: var(--red); }
.kpi.tone-red .kpi-value { color: var(--red); }
.kpi.tone-orange { border-inline-start-color: var(--orange); }
.kpi.tone-orange .kpi-value { color: var(--orange); }

/* ------------------------- الجداول ------------------------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: 13.4px; }
.data-table th {
  background: #eef3f9;
  color: var(--navy);
  font-weight: 700;
  text-align: start;
  padding: 10px 12px;
  border-bottom: 2px solid #d8e2ee;
  white-space: nowrap;
}
.data-table td { padding: 9px 12px; border-bottom: 1px solid #eef1f6; vertical-align: top; }
.data-table tbody tr:hover { background: #f8fafd; }

/* ------------------------- الشارات ------------------------- */
.badge { display: inline-block; font-size: 11.8px; font-weight: 700; padding: 2.5px 11px; border-radius: 20px; white-space: nowrap; }
.badge-green { background: #e3f4eb; color: #16794c; }
.badge-red { background: #fdecea; color: #a92222; }
.badge-orange { background: #fff0e2; color: #a84c00; }
.badge-blue { background: #e8effa; color: var(--navy); }
.badge-gray { background: #edf0f5; color: #5b6575; }

/* ------------------------- الأزرار ------------------------- */
.btn {
  display: inline-block;
  background: var(--navy);
  color: #fff;
  text-decoration: none;
  border: 0;
  font-family: inherit;
  font-size: 13.8px;
  font-weight: 700;
  padding: 9px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: .15s;
  text-align: center;
}
.btn:hover { background: var(--navy-dark); }
.btn-green { background: var(--green); }
.btn-green:hover { background: var(--green-dark); }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #a02020; }
.btn-ghost { background: #fff; color: var(--navy); border: 1px solid var(--line); }
.btn-ghost:hover { background: #f2f6fb; }
.btn-sm { padding: 5.5px 13px; font-size: 12.6px; }
.btn-lg { padding: 13px 30px; font-size: 15.5px; }
.btn-block { width: 100%; display: block; }
.row-actions { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.act { font-size: 12.2px; text-decoration: none; padding: 3px 10px; border-radius: 6px; border: 1px solid var(--line); color: var(--navy); background: #fff; cursor: pointer; font-family: inherit; }
.act:hover { background: #f2f6fb; }
.act.del { color: var(--red); border-color: #f3c7c7; }
.act.edit { color: #a84c00; border-color: #f0d5b8; }
.linklike { border: 0; background: none; }
.inline-form { display: inline; }

/* ------------------------- أدوات الصفحة والفلاتر ------------------------- */
.page-tools { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; flex-wrap: wrap; margin-bottom: 16px; }
.toolbar-left { display: flex; gap: 8px; flex-wrap: wrap; }
.toolbar-right { display: flex; gap: 8px; }
.search-box { display: flex; gap: 6px; }
.search-box input { padding: 7.5px 12px; border: 1px solid var(--line); border-radius: 8px; font-family: inherit; font-size: 13.4px; min-width: 200px; }
.filter-bar { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 16px; }
.filter-bar label { display: flex; flex-direction: column; gap: 4px; font-size: 12.2px; color: var(--muted); font-weight: 700; }
.filter-bar input, .filter-bar select { padding: 7px 10px; border: 1px solid var(--line); border-radius: 7px; font-family: inherit; font-size: 13.2px; background: #fff; color: var(--text); }

/* ------------------------- النماذج ------------------------- */
.form-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); margin-bottom: 18px; }
.form-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 18px; }
.form-field { margin-bottom: 12px; }
.form-field.hidden { display: none; }
.field-label { display: block; font-size: 13px; font-weight: 700; margin-bottom: 5px; color: var(--navy); }
.form-field input[type=text], .form-field input[type=number], .form-field input[type=date],
.form-field input[type=email], .form-field input[type=password], .form-field select, .form-field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-family: inherit;
  font-size: 13.8px;
  background: #fff;
  color: var(--text);
}
.form-field textarea { resize: vertical; }
.form-field input:focus, .form-field select:focus, .form-field textarea:focus { outline: 2px solid rgba(33, 163, 102, .25); border-color: var(--green); }
.field-help { font-size: 11.8px; color: var(--muted); margin-top: 4px; }
.check-line { display: flex; gap: 8px; align-items: flex-start; font-size: 13.6px; padding: 6px 0; }
.fields-sub { font-size: 14px; color: var(--navy); border-bottom: 1px solid var(--line); padding-bottom: 6px; margin: 8px 0 12px; }
.form-actions { display: flex; gap: 10px; margin-top: 14px; flex-wrap: wrap; }

/* ------------------------- تفاصيل ------------------------- */
.detail-card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; margin-bottom: 16px; box-shadow: var(--shadow); }
.detail-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px 18px; margin-top: 8px; }
.detail-item { border-bottom: 1px dashed #edf0f5; padding: 6px 0; }
.detail-label { font-size: 11.8px; color: var(--muted); font-weight: 700; }
.detail-value { font-size: 14px; font-weight: 600; word-break: break-word; }
.confirm-box { background: #fff; border: 1px solid #f3c7c7; border-radius: var(--radius); padding: 24px; max-width: 640px; }
.confirm-rels { background: #fff7ec; border: 1px solid #f4ddba; border-radius: 8px; padding: 10px 16px; margin: 10px 0; }
.verdict { font-size: 15px; font-weight: 700; color: var(--navy); background: #eef3f9; border-radius: 8px; padding: 12px 16px; }

/* ------------------------- التنبيهات ------------------------- */
.alert-item { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; background: #fff; border: 1px solid var(--line); border-inline-start: 4px solid #8a94a6; border-radius: 9px; padding: 11px 14px; margin-bottom: 9px; }
.alert-item.alert-red { border-inline-start-color: var(--red); background: #fdf6f5; }
.alert-item.alert-orange { border-inline-start-color: var(--orange); background: #fffaf3; }
.alert-item.alert-green { border-inline-start-color: var(--green); background: #f4fbf7; }
.alert-title { font-weight: 800; font-size: 13.6px; }
.alert-detail { font-size: 12.9px; color: #46505e; margin-top: 2px; }
.alert-side { display: flex; flex-direction: column; gap: 6px; align-items: flex-end; flex-shrink: 0; }
.rules-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.rule-item { background: #f6f8fb; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; font-size: 12.8px; }

/* ------------------------- الرسوم ------------------------- */
.chart-box { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; margin-bottom: 16px; box-shadow: var(--shadow); }
.chart-title { font-weight: 800; color: var(--navy); font-size: 14.2px; margin-bottom: 8px; }
.chart-canvas-wrap { position: relative; }

/* ------------------------- خريطة الحرارة ------------------------- */
.heat-legend { display: flex; gap: 18px; flex-wrap: wrap; background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; margin-bottom: 12px; font-size: 13px; font-weight: 700; }
.legend-item { display: flex; align-items: center; gap: 7px; }
.legend-item i { width: 16px; height: 16px; border-radius: 4px; display: inline-block; }
.heat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.heat-card { background: #fff; border: 1px solid var(--line); border-inline-start: 5px solid #999; border-radius: 9px; padding: 13px 15px; text-decoration: none; color: var(--text); display: block; }
.heat-card:hover { box-shadow: var(--shadow); }
.heat-name { font-weight: 800; color: var(--navy); font-size: 14.2px; }
.heat-city { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.heat-row { display: flex; justify-content: space-between; font-size: 12.6px; padding: 3px 0; border-bottom: 1px dashed #f0f2f6; }
.heat-tag { display: inline-block; color: #fff; font-size: 11.6px; font-weight: 700; border-radius: 6px; padding: 3px 12px; margin-top: 8px; }

/* ------------------------- التقارير وطباعة ------------------------- */
.report-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.report-card { background: #fff; border: 1px solid var(--line); border-radius: 9px; padding: 15px 17px; text-decoration: none; color: var(--text); display: block; }
.report-card:hover { border-color: var(--navy-soft); box-shadow: var(--shadow); }
.report-name { font-weight: 800; color: var(--navy); }
.report-meta { font-size: 12px; color: var(--muted); margin-top: 4px; }
.type-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.type-card { background: #f6f8fb; border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; }
.type-name { font-weight: 800; font-size: 13.4px; color: var(--navy); }
.type-desc { font-size: 11.9px; color: var(--muted); margin-top: 3px; }
.fc-meta { margin: 8px 0 12px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.print-header { display: none; }

/* ------------------------- التبويبات ------------------------- */
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab { padding: 8px 18px; background: #fff; border: 1px solid var(--line); border-radius: 8px 8px 0 0; color: var(--navy); text-decoration: none; font-weight: 700; font-size: 13.4px; }
.tab.active { background: var(--navy); color: #fff; border-color: var(--navy); }

/* ------------------------- ترقيم الصفحات ------------------------- */
.pager { display: flex; gap: 5px; align-items: center; flex-wrap: wrap; margin: 14px 0; }
.pager-link { padding: 6px 12px; border: 1px solid var(--line); border-radius: 7px; text-decoration: none; color: var(--navy); font-size: 13px; background: #fff; }
.pager-link.active { background: var(--navy); color: #fff; border-color: var(--navy); }
.pager-info { font-size: 12.4px; color: var(--muted); margin-inline-end: 8px; }
.pager-dots { color: var(--muted); }
.more-link { margin-top: 10px; }

/* ------------------------- صفحة الدخول ------------------------- */
.login-body { background: linear-gradient(160deg, var(--navy) 0%, #0b2540 55%, #0d2c4c 100%); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card { background: #fff; border-radius: 14px; padding: 34px 36px; width: 100%; max-width: 430px; box-shadow: 0 12px 40px rgba(0, 0, 0, .3); }
.login-brand { text-align: center; margin-bottom: 18px; }
.login-brand small { display: block; color: var(--muted); font-size: 12.2px; margin-top: 4px; }
.logo-mark { display: inline-block; background: var(--navy); color: #fff; font-weight: 900; font-size: 24px; padding: 8px 22px; border-radius: 10px; letter-spacing: 1px; }
.logo-mark.small { font-size: 16px; padding: 4px 14px; }
.login-card h1 { font-size: 19px; text-align: center; margin: 6px 0 4px; }
.login-sub { text-align: center; color: var(--muted); font-size: 13px; margin: 0 0 16px; }
.login-form input { width: 100%; padding: 11px 14px; border: 1px solid var(--line); border-radius: 8px; font-family: inherit; font-size: 14px; margin-bottom: 12px; }
.login-form .field-label { margin-top: 6px; }
.login-links { display: flex; justify-content: space-between; margin-top: 16px; font-size: 12.8px; }
.login-foot { text-align: center; color: var(--muted); font-size: 11.6px; margin-top: 18px; border-top: 1px solid var(--line); padding-top: 12px; }

/* ------------------------- تجاوب الجوال والأجهزة اللوحية ------------------------- */
@media (max-width: 1100px) {
  .kpi-grid { grid-template-columns: repeat(3, 1fr); }
  .grid-4 { grid-template-columns: repeat(2, 1fr); }
  .type-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  .hamburger { display: flex; }
  .sidebar {
    position: fixed;
    inset-block: 0;
    inset-inline-start: 0;
    top: 0;
    transform: translateX(105%);
    transition: transform .28s ease;
    width: 272px;
    z-index: 80;
    box-shadow: 4px 0 24px rgba(0, 0, 0, .25);
  }
  html[dir="rtl"] .sidebar { transform: translateX(105%); }
  .sidebar.open { transform: translateX(0) !important; }
  .side-overlay.open { display: block; position: fixed; inset: 0; background: rgba(10, 20, 35, .5); z-index: 70; }
  .topbar { height: 60px; padding: 0 12px; }
  .topbar-title { display: none; }
  .user-name { display: none; }
  .content { padding: 14px 12px 40px; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 640px) {
  .kpi-grid, .kpi-grid.kpi-3, .kpi-grid.kpi-4 { grid-template-columns: repeat(2, 1fr); }
  .form-grid { grid-template-columns: 1fr; }
  .grid-4 { grid-template-columns: 1fr; }
  .detail-grid { grid-template-columns: 1fr; }
  .kpi-value { font-size: 16.5px; }
  .topbar-side .btn { padding: 5px 10px; font-size: 12px; }
  .topbar-brand a { font-size: 18px; }
  body { font-size: 13.8px; }
  .search-box input { min-width: 120px; width: 100%; }
  .toolbar-right { width: 100%; }
}
body.no-scroll { overflow: hidden; }

/* ------------------------- الطباعة ------------------------- */
@media print {
  @page { size: A4; margin: 14mm 12mm; }
  body { background: #fff; font-size: 12.2px; }
  .topbar, .sidebar, .side-overlay, .page-tools, .flash-area, .demo-banner, .filter-bar, .no-print, .pager, .more-link { display: none !important; }
  .layout { display: block; min-height: 0; }
  .content { padding: 0; }
  .panel, .detail-card, .chart-box, .kpi { box-shadow: none; border-color: #d5dbe4; break-inside: avoid; }
  .panel-head { padding-top: 10px; }
  .print-header { display: block; text-align: center; border-bottom: 3px double var(--navy); padding-bottom: 10px; margin-bottom: 16px; }
  .print-header .ph-company { font-weight: 800; color: var(--navy); font-size: 15px; }
  .print-header h2 { margin: 6px 0 4px; font-size: 18px; }
  .print-header .ph-meta { font-size: 12px; color: #444; }
  a { text-decoration: none; color: var(--text); }
  .data-table { font-size: 11.2px; }
  .data-table th { background: #eef3f9 !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .kpi-grid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .chart-canvas-wrap { height: 200px !important; }
}
