/* ===================================================================
   أطلس كودات البناء العالمية - مكونات الواجهة (UI Components)
   =================================================================== */

/* ===================================================================
   نظام الأزرار الهندسية المتقدم (Enterprise Engineering Button System)
   =================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border-radius: var(--radius-sm);
  font-family: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  border: 1px solid var(--border-medium);
  background: var(--surface);
  color: var(--text-primary);
  transition: all var(--transition-fast);
  user-select: none;
  white-space: nowrap;
  text-decoration: none;
  position: relative;
  overflow: hidden;
}

.btn:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}

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

.btn:active {
  transform: translateY(0) scale(0.985);
}

.btn[disabled],
.btn.disabled {
  opacity: 0.55;
  cursor: not-allowed;
  pointer-events: none;
  box-shadow: none;
  transform: none;
}

/* 1. الإجراء الأساسي (Primary Action) */
.btn-primary {
  background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
  color: #ffffff !important;
  border-color: #1e3a8a;
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.25);
}

[data-theme="dark"] .btn-primary {
  background: linear-gradient(135deg, #0284c7 0%, #1e40af 100%);
  border-color: #0284c7;
  box-shadow: 0 4px 16px rgba(2, 132, 199, 0.35);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1e3a8a 100%);
  border-color: #2563eb;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.45);
  color: #ffffff !important;
}

/* 2. الإجراء الثانوي (Secondary Action) */
.btn-secondary {
  background: var(--bg-secondary);
  border-color: var(--border-medium);
  color: var(--text-secondary);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  border-color: var(--border-strong);
  color: var(--text-primary);
}

/* 3. الإجراء الثلاثي (Tertiary Action) */
.btn-tertiary {
  background: transparent;
  border-color: transparent;
  color: var(--text-muted);
}

.btn-tertiary:hover {
  background: var(--bg-secondary);
  border-color: var(--border-subtle);
  color: var(--text-primary);
}

/* 4. الإجراء ذو الإطار (Outline Action) */
.btn-outline {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-primary);
}

.btn-outline:hover {
  background: rgba(37, 99, 235, 0.06);
  border-color: var(--brand-blue);
  color: var(--brand-blue);
}

[data-theme="dark"] .btn-outline:hover {
  background: rgba(56, 189, 248, 0.08);
  border-color: var(--brand-cyan);
  color: var(--brand-cyan);
}

/* 5. الإجراء الشفاف (Ghost Action) */
.btn-ghost {
  background: transparent;
  border-color: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: var(--surface-hover);
  color: var(--text-primary);
}

/* 6. إجراء الحذف / الإعادة (Destructive / Reset Action) */
.btn-destructive {
  background: rgba(225, 29, 72, 0.08);
  border-color: rgba(225, 29, 72, 0.3);
  color: #e11d48;
}

.btn-destructive:hover {
  background: #e11d48;
  border-color: #be123c;
  color: #ffffff !important;
  box-shadow: 0 4px 14px rgba(225, 29, 72, 0.3);
}

