/* ===================================================================
   أطلس كودات البناء العالمية - تخطيط وهيكل الصفحة (Layout & Grids)
   =================================================================== */

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

html {
  scroll-behavior: smooth;
  font-size: 16px;
}

body {
  font-family: var(--font-arabic);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.68;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

button, input, select, textarea {
  font-family: inherit;
  color: inherit;
}

a {
  color: inherit;
  text-decoration: none;
  transition: color var(--transition-fast);
}

.container {
  width: min(1340px, calc(100% - 36px));
  margin-inline: auto;
}

/* شريط الإعلانات والبيانات العلوية */
.topbar {
  background: var(--brand-navy);
  color: #94a3b8;
  font-size: 0.8rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  z-index: 40;
}

.topbar .container {
  min-height: 40px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.topbar-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(217, 119, 6, 0.16);
  color: #fcd34d;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  font-weight: 700;
  border: 1px solid rgba(217, 119, 6, 0.3);
}

.topbar-badge::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #f59e0b;
  box-shadow: 0 0 8px #f59e0b;
}

.topbar-links {
  display: flex;
  align-items: center;
  gap: 18px;
}

.topbar-links a:hover {
  color: #ffffff;
}

/* ===================================================================
   الهيدر المؤسسي الفاخر من مستويين (Two-Level Luxury Enterprise Header)
   مستوحى من مرجع التصميم Image 2
   =================================================================== */

.enterprise-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: #061a35;
  box-shadow: 0 4px 24px rgba(6, 26, 53, 0.28);
  transition: background var(--transition-normal);
}

/* المستوى الأول: شريط التطبيق الرئيسي (Level 1: Main Application Bar) */
.header-level-1 {
  background: #061a35;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  height: 66px;
}

.level-1-container {
  width: min(1440px, calc(100% - 32px));
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-inline: auto;
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
  position: relative;
  transition: transform var(--transition-fast);
}

.brand-wrapper:hover {
  text-decoration: none;
}

.brand-logo-container {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
}

.brand-logo-svg {
  width: 48px;
  height: 48px;
  display: block;
  border-radius: 12px;
  box-shadow: 0 4px 16px rgba(15, 23, 42, 0.22), 0 0 0 1px rgba(56, 189, 248, 0.18);
  transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
}

.brand-logo-glow {
  position: absolute;
  inset: -4px;
  border-radius: 16px;
  background: radial-gradient(circle at center, rgba(14, 165, 233, 0.4) 0%, transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
  z-index: -1;
}

.brand-wrapper:hover .brand-logo-svg {
  transform: translateY(-2px) scale(1.05);
  box-shadow: 0 10px 24px rgba(14, 165, 233, 0.32), 0 0 0 1.5px rgba(56, 189, 248, 0.45);
}

.brand-wrapper:hover .brand-logo-glow {
  opacity: 1;
}

/* Brand Typography & Layout */
.brand-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  white-space: nowrap;
}

.brand-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

.brand-title {
  margin: 0;
  padding: 0;
  font-size: 1.25rem;
  font-weight: 900;
  line-height: 1.2;
  color: var(--text-primary);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  letter-spacing: -0.3px;
  white-space: nowrap;
}

/* Explicit high-contrast white & cyan branding for the dark navy enterprise header */
.enterprise-header .brand-title {
  color: #ffffff;
}

.enterprise-header .brand-topic {
  color: #f8fafc;
}

.brand-topic-mobile {
  display: none;
}

.brand-topic-full {
  display: inline;
}

.mobile-search-btn {
  display: none;
}

.lang-desktop-label {
  display: inline;
}

.lang-mobile-label {
  display: none;
}

.enterprise-header .brand-from {
  color: #94a3b8;
}

.enterprise-header .brand-subtitle {
  color: #94a3b8;
}

.enterprise-header .brand-sub-domain {
  color: #38bdf8;
}

.enterprise-header .brand-keifa-highlight {
  background: linear-gradient(135deg, #38bdf8 0%, #60a5fa 100%) !important;
  -webkit-background-clip: text !important;
  -webkit-text-fill-color: transparent !important;
}

.enterprise-header .brand-version-badge {
  background: rgba(245, 158, 11, 0.18) !important;
  border: 1px solid rgba(245, 158, 11, 0.5) !important;
  color: #fbbf24 !important;
}

.brand-keifa-highlight {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 40%, #1e3a8a 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 950;
  letter-spacing: -0.3px;
  white-space: nowrap;
}

[data-theme="dark"] .brand-keifa-highlight {
  background: linear-gradient(135deg, #38bdf8 0%, #60a5fa 50%, #93c5fd 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-from {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.88em;
  margin-inline: 1px;
  opacity: 0.85;
}

.brand-divider {
  color: var(--border-strong, #cbd5e1);
  font-weight: 300;
  opacity: 0.6;
  font-size: 1.15rem;
  user-select: none;
  line-height: 1;
}

.brand-topic {
  color: var(--text-primary);
  font-weight: 800;
  letter-spacing: -0.3px;
  white-space: nowrap;
}

.brand-version-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid rgba(245, 158, 11, 0.35);
  color: #b45309;
  font-size: 0.68rem;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  line-height: 1.25;
  white-space: nowrap;
  flex-shrink: 0;
}

[data-theme="dark"] .brand-version-badge {
  background: rgba(245, 158, 11, 0.15);
  border-color: rgba(245, 158, 11, 0.45);
  color: #fbbf24;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 rgba(16, 185, 129, 0.4);
  animation: pulseLiveDot 2.2s infinite;
}

@keyframes pulseLiveDot {
  0% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
  }
  70% {
    box-shadow: 0 0 0 6px rgba(16, 185, 129, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
  }
}

.brand-subtitle {
  margin: 0;
  padding: 0;
  font-size: 0.71rem;
  font-weight: 600;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 6px;
  line-height: 1.25;
  white-space: nowrap;
}

.brand-sub-tag {
  opacity: 0.85;
  white-space: nowrap;
}

.brand-sub-sep {
  opacity: 0.4;
  font-size: 0.65rem;
}

.brand-sub-domain {
  color: var(--brand-blue);
  font-family: var(--font-latin);
  font-weight: 700;
  letter-spacing: 0.5px;
  font-size: 0.72rem;
  white-space: nowrap;
}

@media (max-width: 1500px) {
  .brand-sub-tag,
  .brand-sub-sep {
    display: none;
  }
}

/* الوسط: محرك البحث العام المدمج الفاخر (Global Compact Search) */
.header-center-search {
  flex: 1;
  max-width: 520px;
  margin-inline: 20px;
}

.compact-search-bar {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  height: 40px;
  padding: 0 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
}

.compact-search-bar:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: #38bdf8;
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.2);
}

.compact-search-bar .search-ico {
  color: #38bdf8;
  font-size: 1.1rem;
  line-height: 1;
}

.compact-search-bar .search-ph {
  flex: 1;
  color: #94a3b8;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.compact-search-bar .search-k-badge {
  font-size: 0.65rem;
  font-family: var(--font-mono);
  font-weight: 700;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 2px 7px;
  border-radius: 4px;
  color: #cbd5e1;
}

/* اليسار: أدوات التحكم الوظيفية المدمجة (Utility Controls) */
.header-utility-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.utility-ctrl-btn {
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.06);
  color: #ffffff;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: all var(--transition-fast);
  user-select: none;
}

.utility-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.28);
  color: #38bdf8;
}

.mobile-menu-btn,
.mobile-search-btn {
  display: none !important;
}

