/* ================================================================
   منصة إدارة الجودة والتميز بشركة الحمراء لخدمات حجاج الداخل — Dashboard Styles
   ================================================================ */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700;800&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --sidebar-w: 260px;
  --topbar-h: 64px;
  --pad: 24px;
  --radius-card: 14px;
  --shadow-card: 0 1px 4px rgba(0,0,0,.07), 0 0 0 1px rgba(0,0,0,.03);
  --shadow-hover: 0 6px 20px rgba(0,0,0,.11);
}

body.dash-body {
  font-family: 'Cairo', sans-serif;
  background: #F4F1EB;
  color: #1a1a1a;
  direction: rtl;
  min-height: 100vh;
}

/* ── SIDEBAR ──────────────────────────────────────────────────── */
.dash-sidebar {
  position: fixed;
  top: 0; right: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: #8B2424;
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow-y: auto;
  overflow-x: hidden;
  transition: transform .3s cubic-bezier(.4,0,.2,1);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.1) transparent;
}

.sidebar-brand {
  padding: 16px 14px;
  border-bottom: 1px solid rgba(255,255,255,.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  text-align: center;
}

.sidebar-brand img {
  height: 38px;
  width: auto;
  flex-shrink: 0;
}

.sidebar-logos {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; width: 100%;
}
.sidebar-logos .sb-logo {
  height: 44px; width: auto; max-width: 78px; object-fit: contain;
  filter: drop-shadow(0 2px 6px rgba(0,0,0,.35));
}
.sidebar-logos .sb-logo--ministry {
  height: 64px; max-width: 110px;
}
.sidebar-logos .sb-sep {
  width: 1px; height: 36px;
  background: linear-gradient(180deg,transparent,rgba(201,168,76,.5),transparent);
}

.sidebar-brand-text {
  color: #C9A84C;
  font-size: .76rem;
  font-weight: 700;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.sidebar-brand-text span {
  display: block;
  font-weight: 400;
  font-size: .72rem;
  color: rgba(255,255,255,.5);
}

.dash-nav {
  flex: 1;
  padding: 10px 0;
}

.nav-section-label {
  font-size: .68rem;
  color: rgba(255,255,255,.3);
  text-transform: uppercase;
  letter-spacing: .08em;
  padding: 14px 18px 5px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 18px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: .9rem;
  font-weight: 500;
  transition: all .18s;
  cursor: pointer;
  border: none;
  background: none;
  width: 100%;
  text-align: right;
  font-family: 'Cairo', sans-serif;
  border-right: 3px solid transparent;
}

.nav-item svg {
  width: 17px; height: 17px;
  flex-shrink: 0;
  opacity: .75;
}

.nav-item:hover {
  color: #fff;
  background: rgba(255,255,255,.06);
  border-right-color: rgba(255,255,255,.15);
}

.nav-item.active {
  color: #C9A84C;
  background: rgba(201,168,76,.1);
  border-right-color: #C9A84C;
  font-weight: 600;
}

.nav-item.active svg { opacity: 1; }

/* ── Quality Guide special nav item ─────────────────────────── */
.nav-item.nav-item--qg {
  color: #E8C97A;
  background: linear-gradient(90deg, rgba(201,168,76,.18), rgba(201,168,76,.04) 60%, transparent);
  border-right-color: rgba(201,168,76,.55);
  font-weight: 700;
  position: relative;
  overflow: hidden;
}
.nav-item.nav-item--qg::before {
  content: '';
  position: absolute;
  top: 0; right: -100%;
  width: 60%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.18), transparent);
  animation: qgShine 3.4s ease-in-out infinite;
  pointer-events: none;
}
@keyframes qgShine {
  0%, 100% { right: -60%; }
  50%      { right: 110%; }
}
.nav-item.nav-item--qg svg {
  opacity: 1;
  color: #E8C97A;
  filter: drop-shadow(0 0 6px rgba(201,168,76,.45));
  transition: transform .35s ease;
}
.nav-item.nav-item--qg:hover {
  color: #fff;
  background: linear-gradient(90deg, rgba(201,168,76,.32), rgba(201,168,76,.10) 60%, transparent);
  border-right-color: #C9A84C;
}
.nav-item.nav-item--qg:hover svg {
  transform: rotate(-8deg) scale(1.08);
}
.qr-nav-badge {
  margin-right: auto;
  font-size: .62rem;
  font-weight: 800;
  letter-spacing: .5px;
  padding: 2px 8px;
  border-radius: 999px;
  background: linear-gradient(135deg, #C9A84C, #E8C97A);
  color: #8B2424;
  text-shadow: 0 1px 0 rgba(255,255,255,.25);
  box-shadow: 0 2px 8px rgba(201,168,76,.4);
  animation: qgBadgePulse 2.2s ease-in-out infinite;
  flex-shrink: 0;
}
@keyframes qgBadgePulse {
  0%, 100% { transform: scale(1);   box-shadow: 0 2px 8px rgba(201,168,76,.4); }
  50%      { transform: scale(1.08); box-shadow: 0 4px 14px rgba(201,168,76,.65); }
}

/* ── Collapsible Nav Group (الخطط) ─────────────────────────────── */
.nav-group { display: flex; flex-direction: column; }
.nav-group-head { width: 100%; }
.nav-group-head .nav-chev {
  margin-right: auto;
  width: 14px; height: 14px;
  opacity: .55;
  transition: transform .28s ease, opacity .2s;
}
.nav-group-head:hover .nav-chev { opacity: .85; }
.nav-group.open .nav-chev { transform: rotate(-180deg); opacity: 1; }
.nav-submenu {
  max-height: 0;
  overflow: hidden;
  transition: max-height .35s cubic-bezier(.4,0,.2,1);
  display: flex;
  flex-direction: column;
}
.nav-group.open .nav-submenu { max-height: 360px; }
.nav-subitem {
  padding: 8px 18px 8px 18px;
  padding-right: 46px;
  font-size: .82rem;
  font-weight: 500;
  position: relative;
  color: rgba(255,255,255,.55);
  border-right: 3px solid transparent;
}
.nav-subitem::before {
  content: '';
  position: absolute;
  right: 30px;
  top: 50%;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: rgba(201,168,76,.4);
  transform: translateY(-50%);
  transition: background .2s, transform .2s;
}
.nav-subitem:hover {
  color: #fff;
  background: rgba(255,255,255,.05);
  border-right-color: rgba(201,168,76,.4);
}
.nav-subitem:hover::before { background: #C9A84C; transform: translateY(-50%) scale(1.3); }
.nav-subitem svg { width: 14px; height: 14px; opacity: .7; }

.sidebar-user {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.sidebar-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #C9A84C, #A0812A);
  color: #8B2424;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .85rem;
  flex-shrink: 0;
}

.sidebar-user-info { flex: 1; min-width: 0; }

.sidebar-user-name {
  color: #fff;
  font-size: .82rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  color: rgba(255,255,255,.45);
  font-size: .7rem;
}

.sidebar-logout {
  background: none;
  border: none;
  color: rgba(255,255,255,.35);
  cursor: pointer;
  padding: 5px;
  border-radius: 6px;
  transition: all .18s;
  display: flex;
  align-items: center;
}

.sidebar-logout:hover { color: #f87171; background: rgba(248,113,113,.1); }

/* ── MAIN ─────────────────────────────────────────────────────── */
.dash-main {
  margin-right: var(--sidebar-w);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── TOPBAR ───────────────────────────────────────────────────── */
.dash-topbar {
  height: var(--topbar-h);
  background: #fff;
  border-bottom: 1px solid #e8e3d8;
  display: flex;
  align-items: center;
  padding: 0 var(--pad);
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
  flex-shrink: 0;
}

.topbar-menu-btn {
  display: none;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 8px;
  color: #8B2424;
  transition: background .15s;
}

.topbar-menu-btn:hover { background: #f3f4f6; }

.topbar-title {
  flex: 1;
  font-size: 1rem;
  font-weight: 700;
  color: #8B2424;
}

.topbar-actions { display: flex; gap: 8px; align-items: center; }

/* ── CONTENT ──────────────────────────────────────────────────── */
.dash-content {
  flex: 1;
  padding: var(--pad);
}

/* ── WELCOME ──────────────────────────────────────────────────── */
.welcome-row {
  margin-bottom: 22px;
}

.welcome-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: #8B2424;
  margin-bottom: 3px;
}

.welcome-date {
  font-size: .82rem;
  color: #8b8470;
}

/* ── STATS GRID ───────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

.stat-card {
  background: #fff;
  border-radius: var(--radius-card);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  box-shadow: var(--shadow-card);
  transition: box-shadow .2s, transform .2s;
}

.stat-card:hover {
  box-shadow: var(--shadow-hover);
  transform: translateY(-2px);
}

.stat-icon {
  width: 50px; height: 50px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.stat-icon--blue  { background: #EFF6FF; }
.stat-icon--green { background: #FFF8F0; }
.stat-icon--red   { background: #FEF2F2; }
.stat-icon--gold  { background: #FFFBEB; }

.stat-body { flex: 1; }

.stat-label {
  font-size: .76rem;
  color: #7b7468;
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: #111827;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.stat-sub {
  font-size: .72rem;
  color: #aaa49a;
  margin-top: 4px;
}

/* ── QUICK ACTIONS ────────────────────────────────────────────── */
.quick-actions {
  display: flex;
  gap: 10px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

/* ── BUTTONS ──────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 10px 20px;
  border-radius: 9px;
  font-size: .88rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all .18s;
  font-family: 'Cairo', sans-serif;
  text-decoration: none;
  white-space: nowrap;
}

.btn--primary {
  background: #8B2424;
  color: #fff;
}
.btn--primary:hover { background: #A52A2A; }

.btn--gold {
  background: #C9A84C;
  color: #3D0A0A;
}
.btn--gold:hover { background: #A0812A; color: #fff; }

.btn--outline {
  background: transparent;
  color: #8B2424;
  border: 2px solid #8B2424;
}
.btn--outline:hover { background: #8B2424; color: #fff; }

.btn--ghost {
  background: transparent;
  color: #6b7280;
  border: 1px solid #e5e7eb;
}
.btn--ghost:hover { background: #f9fafb; color: #111; border-color: #d1d5db; }

.btn--sm { padding: 6px 14px; font-size: .79rem; border-radius: 7px; }

.btn--danger {
  background: #FEF2F2;
  color: #EF4444;
  border: 1px solid #FECACA;
}
.btn--danger:hover { background: #EF4444; color: #fff; }

.btn svg { flex-shrink: 0; }

/* ── Topbar Home button ──────────────────────────────────────── */
.topbar-home-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  text-decoration: none;
  color: #8B2424;
  border-color: #d6e4dd;
  background: #f5f9f7;
  font-weight: 700;
  transition: background .15s, color .15s, border-color .15s, transform .15s;
}
.topbar-home-link:hover {
  background: #8B2424;
  color: #fff;
  border-color: #8B2424;
  transform: translateY(-1px);
}
.topbar-home-link svg { color: currentColor; }

@media (max-width: 560px) {
  .topbar-home-link span { display: none; }
  .topbar-home-link { padding: 6px 9px; }
}

/* ── SECTION HEADER ───────────────────────────────────────────── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.section-title {
  font-size: .98rem;
  font-weight: 700;
  color: #8B2424;
}

/* ── REPORTS TABLE ────────────────────────────────────────────── */
.table-card {
  background: #fff;
  border-radius: var(--radius-card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.reports-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .86rem;
}

.reports-table th {
  background: #f9f7f3;
  padding: 12px 16px;
  text-align: right;
  font-weight: 600;
  color: #4b5563;
  border-bottom: 1px solid #f0ece4;
  font-size: .78rem;
  white-space: nowrap;
}

.reports-table td {
  padding: 13px 16px;
  border-bottom: 1px solid #faf8f4;
  color: #374151;
  vertical-align: middle;
}

.reports-table tg:last-child td { border-bottom: none; }
.reports-table tg:hover td { background: #faf9f6; }

/* ── BADGE ────────────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: .73rem;
  font-weight: 600;
  white-space: nowrap;
}

.badge--green  { background: #FFF8F0; color: #DC2626; }
.badge--red    { background: #FEF2F2; color: #DC2626; }
.badge--blue   { background: #EFF6FF; color: #2563EB; }
.badge--gold   { background: #FFFBEB; color: #B45309; }
.badge--gray   { background: #F3F4F6; color: #6B7280; }
.badge--purple { background: #F5F3FF; color: #7C3AED; }

/* ── PROGRESS BAR ─────────────────────────────────────────────── */
.progress-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.progress-bar {
  flex: 1;
  height: 6px;
  border-radius: 999px;
  background: #f0ece4;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  border-radius: 999px;
  transition: width .6s ease;
}

.progress-fill--green  { background: #EF4444; }
.progress-fill--gold   { background: #F59E0B; }
.progress-fill--red    { background: #EF4444; }

.progress-pct {
  font-size: .78rem;
  font-weight: 700;
  color: #374151;
  min-width: 34px;
  text-align: left;
}

/* ── EMPTY STATE ──────────────────────────────────────────────── */
.empty-state {
  padding: 52px 24px;
  text-align: center;
}

.empty-icon { font-size: 2.8rem; margin-bottom: 12px; opacity: .35; }

.empty-title {
  font-size: .95rem;
  font-weight: 600;
  color: #8b8470;
  margin-bottom: 5px;
}

.empty-text { font-size: .82rem; color: #aaa49a; }

/* ── MODAL ────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: #fff;
  border-radius: 18px;
  padding: 28px;
  max-width: 520px;
  width: 100%;
  transform: translateY(18px) scale(.97);
  transition: transform .25s cubic-bezier(.4,0,.2,1);
  max-height: 90vh;
  overflow-y: auto;
}

.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}

.modal-title {
  font-size: 1.02rem;
  font-weight: 700;
  color: #8B2424;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  color: #9ca3af;
  line-height: 1;
  padding: 4px 7px;
  border-radius: 6px;
  font-family: sans-serif;
}
.modal-close:hover { color: #374151; background: #f3f4f6; }

/* Report type selection */
.type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 6px;
}

.type-card {
  border: 2px solid #e8e3d8;
  border-radius: 12px;
  padding: 15px 10px;
  text-align: center;
  cursor: pointer;
  transition: all .18s;
  background: #fff;
}

.type-card:hover {
  border-color: #A52A2A;
  background: #FFF8F0;
}

.type-card.selected {
  border-color: #8B2424;
  background: #FFF8F0;
  box-shadow: 0 0 0 3px rgba(139,36,36,.1);
}

.type-card-icon { font-size: 1.7rem; margin-bottom: 7px; }

.type-card-name {
  font-size: .83rem;
  font-weight: 600;
  color: #8B2424;
}

.type-card--full { grid-column: span 2; }

/* Form in modal */
.form-group { margin-bottom: 15px; }

.form-group label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: #374151;
  margin-bottom: 6px;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 9px 12px;
  border: 1.5px solid #e5e7eb;
  border-radius: 8px;
  font-family: 'Cairo', sans-serif;
  font-size: .88rem;
  color: #111827;
  background: #fff;
  direction: rtl;
  transition: border-color .18s;
}

.form-group input:focus,
.form-group select:focus {
  outline: none;
  border-color: #A52A2A;
  box-shadow: 0 0 0 3px rgba(165,42,42,.08);
}

.back-btn {
  background: none;
  border: none;
  color: #6b7280;
  cursor: pointer;
  font-size: .83rem;
  font-family: 'Cairo', sans-serif;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-bottom: 16px;
  padding: 0;
  transition: color .15s;
}
.back-btn:hover { color: #8B2424; }

/* ── READ-ONLY BADGE (Manager) ────────────────────────────────── */
.readonly-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #FFFBEB;
  color: #B45309;
  border: 1px solid #FDE68A;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: .76rem;
  font-weight: 600;
}

/* ── SIDEBAR OVERLAY (mobile) ─────────────────────────────────── */
.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 99;
}

/* ── TOAST ────────────────────────────────────────────────────── */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}

.toast {
  background: #1f2937;
  color: #fff;
  padding: 11px 18px;
  border-radius: 10px;
  font-size: .86rem;
  font-family: 'Cairo', sans-serif;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 200px;
  animation: toastSlide .28s ease;
  box-shadow: 0 4px 16px rgba(0,0,0,.22);
  pointer-events: all;
}

.toast--success { border-right: 3px solid #EF4444; }
.toast--error   { border-right: 3px solid #EF4444; }
.toast--info    { border-right: 3px solid #3B82F6; }
.toast--warn    { border-right: 3px solid #F59E0B; }

@keyframes toastSlide {
  from { opacity: 0; transform: translateX(-16px); }
  to   { opacity: 1; transform: translateX(0); }
}

/* ── RESPONSIVE ───────────────────────────────────────────────── */
@media (max-width: 1024px) {
  :root { --sidebar-w: 230px; }
}

@media (max-width: 768px) {
  .dash-sidebar {
    transform: translateX(100%);
    box-shadow: -4px 0 20px rgba(0,0,0,.2);
  }

  .dash-sidebar.open { transform: translateX(0); }

  .dash-main { margin-right: 0; }

  .topbar-menu-btn { display: flex; }

  .sidebar-overlay.show { display: block; }

  .stats-grid { grid-template-columns: 1fr 1fr; }

  .type-grid { grid-template-columns: 1fr 1fr; }

  :root { --pad: 16px; }

  .reports-table th:nth-child(3),
  .reports-table td:nth-child(3) { display: none; }
}

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }

  .type-grid { grid-template-columns: 1fr; }

  .type-card--full { grid-column: span 1; }

  .modal { padding: 20px; border-radius: 14px; }

  .stat-value { font-size: 1.45rem; }

  .reports-table th:nth-child(2),
  .reports-table td:nth-child(2) { display: none; }
}