/* 7. إجراءات الحواسب والحساب الهندسي (Contextual Engineering Calc) */
.btn-engineering-calc {
  background: linear-gradient(135deg, #0284c7 0%, #0369a1 100%);
  color: #ffffff !important;
  border-color: #0284c7;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(2, 132, 199, 0.3);
}

.btn-engineering-calc:hover {
  background: linear-gradient(135deg, #0369a1 0%, #075985 100%);
  box-shadow: 0 6px 18px rgba(2, 132, 199, 0.45);
  color: #ffffff !important;
}

/* 8. إجراء مدقق المطابقة (Contextual Compliance Check) */
.btn-engineering-check {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  color: #ffffff !important;
  border-color: #059669;
  font-weight: 800;
  box-shadow: 0 4px 14px rgba(5, 150, 105, 0.3);
}

.btn-engineering-check:hover {
  background: linear-gradient(135deg, #047857 0%, #065f46 100%);
  box-shadow: 0 6px 18px rgba(5, 150, 105, 0.45);
  color: #ffffff !important;
}

/* 9. إجراء التصدير والطباعة (Contextual Export & Reports) */
.btn-engineering-export {
  background: linear-gradient(135deg, #334155 0%, #1e293b 100%);
  color: #ffffff !important;
  border-color: #475569;
  font-weight: 700;
  box-shadow: 0 4px 14px rgba(30, 41, 59, 0.25);
}

.btn-engineering-export:hover {
  background: linear-gradient(135deg, #475569 0%, #334155 100%);
  color: #ffffff !important;
}

/* 10. الزر الذهبي المميز (Premium Gold Highlight) */
.btn-gold {
  background: linear-gradient(135deg, #d97706 0%, #b45309 100%);
  color: #ffffff !important;
  border-color: #b45309;
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.3);
}

.btn-gold:hover {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  box-shadow: 0 6px 18px rgba(217, 119, 6, 0.45);
  color: #ffffff !important;
}

/* 11. أحجام الأزرار المعتمدة */
.btn-sm {
  min-height: 36px;
  height: 36px;
  padding: 0 14px;
  font-size: 0.82rem;
  border-radius: var(--radius-sm);
}

.btn-toolbar {
  min-height: 34px;
  height: 34px;
  padding: 0 12px;
  font-size: 0.78rem;
  font-weight: 700;
  border-radius: var(--radius-xs);
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
}

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

/* 12. أزرار الأيقونات المفردة (Icon-only buttons: 44x44px Touch Target) */
.btn-icon {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  padding: 0;
  border-radius: var(--radius-sm);
  display: inline-grid;
  place-items: center;
  font-size: 1.25rem;
  line-height: 1;
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all var(--transition-fast);
  outline: none;
  user-select: none;
}

.btn-icon:focus-visible {
  outline: 2px solid var(--brand-blue);
  outline-offset: 2px;
}

.btn-icon:hover {
  background: var(--surface-hover);
  border-color: var(--brand-gold);
  color: var(--brand-gold);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(217, 119, 6, 0.25);
}

.btn-icon:active {
  transform: scale(0.92);
}

.btn-icon.active {
  color: #fbbf24;
  border-color: var(--brand-gold);
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(217, 119, 6, 0.12));
  box-shadow: 0 0 16px rgba(245, 158, 11, 0.35);
}

[data-theme="dark"] .btn-icon {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--border-medium);
  color: #94a3b8;
}

[data-theme="dark"] .btn-icon:hover {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--brand-gold);
  color: #fbbf24;
  box-shadow: 0 4px 16px rgba(245, 158, 11, 0.3);
}

[data-theme="dark"] .btn-icon.active {
  background: linear-gradient(135deg, rgba(245, 158, 11, 0.3), rgba(217, 119, 6, 0.18));
  border-color: var(--brand-gold);
  color: #fbbf24;
  box-shadow: 0 0 18px rgba(245, 158, 11, 0.4);
}

/* 13. المتحكم المقسم (Segmented Control) */
.segmented-control {
  display: inline-flex;
  align-items: center;
  padding: 3px;
  background: var(--bg-secondary);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  gap: 2px;
}

.segmented-item {
  padding: 6px 14px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.segmented-item:hover {
  color: var(--text-primary);
}

.segmented-item.active {
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-sm);
}

/* 14. حالة التحميل (Loading State) */
.btn-loading {
  position: relative;
  color: transparent !important;
  pointer-events: none;
}

.btn-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btnSpinner 0.6s linear infinite;
}

@keyframes btnSpinner {
  to {
    transform: rotate(360deg);
  }
}

/* الشارات والأوسمة (Badges & Pills) */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 0.74rem;
  font-weight: 700;
  background: var(--bg-secondary);
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
  line-height: 1.2;
}