.mobile-menu-btn {
  width: 38px;
  padding: 0;
  flex-direction: column;
  gap: 4px;
}

.mobile-menu-btn .bar-line {
  width: 18px;
  height: 2px;
  background: #ffffff;
  border-radius: 2px;
}

/* ===================================================================
   المستوى الثاني: شريط التنقل الأفقي المتكامل (Level 2: Horizontal Nav)
   =================================================================== */

.header-level-2 {
  background: #08294F;
  border-bottom: 1px solid rgba(220, 229, 241, 0.12);
  height: 48px;
  position: relative;
  overflow: visible;
  max-width: 100%;
}

.level-2-container {
  width: min(1440px, calc(100% - 32px));
  max-width: 100%;
  box-sizing: border-box;
  height: 100%;
  margin-inline: auto;
  display: flex;
  align-items: center;
  overflow: visible;
}

.enterprise-nav-menu {
  display: flex;
  align-items: center;
  list-style: none;
  margin: 0;
  padding: 0;
  gap: 4px;
  height: 100%;
}

.enterprise-nav-menu .nav-item {
  height: 100%;
  position: relative;
  display: flex;
  align-items: center;
}

.enterprise-nav-menu .nav-item.has-mega {
  position: static;
}

.enterprise-nav-menu .nav-tab-btn {
  height: 48px;
  padding: 0 16px;
  border: none;
  border-bottom: 3px solid transparent;
  border-radius: 0;
  background: transparent;
  color: #cbd5e1;
  font-size: 0.88rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  transition: all var(--transition-fast);
  user-select: none;
  white-space: nowrap;
}

.enterprise-nav-menu .nav-tab-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.06);
}

.enterprise-nav-menu .nav-tab-btn.active {
  color: #ffffff;
  border-bottom-color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
}

.enterprise-nav-menu .nav-chevron {
  font-size: 0.7rem;
  color: #94a3b8;
  transition: transform 0.22s ease;
}

.enterprise-nav-menu .nav-item.open .nav-chevron,
.enterprise-nav-menu .nav-item:hover .nav-chevron {
  transform: rotate(180deg);
  color: #38bdf8;
}

/* ===================================================================
   القائمة العملاقة الاحترافية (Professional Multi-Column Mega Menu)
   =================================================================== */

.mega-menu-panel {
  position: absolute;
  top: 100%;
  inset-inline: 0;
  width: min(1440px, calc(100% - 32px));
  margin-inline: auto;
  background: #ffffff;
  color: #10223D;
  border: 1px solid #DCE5F1;
  border-top: none;
  border-radius: 0 0 16px 16px;
  box-shadow: 0 24px 48px -12px rgba(6, 26, 53, 0.28), 0 0 0 1px rgba(0, 0, 0, 0.04);
  display: none;
  z-index: 150;
  animation: megaFadeIn 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.mega-menu-panel::before {
  content: "";
  position: absolute;
  top: -10px;
  inset-inline: 0;
  height: 10px;
}

.nav-item.has-mega:hover .mega-menu-panel,
.mega-menu-panel.open {
  display: block !important;
}

@keyframes megaFadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.mega-menu-inner {
  display: grid;
  grid-template-columns: 270px 330px 290px 1fr;
  min-height: 420px;
}

.mega-col {
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  border-inline-end: 1px solid #edf2f7;
}

.mega-col-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid #edf2f7;
}

.mega-col-heading {
  font-size: 0.96rem;
  font-weight: 800;
  color: #061A35;
  margin: 0;
}

.mega-head-tag {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 9999px;
  background: #f1f5f9;
  color: #475569;
}

/* العمود 1: التخصصات الهندسية */
.mega-cat-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.mega-cat-btn {
  width: 100%;
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: #334155;
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 9px;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: inherit;
}

.mega-cat-btn:hover {
  background: #f8fafc;
  border-color: #e2e8f0;
  color: #1764D9;
  transform: translateX(-2px);
}

[dir="ltr"] .mega-cat-btn:hover {
  transform: translateX(2px);
}

.mega-cat-btn .cat-ico {
  font-size: 1.05rem;
}

.mega-cat-btn .cat-name {
  flex: 1;
}

.mega-cat-btn .cat-count {
  font-size: 0.72rem;
  color: #94a3b8;
  font-weight: 600;
}

/* العمود 2: أهم الأكواد الإنشائية المعتمدة */
.mega-codes-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.mega-code-card {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  cursor: pointer;
  transition: all 0.18s ease;
}

.mega-code-card:hover {
  background: #f8fafc;
  border-color: #1764D9;
  box-shadow: 0 4px 12px rgba(23, 100, 217, 0.08);
  transform: translateY(-2px);
}

.code-card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.badge-code {
  font-size: 0.72rem;
  font-weight: 800;
  padding: 2px 8px;
  border-radius: 6px;
  font-family: var(--font-latin);
}

.badge-aci { background: rgba(23, 100, 217, 0.12); color: #1764D9; }
.badge-asce { background: rgba(2, 132, 199, 0.12); color: #0284c7; }
.badge-euro { background: rgba(109, 40, 217, 0.12); color: #6d28d9; }
.badge-sbc { background: rgba(4, 120, 87, 0.12); color: #047857; }
.badge-ibc { background: rgba(217, 119, 6, 0.12); color: #b45309; }

.code-year {
  font-size: 0.7rem;
  color: #64748b;
  font-weight: 700;
  font-family: var(--font-mono);
}

.code-name {
  font-size: 0.86rem;
  font-weight: 700;
  color: #10223D;
  margin-bottom: 2px;
}

.code-desc {
  font-size: 0.75rem;
  color: #64748b;
  line-height: 1.35;
}

/* العمود 3: أدوات واستكشاف */
.mega-actions-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mega-action-row {
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: #f8fafc;
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  transition: all 0.18s ease;
  text-align: inherit;
  width: 100%;
}

.mega-action-row:hover {
  background: #ffffff;
  border-color: #1764D9;
  box-shadow: 0 4px 12px rgba(23, 100, 217, 0.08);
  transform: translateY(-2px);
}

.action-ico {
  font-size: 1.3rem;
  flex-shrink: 0;
}

.action-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.action-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: #10223D;
}

.action-sub {
  font-size: 0.74rem;
  color: #64748b;
  line-height: 1.3;
}

/* العمود 4: لوحة الترويج والتميز الفاخرة (Blueprint Featured Card) */
.mega-col-promo {
  border-inline-end: none;
  background: radial-gradient(circle at 85% 15%, #133966 0%, #061A35 100%);
  color: #ffffff;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px 24px;
}

.blueprint-mesh-bg {
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(to right, rgba(56, 189, 248, 0.08) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(56, 189, 248, 0.08) 1px, transparent 1px);
  background-size: 20px 20px;
  pointer-events: none;
}

.blueprint-badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 800;
  color: #DCAA54;
  background: rgba(220, 170, 84, 0.15);
  border: 1px solid rgba(220, 170, 84, 0.35);
  padding: 3px 9px;
  border-radius: 9999px;
  margin-bottom: 14px;
  align-self: flex-start;
}

.blueprint-title {
  font-size: 1.25rem;
  font-weight: 800;
  color: #ffffff;
  margin: 0 0 10px 0;
  line-height: 1.3;
}

.blueprint-desc {
  font-size: 0.86rem;
  color: #cbd5e1;
  line-height: 1.6;
  margin: 0 0 20px 0;
}

.blueprint-cta-btn {
  align-self: flex-start;
  background: #1764D9;
  border: none;
  color: #ffffff;
  font-weight: 700;
  padding: 10px 20px;
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
}

.blueprint-cta-btn:hover {
  background: #1d4ed8;
  box-shadow: 0 0 20px rgba(56, 189, 248, 0.35);
  transform: translateY(-2px);
}

.blueprint-stats-row {
  margin-top: 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 0.76rem;
  color: #94a3b8;
  font-weight: 600;
}

/* ===================================================================
   القوائم المنسدلة السياقية (Contextual Dropdowns)
   =================================================================== */

.nav-dropdown-menu {
  position: absolute;
  top: 100%;
  inset-inline-start: 0;
  min-width: 320px;
  background: #ffffff;
  color: #10223D;
  border: 1px solid #DCE5F1;
  border-top: none;
  border-radius: 0 0 14px 14px;
  box-shadow: 0 20px 40px -10px rgba(6, 26, 53, 0.25);
  display: none;
  z-index: 150;
  animation: megaFadeIn 0.2s ease;
  overflow: hidden;
  padding: 16px;
}

.nav-dropdown-menu.dropdown-wide {
  min-width: 580px;
}

.nav-dropdown-menu::before {
  content: "";
  position: absolute;
  top: -10px;
  inset-inline: 0;
  height: 10px;
}

.nav-item.has-dropdown:hover .nav-dropdown-menu,
.nav-dropdown-menu.open {
  display: block !important;
}

.dropdown-head {
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid #edf2f7;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.drop-title {
  font-size: 0.92rem;
  font-weight: 800;
  color: #061A35;
}

.drop-sub {
  font-size: 0.74rem;
  color: #64748b;
}

.dropdown-items-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dropdown-grid-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.dropdown-row-link {
  padding: 8px 10px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: inherit;
  transition: all 0.15s ease;
}

.dropdown-row-link:hover {
  background: #ffffff;
  border-color: #1764D9;
  color: #1764D9;
  box-shadow: 0 2px 8px rgba(23, 100, 217, 0.08);
  transform: translateY(-1px);
}

.row-ico {
  font-size: 1.15rem;
  flex-shrink: 0;
}

.row-meta {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.row-meta strong {
  font-size: 0.84rem;
  font-weight: 700;
  color: #10223D;
}

.row-meta span {
  font-size: 0.72rem;
  color: #64748b;
}

.dropdown-foot {
  margin-top: 14px;
  padding-top: 10px;
  border-top: 1px solid #edf2f7;
}

/* ===================================================================
   بوابات الوصول السريع الهندسية (Quick-Access Navigation Cards)
   =================================================================== */

.quick-access-section {
  margin: 32px 0 28px;
}

.quick-access-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 16px;
}

.quick-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  padding: 18px 16px;
  cursor: pointer;
  transition: all 0.22s cubic-bezier(0.16, 1, 0.3, 1);
  display: flex;
  flex-direction: column;
  position: relative;
}

.quick-card:hover {
  transform: translateY(-4px);
  border-color: var(--brand-blue);
  box-shadow: 0 12px 28px -6px rgba(23, 100, 217, 0.16);
}

.quick-card-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
}

.quick-card-icon {
  font-size: 1.3rem;
}

.qc-blue { background: rgba(23, 100, 217, 0.12); color: #1764D9; }
.qc-emerald { background: rgba(16, 185, 129, 0.12); color: #059669; }
.qc-indigo { background: rgba(99, 102, 241, 0.12); color: #4f46e5; }
.qc-amber { background: rgba(245, 158, 11, 0.12); color: #d97706; }
.qc-violet { background: rgba(139, 92, 246, 0.12); color: #7c3aed; }
.qc-rose { background: rgba(244, 63, 94, 0.12); color: #e11d48; }

.quick-card-title {
  font-size: 0.98rem;
  font-weight: 800;
  color: var(--text-primary);
  margin: 0 0 6px 0;
}

.quick-card-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  line-height: 1.45;
  margin: 0 0 14px 0;
  flex: 1;
}

.quick-card-arrow {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--brand-blue);
  align-self: flex-start;
  transition: transform 0.2s ease;
}

.quick-card:hover .quick-card-arrow {
  transform: translateX(-4px);
}

[dir="ltr"] .quick-card:hover .quick-card-arrow {
  transform: translateX(4px);
}

/* ===================================================================
   تعديلات الوضع الداكن الفاخر (Dark Theme Overrides)
   =================================================================== */

[data-theme="dark"] .mega-menu-panel,
[data-theme="dark"] .nav-dropdown-menu {
  background: #0B1A30;
  color: #F8FAFC;
  border-color: #1E3A5F;
  box-shadow: 0 24px 50px rgba(0, 0, 0, 0.65);
}

[data-theme="dark"] .mega-col {
  border-inline-end-color: #162E4C;
}

[data-theme="dark"] .mega-col-head,
[data-theme="dark"] .dropdown-head,
[data-theme="dark"] .dropdown-foot {
  border-bottom-color: #162E4C;
  border-top-color: #162E4C;
}

[data-theme="dark"] .mega-col-heading,
[data-theme="dark"] .drop-title,
[data-theme="dark"] .code-name,
[data-theme="dark"] .action-title,
[data-theme="dark"] .row-meta strong {
  color: #F8FAFC;
}

[data-theme="dark"] .mega-cat-btn,
[data-theme="dark"] .dropdown-row-link {
  color: #CBD5E1;
}

[data-theme="dark"] .mega-cat-btn:hover,
[data-theme="dark"] .dropdown-row-link:hover {
  background: #112644;
  color: #38BDF8;
  border-color: #1E3A5F;
}

[data-theme="dark"] .mega-code-card,
[data-theme="dark"] .mega-action-row,
[data-theme="dark"] .dropdown-row-link {
  background: #0E203B;
  border-color: #1A3456;
}

[data-theme="dark"] .mega-code-card:hover,
[data-theme="dark"] .mega-action-row:hover {
  background: #132B4F;
  border-color: #38BDF8;
}

[data-theme="dark"] .mega-head-tag {
  background: #112644;
  color: #94A3B8;
}

/* التجاوب والشاشات المتوسطة والصغيرة (Responsive Breakpoints) */
@media (max-width: 1280px) {
  .quick-access-grid {
    grid-template-columns: repeat(3, 1fr);
  }
  .mega-menu-inner {
    grid-template-columns: 240px 290px 260px 1fr;
  }
}

@media (max-width: 1024px) and (min-width: 769px) {
  .header-center-search {
    display: flex;
    max-width: 320px;
    margin-inline: 12px;
  }
  .mobile-menu-btn {
    display: flex;
  }
  .header-level-2 {
    overflow: visible;
  }
  .enterprise-nav-menu .nav-tab-btn {
    padding: 0 10px;
    font-size: 0.82rem;
    gap: 5px;
  }
  /* Dedicated Tablet Mega Menu: Adaptive 3-Column Layout */
  .mega-menu-panel {
    width: calc(100% - 24px);
    max-height: 80vh;
    overflow-y: auto;
  }
  .mega-menu-inner {
    grid-template-columns: 220px 1fr 240px;
  }
  .mega-col-promo {
    display: none;
  }
  .quick-access-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 768px) {
  .header-center-search {
    display: none;
  }
  .mobile-menu-btn {
    display: flex;
  }
  .header-level-2 {
    display: none;
  }
  .mega-menu-panel {
    display: none !important;
  }
  .mobile-bottom-dock {
    display: flex;
  }
  .quick-access-grid {
    grid-template-columns: 1fr;
  }
}

/* درج التنقل للأجهزة الذكية (Mobile Navigation Drawer) */
.mobile-drawer-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 8, 16, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 120;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

.mobile-drawer-backdrop.open {
  opacity: 1;
  pointer-events: auto;
}

.mobile-nav-drawer {
  position: fixed;
  top: 0;
  bottom: 0;
  inset-inline-start: 0;
  width: min(340px, 86vw);
  background: var(--surface);
  border-inline-end: 1px solid var(--border-medium);
  box-shadow: var(--shadow-xl);
  z-index: 130;
  transform: translateX(100%);
  transition: transform var(--transition-smooth), visibility var(--transition-smooth);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  visibility: hidden;
  pointer-events: none;
}

[dir="ltr"] .mobile-nav-drawer {
  transform: translateX(-100%);
}

.mobile-nav-drawer.open {
  transform: translateX(0) !important;
  visibility: visible !important;
  pointer-events: auto !important;
}

@media (min-width: 769px) {
  .mobile-nav-drawer {
    display: none !important;
  }
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 900;
  font-size: 1.15rem;
  color: var(--text-primary);
}

.drawer-close-btn {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-medium);
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  display: grid;
  place-items: center;
}

.drawer-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.drawer-search-btn {
  width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  color: var(--text-muted);
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  text-align: inherit;
}

.drawer-nav-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.drawer-group-label {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 4px;
}

.drawer-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-secondary);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  text-align: inherit;
  transition: all var(--transition-fast);
}

.drawer-item:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.drawer-item.active {
  background: rgba(37, 99, 235, 0.08);
  color: var(--brand-blue);
  border-color: rgba(37, 99, 235, 0.25);
}

[data-theme="dark"] .drawer-item.active {
  background: rgba(56, 189, 248, 0.12);
  color: var(--brand-cyan);
  border-color: rgba(56, 189, 248, 0.3);
}

.drawer-setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 0.88rem;
  color: var(--text-secondary);
}

/* شريط التثبيت السفلي للهواتف الذكية (Mobile Bottom Dock) */
.mobile-bottom-dock {
  display: none;
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  height: 60px;
  background: var(--surface-dock);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  z-index: 100;
  align-items: center;
  justify-content: space-around;
  padding-bottom: max(4px, env(safe-area-inset-bottom));
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.06);
}

.bottom-dock-btn {
  flex: 1;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 0;
  transition: all var(--transition-fast);
  user-select: none;
}

.bottom-dock-btn .dock-icon {
  font-size: 1.15rem;
  line-height: 1;
}

.bottom-dock-btn .dock-label {
  font-size: 0.68rem;
  font-weight: 700;
}

.bottom-dock-btn:hover {
  color: var(--text-primary);
}

.bottom-dock-btn.active {
  color: var(--brand-blue);
}

[data-theme="dark"] .bottom-dock-btn.active {
  color: var(--brand-cyan);
}

/* نافذة لوحة الأوامر والبحث الشامل (Command Palette Modal Ctrl+K) */
dialog.command-palette-modal {
  width: min(680px, calc(100% - 32px));
  max-height: 80vh;
  margin: auto;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  padding: 0;
  display: none;
  flex-direction: column;
}

dialog.command-palette-modal[open] {
  display: flex;
  animation: cmdModalFadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes cmdModalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.97) translateY(-8px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

dialog.command-palette-modal::backdrop {
  background: rgba(4, 8, 16, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

.cmd-modal-box {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-height: 80vh;
}

.cmd-search-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface);
}

.cmd-search-icon {
  font-size: 1.25rem;
  color: var(--brand-blue);
  line-height: 1;
}

.cmd-input {
  flex: 1;
  min-width: 0;
  width: 100%;
  border: none;
  outline: none;
  background: transparent;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-primary);
}

.cmd-esc-badge {
  font-size: 0.68rem;
  font-family: var(--font-mono);
  font-weight: 700;
  padding: 2px 7px;
  border-radius: var(--radius-2xs);
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  color: var(--text-muted);
  cursor: pointer;
}

.cmd-filters-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  overflow-x: auto;
}