.badge-current {
  background: rgba(5, 150, 105, 0.12);
  color: #059669;
  border-color: rgba(5, 150, 105, 0.25);
}

[data-theme="dark"] .badge-current {
  color: #34d399;
  background: rgba(16, 185, 129, 0.15);
}

.badge-transition {
  background: rgba(217, 119, 6, 0.12);
  color: #b45309;
  border-color: rgba(217, 119, 6, 0.25);
}

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

.badge-reference {
  background: rgba(37, 99, 235, 0.1);
  color: var(--brand-blue);
  border-color: rgba(37, 99, 235, 0.2);
}

.badge-pill-gold {
  background: rgba(217, 119, 6, 0.1);
  color: var(--brand-gold);
  border-color: rgba(217, 119, 6, 0.25);
}

/* بطاقة الكود (Engineering Code Card) */
.code-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transition: all var(--transition-normal);
  position: relative;
  overflow: hidden;
}

.code-card::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  width: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-blue), var(--brand-gold));
  transition: width var(--transition-normal);
}

.code-card:hover {
  transform: translateY(-3px);
  border-color: var(--brand-blue);
  box-shadow: var(--shadow-md);
}

.code-card:hover::after {
  width: 100%;
}

.code-card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

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

.code-title-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.code-card h3 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 8px;
}

.code-arabic-title {
  font-size: 1.02rem;
  font-weight: 700;
  color: var(--brand-blue);
}

.code-english-title {
  font-size: 0.84rem;
  color: var(--text-muted);
  font-family: var(--font-latin);
}

.code-card-summary {
  font-size: 0.9rem;
  color: var(--text-secondary);
  line-height: 1.65;
}

/* بطاقة المقتطفات السريعة في الكارد */
.code-excerpt-preview {
  background: var(--bg-primary);
  border: 1px dashed var(--border-medium);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.84rem;
  color: var(--text-muted);
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.code-excerpt-preview .icon {
  color: var(--brand-gold);
  font-size: 1.1rem;
}

.code-meta-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border-subtle);
}

.code-meta-tags {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 0.78rem;
  color: var(--text-muted);
}

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

/* النافذة التفصيلية المنبثقة المحسنة (Deep Dive Modal / Drawer) */
dialog.engineering-modal {
  width: min(960px, calc(100% - 28px));
  max-height: 88vh;
  margin: auto;
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-xl);
  background: var(--surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-xl);
  overflow: hidden;
  display: none;
  flex-direction: column;
}

dialog.engineering-modal[open] {
  display: flex;
}

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

.modal-header {
  padding: 20px 28px;
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-shrink: 0;
}

.modal-header-info {
  flex: 1;
}

.modal-header-info h2 {
  font-size: 1.35rem;
  font-weight: 800;
  line-height: 1.3;
  margin: 0;
  color: var(--text-primary);
}

.modal-header-info p {
  color: var(--brand-blue);
  font-size: 0.9rem;
  font-weight: 700;
  margin-top: 4px;
  margin-bottom: 0;
}

.modal-close-btn {
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  display: grid;
  place-items: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.modal-close-btn:hover {
  background: var(--brand-rose);
  color: #ffffff;
  border-color: var(--brand-rose);
}

/* حاوية المحتوى الداخلي للنافذة المنبثقة لضمان التدفق السليم للشريط والتبويبات */
#modalContent {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

/* تبويبات النافذة المنبثقة كشريط شريحي أنيق (Segmented Tabs) */
.modal-nav-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  background: #f1f5f9;
  border-bottom: 1px solid #cbd5e1;
  overflow-x: auto;
  flex-shrink: 0;
}

[data-theme="dark"] .modal-nav-tabs {
  background: var(--bg-secondary);
  border-bottom-color: var(--border-subtle);
}