.cmd-filter-chip {
  padding: 4px 12px;
  border-radius: var(--radius-full);
  background: var(--surface);
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
}

.cmd-filter-chip:hover {
  border-color: var(--brand-blue);
  color: var(--text-primary);
}

.cmd-filter-chip.active {
  background: var(--brand-blue);
  color: #ffffff;
  border-color: var(--brand-blue);
}

.cmd-results-list {
  flex: 1;
  overflow-y: auto;
  max-height: 420px;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cmd-result-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.cmd-result-item:hover,
.cmd-result-item.selected {
  background: var(--surface-hover);
  border-color: var(--border-subtle);
}

.cmd-result-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.cmd-result-icon {
  font-size: 1.2rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.cmd-result-icon svg {
  width: 22px;
  height: 15px;
  border-radius: 3px;
  vertical-align: middle;
  display: inline-block;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.cmd-result-title {
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--text-primary);
}

.cmd-result-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.cmd-result-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--brand-blue);
}

.cmd-footer-hints {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 10px 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
  font-size: 0.74rem;
  color: var(--text-muted);
}

.cmd-hint-item span {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-primary);
}

/* قسم البطل المميز المؤسسي (Engineering Command Deck Hero) */
.hero {
  position: relative;
  background: radial-gradient(circle at 10% 20%, rgba(37, 99, 235, 0.16) 0%, transparent 45%),
              radial-gradient(circle at 90% 80%, rgba(217, 119, 6, 0.12) 0%, transparent 40%),
              linear-gradient(160deg, #050b17 0%, #0c1830 50%, #060e1d 100%);
  color: #ffffff;
  padding: 44px 0 38px;
  overflow: hidden;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  background-image: 
    linear-gradient(to right, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 36px 36px;
  pointer-events: none;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.28fr) minmax(0, 0.72fr);
  gap: 40px;
  align-items: center;
  position: relative;
  z-index: 2;
  width: min(1380px, calc(100% - 64px));
  max-width: 100%;
  margin-inline: auto;
  padding-inline: 24px;
  box-sizing: border-box;
}

.hero-grid > div {
  min-width: 0;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 12px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  color: #e2e8f0;
  margin-bottom: 12px;
  backdrop-filter: blur(10px);
}

.hero-tag span {
  color: var(--brand-gold);
}

.hero-title {
  font-size: clamp(1.8rem, 3.4vw, 2.7rem);
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: -0.8px;
  margin-bottom: 12px;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: normal;
}

.hero-title .gradient-text {
  background: linear-gradient(135deg, #60a5fa 0%, #f59e0b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  font-size: 0.98rem;
  color: #94a3b8;
  width: 100%;
  max-width: 640px;
  line-height: 1.6;
  margin-bottom: 22px;
  box-sizing: border-box;
  overflow-wrap: break-word;
  word-break: break-word;
}

/* شريط البحث المطور المؤسسي */
.hero-search-box {
  position: relative;
  width: 100%;
  max-width: 740px;
  box-sizing: border-box;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.35);
  border-radius: var(--radius-md);
}

.hero-search-input {
  width: 100%;
  height: 58px;
  padding-block: 0;
  padding-inline-start: 54px;
  padding-inline-end: 140px;
  font-size: 1rem;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.98);
  color: #0f172a;
  outline: none;
  transition: all var(--transition-normal);
}

[data-theme="dark"] .hero-search-input {
  background: #0d172a;
  color: #f8fafc;
  border-color: #223458;
}

.hero-search-input:focus {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.25);
}

.hero-search-icon {
  position: absolute;
  inset-inline-start: 20px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 1.3rem;
  color: var(--text-muted);
  pointer-events: none;
}