.modal-tab-btn {
  border: 1px solid transparent;
  background: transparent;
  padding: 8px 16px;
  font-size: 0.88rem;
  font-weight: 700;
  color: #475569;
  cursor: pointer;
  border-radius: var(--radius-full);
  transition: all var(--transition-fast);
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.modal-tab-btn:hover {
  color: #0f172a;
  background: #e2e8f0;
}

.modal-tab-btn.active {
  color: #1d4ed8;
  background: #ffffff;
  border-color: #cbd5e1;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  font-weight: 800;
}

[data-theme="dark"] .modal-tab-btn {
  color: var(--text-secondary);
}

[data-theme="dark"] .modal-tab-btn:hover {
  color: var(--text-primary);
  background: var(--surface-hover);
}

[data-theme="dark"] .modal-tab-btn.active {
  color: var(--brand-blue);
  background: var(--surface-card);
  border-color: rgba(37, 99, 235, 0.3);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.modal-tab-badge {
  background: #dbeafe;
  color: #1e40af;
  font-size: 0.75rem;
  padding: 2px 7px;
  border-radius: var(--radius-full);
  font-weight: 800;
}

[data-theme="dark"] .modal-tab-badge {
  background: rgba(37, 99, 235, 0.15);
  color: var(--brand-blue);
}

/* شريط البحث الموضعي الثابت لبنود ومعادلات النافذة المنبثقة (دائماً أعلى منطقة التمرير) */
.modal-clauses-toolbar {
  background: #ffffff;
  border-bottom: 1px solid #cbd5e1;
  padding: 12px 28px;
  flex-shrink: 0;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.04);
}

[data-theme="dark"] .modal-clauses-toolbar {
  background: var(--surface-card);
  border-bottom-color: var(--border-subtle);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.03);
}

.modal-clauses-toolbar-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  background: #f8fafc;
  border: 1px solid #cbd5e1;
  border-radius: var(--radius-md);
  padding: 8px 16px;
  transition: all var(--transition-fast);
}

[data-theme="dark"] .modal-clauses-toolbar-inner {
  background: var(--bg-secondary);
  border-color: var(--border-medium);
}

.modal-clauses-toolbar-inner:focus-within {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
  background: #ffffff;
}

[data-theme="dark"] .modal-clauses-toolbar-inner:focus-within {
  border-color: var(--brand-blue);
  box-shadow: 0 0 0 3px var(--brand-blue-glow);
  background: var(--surface);
}

.modal-toolbar-icon {
  font-size: 1.1rem;
  opacity: 0.65;
  user-select: none;
}

.modal-clauses-toolbar input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #0f172a;
  font-size: 0.92rem;
  font-family: inherit;
  font-weight: 600;
}

[data-theme="dark"] .modal-clauses-toolbar input {
  color: var(--text-primary);
}

.modal-clauses-toolbar input::placeholder {
  color: #64748b;
}

[data-theme="dark"] .modal-clauses-toolbar input::placeholder {
  color: var(--text-muted);
}

.modal-body {
  padding: 24px 28px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  background: #f8fafc;
  scrollbar-width: thin;
  scrollbar-color: rgba(37, 99, 235, 0.3) transparent;
}

[data-theme="dark"] .modal-body {
  background: var(--surface);
}

.modal-tab-pane {
  display: none;
}

.modal-tab-pane.active {
  display: block;
}

/* بنود الاشتراطات في النافذة المنبثقة */
.modal-provision-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-inline-start: 3px solid var(--brand-blue);
  border-radius: var(--radius-sm);
  padding: 14px 18px;
  transition: all var(--transition-fast);
}

.modal-provision-item:hover {
  border-color: var(--brand-blue);
  background: var(--surface-hover);
  transform: translateX(-3px);
}

[dir="ltr"] .modal-provision-item:hover {
  transform: translateX(3px);
}

.modal-provision-bullet {
  color: var(--brand-gold);
  font-size: 1.15rem;
  line-height: 1.4;
  flex-shrink: 0;
}

.modal-provision-text {
  font-size: 0.94rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.6;
}