.hero-search-btn {
  position: absolute;
  inset-inline-end: 6px;
  top: 6px;
  height: 46px;
  padding: 0 20px;
  background: linear-gradient(135deg, var(--brand-blue), #1d4ed8);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.hero-search-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.4);
}

/* الكلمات المفتاحية الأكثر طلباً */
.quick-tags {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 14px;
  font-size: 0.8rem;
  color: #94a3b8;
}

.quick-tag-chip {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #e2e8f0;
  padding: 4px 11px;
  border-radius: var(--radius-full);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 600;
  transition: all var(--transition-fast);
}

.quick-tag-chip:hover {
  background: var(--brand-blue);
  border-color: var(--brand-blue);
  color: #ffffff;
  transform: translateY(-1px);
}

/* لوحة الإحصائيات الهندسية المباشرة بالهيرو */
.hero-glass-panel {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-xl);
  padding: 30px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
}

.panel-header-badge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}

.panel-header-badge h3 {
  font-size: 1.1rem;
  font-weight: 800;
  color: #ffffff;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 14px;
}

.stat-item {
  background: rgba(5, 12, 26, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: var(--radius-md);
  padding: 16px;
  transition: transform var(--transition-fast);
}

.stat-item:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}

.stat-item b {
  display: block;
  font-size: 1.85rem;
  font-family: var(--font-latin);
  font-weight: 800;
  color: #ffffff;
  line-height: 1.1;
  margin-bottom: 4px;
}

.stat-item span {
  font-size: 0.78rem;
  color: #94a3b8;
  font-weight: 600;
}

.hero-highlight-card {
  margin-top: 16px;
  background: linear-gradient(135deg, rgba(217, 119, 6, 0.14), rgba(37, 99, 235, 0.08));
  border: 1px solid rgba(217, 119, 6, 0.25);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  font-size: 0.82rem;
  color: #fde68a;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.hero-highlight-card .icon {
  font-size: 1.2rem;
  flex-shrink: 0;
}

/* محتوى التطبيق الرئيسي والأقسام */
main {
  flex: 1;
  padding: 44px 0 80px;
}

.section-container {
  margin-bottom: 56px;
}

.section-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 16px;
}

.section-title-wrap h2 {
  font-size: 1.65rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-title-wrap p {
  color: var(--text-muted);
  font-size: 0.92rem;
  margin-top: 4px;
}

/* شبكات الدول والتخصصات */
.regions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.region-item {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 20px 16px;
  cursor: pointer;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
  text-align: right;
}

.region-item::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 4px;
  height: 100%;
  background: transparent;
  transition: background var(--transition-fast);
}

.region-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
  border-color: var(--brand-blue);
}

.region-item:hover::before {
  background: var(--brand-blue);
}

.region-item.active {
  border-color: var(--brand-blue);
  background: var(--surface-hover);
}

.region-item.active::before {
  background: var(--brand-gold);
}

.region-flag {
  font-size: 2rem;
  margin-bottom: 12px;
  display: block;
}

.region-name {
  font-size: 1.05rem;
  font-weight: 800;
  color: var(--text-primary);
}

.region-en {
  font-size: 0.76rem;
  color: var(--text-muted);
  font-family: var(--font-latin);
}

.region-count {
  position: absolute;
  top: 14px;
  left: 14px;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 3px 8px;
  border-radius: var(--radius-full);
  background: var(--bg-secondary);
  color: var(--text-secondary);
}

.disciplines-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
}

.discipline-item {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 16px 12px;
  text-align: center;
  cursor: pointer;
  transition: all var(--transition-normal);
}

.discipline-item:hover {
  border-color: var(--brand-blue);
  transform: translateY(-3px);
  box-shadow: var(--shadow-sm);
}

.discipline-item.active {
  background: var(--surface-hover);
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 2px var(--brand-blue-glow);
}

.discipline-icon {
  font-size: 1.6rem;
  margin-bottom: 6px;
  display: block;
}

.discipline-name {
  font-size: 0.88rem;
  font-weight: 700;
  display: block;
}

.discipline-count {
  font-size: 0.72rem;
  color: var(--text-muted);
}

/* دليل الأكواد - شبكة التقسيم (Sidebar + Content) */
.catalog-layout {
  display: grid;
  grid-template-columns: 290px 1fr;
  gap: 24px;
  align-items: flex-start;
}

.catalog-sidebar {
  position: sticky;
  top: 96px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.catalog-sidebar h3 {
  font-size: 1.08rem;
  font-weight: 800;
  margin-bottom: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.filter-group {
  padding: 14px 0;
  border-top: 1px solid var(--border-subtle);
}

.filter-group:first-of-type {
  border-top: none;
  padding-top: 0;
}

.filter-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-secondary);
  margin-bottom: 8px;
}

.filter-select, .filter-input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  background: var(--bg-primary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  color: var(--text-primary);
  outline: none;
  transition: border var(--transition-fast);
}

.filter-select:focus, .filter-input:focus {
  border-color: var(--brand-blue);
}

.filter-checkbox-label {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.86rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  margin: 10px 0;
  user-select: none;
}

.filter-checkbox-label input {
  width: 17px;
  height: 17px;
  cursor: pointer;
  accent-color: var(--brand-blue);
}

/* تذييل الصفحة الفاخر */
.app-footer {
  background: var(--brand-navy);
  color: #94a3b8;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding: 50px 0 30px;
  font-size: 0.88rem;
}

.footer-top {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 40px;
  margin-bottom: 40px;
}

.footer-brand h4 {
  font-size: 1.25rem;
  font-weight: 900;
  color: #ffffff;
  margin-bottom: 12px;
}

.footer-brand p {
  line-height: 1.7;
  max-width: 480px;
  font-size: 0.85rem;
}

.footer-col h5 {
  font-size: 0.95rem;
  font-weight: 800;
  color: #ffffff;
  margin-bottom: 14px;
}

.footer-col ul {
  list-style: none;
  display: grid;
  gap: 10px;
}

.footer-col a:hover {
  color: #ffffff;
}

.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  padding-top: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 0.8rem;
  flex-wrap: wrap;
  gap: 14px;
}

/* ===================================================================
   إعلان AdSense المتجاوب — تطبيق إرشادات Google الرسمية (answer/10762946)
   =================================================================== */
.header-ad-banner {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 14px auto;
  padding: 0 16px;
  text-align: center;
  width: 100%;
  max-width: 1200px;
  box-sizing: border-box;
  overflow: hidden;
}

ins.adsbygoogle {
  display: block;
  min-width: 0 !important;
  max-width: 100% !important;
  box-sizing: border-box !important;
}

/* إرشادات Google AdSense الرسمية (answer/10762946): إخفاء الوحدات غير المعبأة فقط عند تأكيد حالتها من خوادم AdSense */
ins.adsbygoogle[data-ad-status="unfilled"] {
  display: none !important;
}

/* طي الحاوية فقط عند تأكيد عدم توفر إعلان أو عند حجب الإعلان بواسطة المتصفح */
.header-ad-banner:has(ins.adsbygoogle[data-ad-status="unfilled"]),
.header-ad-banner:has(ins.adsbygoogle[style*="display: none"]),
.header-ad-banner:has(ins.adsbygoogle[style*="display:none"]) {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
  height: 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
}

/* التجاوب (Media Queries) */
@media (max-width: 1080px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .hero-glass-panel {
    display: none;
  }
  .catalog-layout {
    grid-template-columns: 1fr;
  }
  .catalog-sidebar {
    position: static;
  }
  .footer-top {
    grid-template-columns: 1fr 1fr;
  }
}