/* صندوق البند والمقتطف الهندسي (Clause Card) */
.clause-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: var(--radius-md);
  padding: 24px;
  margin-bottom: 20px;
  position: relative;
  scroll-margin-top: 24px;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
  transition: border-color var(--transition-fast), box-shadow 0.4s ease;
  max-width: 100%;
  min-width: 0;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .clause-card {
    padding: 16px 14px;
  }
}

[data-theme="dark"] .clause-card {
  background: var(--surface-card);
  border-color: var(--border-subtle);
  box-shadow: none;
}

.clause-card:hover {
  border-color: #93c5fd;
  box-shadow: 0 6px 20px rgba(37, 99, 235, 0.08);
}

[data-theme="dark"] .clause-card:hover {
  border-color: var(--brand-blue);
  box-shadow: none;
}

/* تأثير الوميض الجذاب عند فتح رابط مباشر للبند */
@keyframes clauseHighlightPulse {
  0% {
    border-color: var(--brand-gold);
    box-shadow: 0 0 0 4px rgba(217, 119, 6, 0.35), 0 8px 24px rgba(217, 119, 6, 0.2);
    transform: scale(1.01);
  }
  50% {
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 6px rgba(37, 99, 235, 0.4), 0 12px 28px rgba(37, 99, 235, 0.25);
    transform: scale(1.01);
  }
  100% {
    border-color: var(--brand-blue);
    box-shadow: none;
    transform: scale(1);
  }
}

.clause-highlight-pulse {
  animation: clauseHighlightPulse 3s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.clause-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

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

.btn-share-clause {
  height: 32px;
  padding: 0 12px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: var(--radius-xs);
  background: #fef3c7;
  color: #92400e;
  border: 1px solid #fcd34d;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  transition: all var(--transition-fast);
}

.btn-share-clause:hover {
  background: #f59e0b;
  color: #ffffff;
  border-color: #f59e0b;
  transform: translateY(-1px);
}

[data-theme="dark"] .btn-share-clause {
  background: rgba(217, 119, 6, 0.12);
  color: var(--brand-gold);
  border-color: rgba(217, 119, 6, 0.3);
}

[data-theme="dark"] .btn-share-clause:hover {
  background: var(--brand-gold);
  color: #ffffff;
  border-color: var(--brand-gold);
}

.clause-actions-group .btn-sm {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-weight: 700;
  height: 32px;
}

.clause-actions-group .btn-sm:hover {
  background: #f1f5f9;
  border-color: #94a3b8;
  color: #0f172a;
}

[data-theme="dark"] .clause-actions-group .btn-sm {
  background: var(--surface);
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.clause-id-badge {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-xs);
  background: #eff6ff;
  color: #1d4ed8;
  border: 1px solid #bfdbfe;
}

[data-theme="dark"] .clause-id-badge {
  background: var(--brand-blue-glow);
  color: var(--brand-blue);
  border-color: rgba(37, 99, 235, 0.2);
}

.clause-title {
  font-size: 1.18rem;
  font-weight: 800;
  color: #0f172a;
  line-height: 1.4;
}

[data-theme="dark"] .clause-title {
  color: var(--text-primary);
}

.clause-content {
  font-size: 0.94rem;
  color: #334155;
  line-height: 1.82;
  font-weight: 500;
}

[data-theme="dark"] .clause-content {
  color: var(--text-secondary);
}

.clause-rule-highlight {
  margin-top: 16px;
  padding: 14px 18px;
  background: #fffbeb;
  border: 1px solid #fde68a;
  border-inline-start: 4px solid #d97706;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  line-height: 1.68;
  color: #1e293b;
}

.clause-rule-highlight b {
  color: #92400e;
  font-weight: 800;
}

[data-theme="dark"] .clause-rule-highlight {
  background: rgba(217, 119, 6, 0.08);
  border-color: rgba(217, 119, 6, 0.2);
  border-inline-start-color: var(--brand-gold);
  color: var(--text-primary);
}

[data-theme="dark"] .clause-rule-highlight b {
  color: #fbbf24;
}

/* صندوق المعادلة الرياضية الهندسية المحسن والمنسق رياضياً */
.formula-card {
  background: #f8faff;
  border: 1px solid #dbeafe;
  border-inline-start: 4px solid #2563eb;
  border-radius: var(--radius-md);
  padding: 18px 22px;
  margin: 16px 0;
  position: relative;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.04);
  max-width: 100%;
  box-sizing: border-box;
}