/* ===================================================================
   التجاوب والتهيؤ للأجهزة اللوحية والمحمولة (Responsive Engine)
   =================================================================== */

/* 1. الشاشات المتوسطة والأجهزة اللوحية الأفقية (Tablet Landscape ≤ 1100px) */
@media (max-width: 1100px) {
  .hero-grid {
    grid-template-columns: 1fr;
    gap: 32px;
  }
  .hero-glass-panel {
    display: none;
  }
  .catalog-layout {
    grid-template-columns: 1fr;
  }
  .catalog-sidebar {
    position: static;
  }
  .footer-top {
    grid-template-columns: 1fr 1fr;
  }
  .enterprise-nav-dock {
    gap: 2px;
    padding: 3px 6px;
  }
  .nav-tab-btn {
    padding: 6px 10px;
    font-size: 0.8rem;
  }
  .cmd-label,
  .cmd-shortcut {
    display: none;
  }
  .header-cmd-btn {
    padding: 0 10px;
    width: 38px;
    justify-content: center;
  }
  .header-center-search {
    display: none !important;
  }
}

/* ===================================================================
   النظام المتجاوب المتكامل الفاخر للأجهزة اللوحية والمحمولة (Mobile & Tablet)
   =================================================================== */

/* 1. القواعد العامة للهواتف المحمولة (Mobile Devices ≤ 768px) */
@media (max-width: 768px) {
  body {
    padding-bottom: calc(68px + env(safe-area-inset-bottom, 0px));
  }

  /* إخفاء شريط الإعلانات والبيانات العلوي في الهواتف لمنح الشاشة للهيدر */
  .topbar {
    display: none !important;
  }

  /* الهيدر المطور المخصص للهواتف المحمولة (Dedicated Mobile Header) */
  .enterprise-header {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  }

  .header-level-1 {
    height: 60px;
  }

  .level-1-container {
    width: 100%;
    padding-inline: 12px;
    gap: 8px;
    justify-content: space-between;
  }

  /* الهوية البرمجية والشعار في الموبايل */
  .brand-wrapper {
    gap: 8px;
    max-width: calc(100% - 134px);
    flex-shrink: 1;
  }

  .brand-logo-container,
  .brand-logo-svg {
    width: 36px;
    height: 36px;
    border-radius: 9px;
    flex-shrink: 0;
  }

  .brand-text {
    overflow: hidden;
    gap: 0;
  }

  .brand-title-row {
    gap: 5px;
    overflow: hidden;
  }

  .brand-title {
    font-size: 0.94rem;
    line-height: 1.2;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* إظهار العنوان المختصر في الشاشات الصغيرة وإخفاء الكامل لتفادي الانكسار */
  .brand-topic-full {
    display: none !important;
  }

  .brand-topic-mobile {
    display: inline !important;
  }

  .brand-from {
    font-size: 0.82em;
    margin-inline: 1px;
  }

  .brand-version-badge {
    display: none !important; /* معروضة بفخامة داخل درج الهاتف */
  }

  .brand-subtitle {
    display: none !important;
  }

  /* محرك البحث المركزي المكتبي مخفي في الهيدر */
  .header-center-search {
    display: none !important;
  }

  /* أدوات التحكم المدمجة في الهيدر */
  .header-utility-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
  }

  .mobile-search-btn {
    display: flex !important;
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 9px;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.16);
    color: #38bdf8;
    font-size: 1.2rem;
    cursor: pointer;
    touch-action: manipulation;
  }

  .mobile-search-btn:active {
    background: rgba(56, 189, 248, 0.2);
    transform: scale(0.96);
  }

  .lang-toggle-btn {
    height: 38px;
    min-width: 38px;
    padding: 0 8px;
    border-radius: 9px;
    font-size: 0.76rem;
    font-weight: 800;
  }

  .lang-desktop-label {
    display: none !important;
  }

  .lang-mobile-label {
    display: inline !important;
  }

  .theme-toggle-btn {
    display: none !important; /* معروض بزر مخصص في درج التنقل */
  }

  .mobile-menu-btn {
    display: flex !important;
    width: 38px;
    height: 38px;
    min-width: 38px;
    border-radius: 9px;
    align-items: center;
    justify-content: center;
  }

  /* شريط المستوى الثاني والقائمة العملاقة لا تظهر على الموبايل (يستعاض عنها بدرج الهاتف) */
  .header-level-2 {
    display: none !important;
  }

  .mega-menu-panel {
    display: none !important;
  }

  /* قسم البطل المتطور للهواتف الذكية (Mobile Engineering Hero) */
  .hero {
    padding: 22px 0 18px 0;
    margin-top: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }

  /* ضمان احتواء الحاويات الرئيسية وهيكل الهيرو بهوامش متناسقة عبر كافة مقاسات الهواتف */
  .container,
  .container.hero-grid {
    width: calc(100% - 32px);
    max-width: 100%;
    margin-inline: auto;
    box-sizing: border-box;
    padding-inline: 0;
  }

  .hero-grid {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
    box-sizing: border-box;
    margin-inline: auto;
  }

  .hero-grid > div {
    min-width: 0;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
  }

  .hero-tag {
    font-size: 0.72rem;
    padding: 3px 10px;
    margin-bottom: 8px;
    max-width: 100%;
    box-sizing: border-box;
    white-space: normal;
    line-height: 1.35;
  }

  .hero-title {
    font-size: clamp(1.35rem, 4.6vw, 1.75rem);
    line-height: 1.34;
    letter-spacing: normal;
    margin-bottom: 12px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    text-wrap: balance;
    text-align: start;
  }

  .hero-subtitle {
    font-size: clamp(0.82rem, 2.4vw, 0.92rem);
    line-height: 1.5;
    margin-bottom: 16px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    word-break: normal;
    overflow-wrap: break-word;
    text-wrap: pretty;
    text-align: start;
    color: #94a3b8;
  }

  /* شريط البحث الميداني الكامل العرض بالهيرو */
  .hero-search-box {
    position: relative;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
    border-radius: 12px;
  }

  .hero-search-input {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    height: 48px;
    font-size: 0.86rem;
    padding-block: 0;
    padding-inline-start: 42px;
    padding-inline-end: 48px;
    border-radius: 12px;
    text-overflow: ellipsis;
  }

  .hero-search-icon {
    position: absolute;
    inset-inline-start: 13px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.15rem;
    pointer-events: none;
    z-index: 2;
  }

  .hero-search-btn {
    position: absolute;
    inset-inline-end: 5px;
    top: 5px;
    width: 38px;
    height: 38px;
    padding: 0;
    border-radius: 8px;
    justify-content: center;
    align-items: center;
    display: flex;
    z-index: 2;
  }

  .hero-search-btn .search-btn-text {
    display: none !important;
  }

  .hero-search-btn .search-btn-icon {
    display: inline-block !important;
    font-size: 1.15rem;
    font-weight: 900;
  }

  .autocomplete-dropdown {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
  }

  /* وسوم الأكواد الأكثر طلباً: شريط تمرير أفقي انسيابي بحاوية مقيدة ومؤشر تدرج */
  .quick-tags {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 7px;
    padding-block: 4px;
    padding-inline: 2px 16px;
    margin-top: 10px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
    mask-image: linear-gradient(to left, transparent 0%, black 16px, black calc(100% - 16px), black 100%);
    -webkit-mask-image: linear-gradient(to left, transparent 0%, black 16px, black calc(100% - 16px), black 100%);
  }

  [dir="ltr"] .quick-tags {
    mask-image: linear-gradient(to right, transparent 0%, black 16px, black calc(100% - 16px), black 100%);
    -webkit-mask-image: linear-gradient(to right, transparent 0%, black 16px, black calc(100% - 16px), black 100%);
  }

  .quick-tags::-webkit-scrollbar {
    display: none;
  }

  .quick-tag-chip {
    flex-shrink: 0;
    white-space: nowrap;
    min-width: max-content;
  }

  #popularSearchLabel {
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 700;
    color: #94a3b8;
    align-self: center;
    white-space: nowrap;
  }

  .quick-tag-chip {
    flex-shrink: 0;
    white-space: nowrap;
    font-size: 0.74rem;
    padding: 4px 10px;
    border-radius: 20px;
  }

  /* بطاقة إحصائيات الهيرو على الهواتف: شريط تلخيص أفقي فائق الدقة */
  .hero-glass-panel {
    padding: 12px 14px;
    border-radius: 12px;
    margin-top: 0;
    background: rgba(255, 255, 255, 0.04);
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    min-width: 0;
  }

  .panel-header-badge {
    margin-bottom: 8px;
  }

  .panel-header-badge h3 {
    font-size: 0.86rem;
  }

  .panel-header-badge .badge {
    font-size: 0.65rem;
    padding: 2px 6px;
  }

  .stats-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    width: 100%;
    box-sizing: border-box;
  }

  .stat-item {
    padding: 4px 2px;
    text-align: center;
    min-width: 0;
    overflow: hidden;
  }

  .stat-item b {
    font-size: 1.05rem;
    line-height: 1.2;
  }

  .stat-item span {
    font-size: 0.6rem;
    line-height: 1.2;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .hero-highlight-card {
    display: none;
  }

  /* مسار الفتات وإعلان الهيدر بعد الهيرو */
  .breadcrumbs-container {
    margin-top: 6px;
    margin-bottom: 0;
    width: 100%;
    box-sizing: border-box;
  }

  .breadcrumbs-bar {
    padding: 6px 0 10px;
    font-size: 0.78rem;
    width: 100%;
    box-sizing: border-box;
    overflow-x: auto;
    white-space: nowrap;
  }

  /* إعلان الهيدر المتجاوب على شاشات الهواتف المحمولة */
  .header-ad-banner {
    margin: 10px auto;
    padding: 0 12px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* بوابات الوصول السريع */
  .quick-access-section {
    margin: 14px 0 16px;
    width: 100%;
    box-sizing: border-box;
  }

  .quick-access-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .quick-card {
    padding: 12px 10px;
    border-radius: 12px;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    word-break: break-word;
  }

  .quick-card-icon-wrap {
    width: 36px;
    height: 36px;
    margin-bottom: 8px;
    border-radius: 8px;
    flex-shrink: 0;
  }

  .quick-card-icon {
    font-size: 1.15rem;
  }

  .quick-card-title {
    font-size: 0.88rem;
    margin-bottom: 4px;
    line-height: 1.3;
  }

  .quick-card-desc {
    font-size: 0.72rem;
    margin-bottom: 8px;
    line-height: 1.35;
  }

  .quick-card-arrow {
    font-size: 0.78rem;
  }

  /* رؤوس الأقسام والفلاتر في الموبايل */
  .section-container {
    margin-bottom: 36px;
    width: 100%;
    box-sizing: border-box;
  }

  .section-head {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-subtle);
    width: 100%;
    box-sizing: border-box;
  }

  .section-head .btn {
    align-self: flex-start;
    max-width: 100%;
    white-space: normal;
  }

  .section-title-wrap {
    width: 100%;
    max-width: 100%;
  }

  .section-title-wrap h2 {
    font-size: clamp(1.15rem, 4.4vw, 1.45rem);
    line-height: 1.35;
    flex-wrap: wrap;
    word-break: break-word;
  }

  .section-title-wrap p {
    font-size: 0.82rem;
    line-height: 1.45;
  }

  /* شبكات الدول والتخصصات المتجاوبة */
  .regions-grid {
    grid-template-columns: repeat(auto-fill, minmax(135px, 1fr));
    gap: 10px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .region-item {
    padding: 14px 12px;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    word-break: break-word;
  }

  .disciplines-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 8px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .discipline-item {
    padding: 12px 8px;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    word-break: break-word;
  }

  /* دليل الأكواد والشريط الجانبي */
  .catalog-layout {
    grid-template-columns: minmax(0, 1fr);
    gap: 18px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .catalog-sidebar {
    position: static;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    padding: 18px 16px;
  }

  .code-card {
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
    word-break: break-word;
    overflow-wrap: break-word;
    padding: 18px 14px;
  }

  .code-card-header {
    flex-wrap: wrap;
    gap: 8px;
  }

  .code-badges-wrap {
    flex-wrap: wrap;
    gap: 6px;
  }

  .code-card-meta {
    flex-wrap: wrap;
    gap: 6px;
    word-break: break-word;
    font-size: 0.8rem;
  }

  /* مصفوفة المقارنة الفنية والجداول */
  .comparison-matrix-card {
    padding: 14px 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    box-sizing: border-box;
  }

  .matrix-table {
    min-width: 580px;
  }

  /* حواسب وأدوات الهندسة على الهواتف */
  .calculators-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 14px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .calc-card {
    padding: 16px 14px;
    min-width: 0;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }

  .calc-header {
    flex-wrap: wrap;
  }

  .form-group input,
  .form-group select {
    min-height: 44px;
    font-size: 0.94rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  /* الجداول الفنية */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    margin-bottom: 12px;
  }

  /* شريط التثبيت السفلي للهاتف */
  .mobile-bottom-dock {
    display: flex !important;
    height: 60px;
    padding-bottom: max(4px, env(safe-area-inset-bottom, 0px));
  }

  .footer-top {
    grid-template-columns: 1fr;
    gap: 20px;
  }
}

/* 2. الهواتف الصغيرة جداً (Compact Devices ≤ 360px) */
@media (max-width: 360px) {
  .container,
  .container.hero-grid {
    width: calc(100% - 20px);
  }

  .hero-title {
    font-size: 1.28rem;
    line-height: 1.34;
  }

  .level-1-container {
    padding-inline: 8px;
    gap: 4px;
  }

  .header-utility-controls {
    gap: 4px;
  }

  .mobile-search-btn,
  .mobile-menu-btn {
    width: 34px;
    height: 34px;
    min-width: 34px;
  }

  .lang-toggle-btn {
    height: 34px;
    min-width: 34px;
    padding: 0 6px;
  }

  .brand-wrapper {
    gap: 6px;
    max-width: calc(100% - 116px);
  }

  .brand-logo-container,
  .brand-logo-svg {
    width: 30px;
    height: 30px;
  }

  .brand-title {
    font-size: 0.82rem;
  }

  .quick-access-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .regions-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .disciplines-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 6px;
  }
}

/* 3. اختبار الشاشات الضيقة للغاية (Narrow Stress Test ≤ 280px) */
@media (max-width: 280px) {
  .container,
  .container.hero-grid {
    width: calc(100% - 12px);
  }

  .hero-title {
    font-size: 1.05rem;
    line-height: 1.35;
  }

  .brand-title {
    font-size: 0.76rem;
  }

  .regions-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .disciplines-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .stats-grid {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* ===================================================================
   تحسينات التخطيط والأدوات والتجاوب (UI/UX Precision Layout System)
   =================================================================== */

/* وضع الأدوات المباشر: طي الهيرو وبوابات الوصول والإعلان ودليل الهبوط لتسريع التفاعل والوصول للنتائج */
body.in-tool-view #mainHeroSection,
body.in-tool-view #quickAccessSection,
body.in-tool-view #mainHeaderAdBanner,
body.in-tool-view #landingGuideSection {
  display: none !important;
}

/* تعويض شريط التثبيت السفلي على الجوال لمنع تغطية المحتوى */
@media (max-width: 1024px) {
  main, .app-main, body {
    padding-bottom: calc(76px + env(safe-area-inset-bottom, 0px));
  }
}

/* أبعاد وضبط حاويات الإعلانات المتجاوبة وتجنب الفراغات الزائدة */
.header-ad-banner {
  min-height: 0;
  max-width: 1200px;
  width: 100%;
  margin: 14px auto;
  box-sizing: border-box;
}

.header-ad-banner:empty {
  display: none !important;
  margin: 0 !important;
  padding: 0 !important;
  height: 0 !important;
}

/* مواءمة فلاتر الدول بين الجوال والكمبيوتر */
.regions-mobile-select-wrap {
  display: none;
  margin-bottom: 16px;
}

.regions-mobile-select-wrap select {
  width: 100%;
  height: 46px;
  background: var(--surface-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.95rem;
  font-weight: 700;
  padding: 0 16px;
  box-sizing: border-box;
  outline: none;
  transition: border-color var(--transition-fast);
}

.regions-mobile-select-wrap select:focus {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

@media (max-width: 768px) {
  .regions-mobile-select-wrap {
    display: block !important;
  }
  .regions-grid {
    display: none !important;
  }
}

@media (min-width: 769px) {
  .regions-mobile-select-wrap {
    display: none !important;
  }
  .regions-grid {
    display: grid !important;
  }
}

/* شريط تحكم فلاتر الجوال لدليل الأكواد */
.catalog-mobile-controls {
  display: none;
  margin-bottom: 20px;
}

@media (max-width: 1024px) {
  .catalog-sidebar {
    display: none !important;
  }

  .catalog-mobile-controls {
    display: block !important;
  }
}

@media (min-width: 1025px) {
  .catalog-sidebar {
    display: block !important;
  }

  .catalog-mobile-controls {
    display: none !important;
  }
}

.mobile-search-filter-row,
.mobile-search-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.mobile-filter-search-box,
.mobile-search-input-wrap {
  position: relative;
  flex: 1;
  min-width: 0;
}

.mfs-input,
.mobile-search-input-wrap input {
  width: 100%;
  height: 44px;
  padding: 0 40px 0 14px;
  background: var(--surface-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.92rem;
  box-sizing: border-box;
  outline: none;
  transition: border-color var(--transition-fast);
}

.mfs-input:focus,
.mobile-search-input-wrap input:focus {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

[dir="rtl"] .mfs-input,
[dir="rtl"] .mobile-search-input-wrap input {
  padding: 0 14px 0 40px;
}

.mfs-icon,
.mobile-search-input-wrap .search-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
  font-size: 1rem;
}

[dir="rtl"] .mfs-icon,
[dir="rtl"] .mobile-search-input-wrap .search-icon {
  left: 14px;
  right: auto;
}

[dir="ltr"] .mfs-icon,
[dir="ltr"] .mobile-search-input-wrap .search-icon {
  right: 14px;
  left: auto;
}

.mobile-filter-btn,
.btn-open-mobile-filters {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 44px;
  min-width: 44px;
  padding: 0 16px;
  background: var(--surface-card);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all var(--transition-fast);
  user-select: none;
}

.mobile-filter-btn:hover,
.btn-open-mobile-filters:hover {
  border-color: var(--brand-blue);
  background: var(--surface-hover);
}

.active-filters-badge,
.filter-badge-counter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--brand-blue);
  color: #fff;
  font-size: 0.72rem;
  font-weight: 800;
}

.mobile-results-info-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* شارات الفلاتر النشطة */
.active-filter-chips-container {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
}

.active-filter-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.3);
  border-radius: 999px;
  color: var(--brand-blue);
  font-size: 0.8rem;
  font-weight: 700;
}

.chip-remove-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: none;
  background: rgba(56, 189, 248, 0.2);
  color: var(--brand-blue);
  cursor: pointer;
  font-size: 0.75rem;
  line-height: 1;
  padding: 0;
  transition: background var(--transition-fast);
}

.chip-remove-btn:hover {
  background: var(--brand-rose);
  color: #fff;
}

.btn-clear-chips {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  text-decoration: underline;
  padding: 4px 6px;
}

.btn-clear-chips:hover {
  color: var(--brand-rose);
}

/* نافذة فلاتر الجوال المنبثقة (Bottom Sheet Modal) */
.mobile-filters-modal {
  border: none;
  padding: 0;
  background: transparent;
  width: 100%;
  max-width: 480px;
  margin: auto auto 0 auto;
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  box-shadow: var(--shadow-xl);
  overflow: hidden;
}

@media (min-width: 769px) {
  .mobile-filters-modal {
    margin: auto;
    border-radius: var(--radius-xl);
  }
}

.mobile-filters-modal::backdrop {
  background: rgba(3, 7, 18, 0.75);
  backdrop-filter: blur(8px);
}

.mobile-filters-sheet,
.mobile-filters-modal-dialog {
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-medium);
  border-radius: inherit;
  max-height: 85vh;
  box-sizing: border-box;
}

.sheet-header,
.mobile-filters-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  background: var(--surface-card);
}

.sheet-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sheet-title-group h3,
.mobile-filters-header h3 {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0;
  color: var(--text-primary);
}

.sheet-close-btn,
.mobile-filters-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 1.2rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.sheet-close-btn:hover,
.mobile-filters-close-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