@media (max-width: 768px) {
  .formula-card {
    padding: 14px 12px;
  }
}

[data-theme="dark"] .formula-card {
  background: linear-gradient(145deg, var(--bg-secondary), var(--surface));
  border-color: var(--border-medium);
  border-inline-start-color: var(--brand-blue);
  box-shadow: none;
}

.formula-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.formula-card-label {
  font-size: 0.82rem;
  font-weight: 800;
  color: #1d4ed8;
  letter-spacing: 0.5px;
}

[data-theme="dark"] .formula-card-label {
  color: #60a5fa;
}

.formula-card-header button {
  background: #ffffff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
  font-weight: 700;
}

.formula-card-header button:hover {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

[data-theme="dark"] .formula-card-header button {
  background: var(--surface);
  border-color: var(--border-medium);
  color: var(--text-primary);
}

.formula-expression {
  font-family: 'Cambria Math', 'KaTeX_Math', 'STIX Two Math', 'Times New Roman', serif;
  font-size: 1.22rem;
  font-weight: 700;
  color: #0f172a;
  letter-spacing: 0.8px;
  padding: 12px 16px;
  direction: ltr;
  text-align: left;
  background: #ffffff;
  border-radius: var(--radius-sm);
  border: 1px solid #bfdbfe;
  box-shadow: inset 0 1px 3px rgba(37, 99, 235, 0.06);
  margin: 10px 0 12px;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  white-space: normal;
  word-break: break-word;
}

[data-theme="dark"] .formula-expression {
  background: rgba(10, 18, 34, 0.85);
  border-color: rgba(59, 130, 246, 0.3);
  color: #93c5fd;
  box-shadow: none;
}

.formula-expression sub, .formula-expression sup {
  font-size: 0.75em;
  font-weight: 600;
}

.formula-notes {
  font-size: 0.88rem;
  color: #334155;
  line-height: 1.65;
  margin-top: 6px;
  font-weight: 500;
}

[data-theme="dark"] .formula-notes {
  color: var(--text-secondary);
}

/* تنبيه التوست (Toast Notification) */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast {
  background: var(--brand-navy-light);
  color: #ffffff;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  font-weight: 700;
  box-shadow: var(--shadow-lg);
  border: 1px solid rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  gap: 10px;
  transform: translateY(20px);
  opacity: 0;
  transition: all var(--transition-normal);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-icon {
  color: var(--brand-gold);
}

/* أزرار وشريط فلترة الموسوعة الهندسية */
.handbook-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--border-medium);
  background: var(--surface);
  color: var(--text-secondary);
  font-size: 0.85rem;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.handbook-tab-btn:hover {
  border-color: var(--brand-blue);
  color: var(--brand-blue);
  background: var(--surface-card);
}

.handbook-tab-btn.active {
  background: var(--brand-blue);
  color: #ffffff;
  border-color: var(--brand-blue);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.25);
}

.handbook-controls-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  background: var(--surface-card);
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

/* ===================================================================
   بطاقات الأكواد المدمجة وأعلام SVG ومكونات الجوال
   =================================================================== */

/* بطاقة الكود المدمجة (Compact Code Card) */
.compact-code-card {
  padding: 18px 20px !important;
  gap: 12px !important;
  border-radius: var(--radius-lg);
}

@media (max-width: 768px) {
  .compact-code-card {
    padding: 14px 16px !important;
    gap: 10px !important;
  }
}

.code-symbol-badge {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.28);
  border-radius: var(--radius-sm);
  color: var(--brand-blue);
  font-size: 0.88rem;
  font-weight: 800;
  font-family: var(--font-latin);
  letter-spacing: 0.5px;
}

.badge-year {
  background: rgba(234, 179, 8, 0.12) !important;
  border: 1px solid rgba(234, 179, 8, 0.28) !important;
  color: var(--brand-gold) !important;
  font-family: var(--font-latin);
  font-weight: 700;
}

.favorite-toggle-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border-subtle);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.favorite-toggle-btn:hover {
  background: var(--surface-hover);
  color: var(--brand-gold);
  border-color: var(--brand-gold);
}

.favorite-toggle-btn.active {
  color: var(--brand-gold) !important;
  background: rgba(234, 179, 8, 0.12) !important;
  border-color: rgba(234, 179, 8, 0.4) !important;
}

.code-card .code-title-group h3 {
  font-size: 1.15rem;
  font-weight: 800;
  margin: 0;
  line-height: 1.45;
}

.code-card-summary {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin: 0;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.code-expand-toggle-wrap {
  display: flex;
  align-items: center;
  justify-content: flex-start;
}

.btn-toggle-details {
  background: transparent;
  border: none;
  color: var(--brand-blue);
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
  padding: 4px 6px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: color var(--transition-fast);
}

.btn-toggle-details:hover {
  color: var(--brand-blue-hover);
  text-decoration: underline;
}

.code-card-expandable {
  background: var(--bg-primary);
  border: 1px dashed var(--border-medium);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
  animation: fadeIn 0.2s ease-in-out;
}

.code-card-expandable .code-excerpt-preview {
  margin: 0;
  border: none;
  background: transparent;
  padding: 0;
}

.code-card-footer {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
  padding-top: 12px;
  border-top: 1px solid var(--border-subtle);
  margin-top: auto;
}

.code-card-footer .btn {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-weight: 700;
}

.code-card-footer .btn-view-clauses {
  flex: 1.2;
}

.code-card-footer .btn-official-source {
  flex: 0.8;
}

/* أعلام SVG الموحدة بدلاً من الإيموجي في أنظمة ويندوز */
.flag-svg {
  display: inline-block;
  vertical-align: -2px;
  width: 20px;
  height: 14px;
  border-radius: 2px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  margin-inline-end: 6px;
  flex-shrink: 0;
  object-fit: cover;
}

/* شريط تحكم الموسوعة المتجاوب */
.handbook-tabs-desktop {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.handbook-select-mobile-wrap {
  display: none;
}

.handbook-search-wrap {
  position: relative;
  flex: 1;
  min-width: 220px;
  max-width: 360px;
}

.handbook-search-wrap input {
  width: 100%;
  height: 42px;
  padding: 0 36px 0 14px;
  font-size: 0.88rem;
  background: var(--surface);
  border: 1px solid var(--border-medium);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  box-sizing: border-box;
}

[dir="rtl"] .handbook-search-wrap input {
  padding: 0 14px 0 36px;
}

.handbook-search-wrap .search-icon {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.6;
  pointer-events: none;
  font-size: 0.95rem;
}

[dir="rtl"] .handbook-search-wrap .search-icon {
  left: 12px;
  right: auto;
}

[dir="ltr"] .handbook-search-wrap .search-icon {
  right: 12px;
  left: auto;
}

.handbook-match-badge {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-muted);
  white-space: nowrap;
}

@media (max-width: 768px) {
  .handbook-tabs-desktop {
    display: none !important;
  }

  .handbook-select-mobile-wrap {
    display: block !important;
    width: 100%;
  }

  .handbook-select-mobile {
    width: 100%;
    height: 44px;
  }

  .handbook-controls-bar {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
  }

  .handbook-search-wrap {
    max-width: 100%;
    width: 100%;
  }
}