.sheet-body,
.mobile-filters-body {
  padding: 20px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  -webkit-overflow-scrolling: touch;
  background: var(--surface);
}

.sheet-footer,
.mobile-filters-footer {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-top: 1px solid var(--border-subtle);
  background: var(--surface-card);
}

.sheet-footer button,
.mobile-filters-footer button {
  flex: 1;
  height: 44px;
}

/* تحسينات لوحة الأوامر (Command Palette) */
.cmd-close-btn {
  position: static;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--surface-card);
  color: var(--text-muted);
  font-size: 1.15rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
  padding: 0;
}

.cmd-close-btn:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
  border-color: var(--border-medium);
}

@media (max-width: 768px) {
  .cmd-esc-badge {
    display: none !important;
  }
}

.cmd-filters-wrapper {
  position: relative;
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: var(--border-medium) transparent;
}

.cmd-filters-wrapper::-webkit-scrollbar {
  height: 4px;
  display: block;
}

.cmd-filters-wrapper::-webkit-scrollbar-track {
  background: transparent;
}

.cmd-filters-wrapper::-webkit-scrollbar-thumb {
  background: var(--border-medium);
  border-radius: 4px;
}

.cmd-filters-scroll {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  min-width: max-content;
}

.cmd-hints-desktop {
  display: flex;
  align-items: center;
  gap: 14px;
}

.cmd-hints-mobile {
  display: none;
  font-size: 0.8rem;
  color: var(--text-muted);
}

@media (max-width: 768px) {
  dialog.command-palette-modal {
    width: calc(100% - 24px) !important;
    max-width: calc(100% - 24px) !important;
    margin: 16px auto !important;
  }
  .cmd-search-header {
    padding: 12px 14px !important;
    gap: 8px !important;
  }
  .cmd-input {
    font-size: 0.95rem !important;
  }
  .cmd-hints-desktop {
    display: none !important;
  }
  .cmd-hints-mobile {
    display: flex !important;
    align-items: center;
    gap: 12px;
  }
}


