/* ============================================================
   منصة بناء — الأنماط الأساسية
   ملف: assets/css/main.css
   ============================================================ */

/* ==================== 1. الأساسيات ==================== */
:root {
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: 'Cairo', sans-serif;
  font-feature-settings: 'kern' 1;
}

/* شريط تمرير مخفي (للتمرير الأفقي) */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* ==================== 2. الخلفيات والأنماط الزخرفية ==================== */
.brick-pattern {
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,0.045) 0px, rgba(255,255,255,0.045) 1px, transparent 1px, transparent 34px),
    repeating-linear-gradient(90deg, rgba(255,255,255,0.045) 0px, rgba(255,255,255,0.045) 1px, transparent 1px, transparent 68px);
}

/* خط سير الحالة — RTL-aware */
.status-track { position: relative; }
.status-track::before {
  content: '';
  position: absolute;
  top: 22px;
  right: 6%;
  left: 6%;
  height: 3px;
  background: linear-gradient(to left, #1C5D9F, #E5E7EB 55%, #E5E7EB);
  z-index: 0;
}
@media (max-width: 640px) {
  .status-track::before { display: none; }
}

/* تأثير الزجاج */
.glass {
  backdrop-filter: saturate(180%) blur(16px);
  -webkit-backdrop-filter: saturate(180%) blur(16px);
  background-color: rgba(255,255,255,0.85);
}
.dark .glass { background-color: rgba(11,36,64,0.85); }

/* ==================== 3. إمكانية الوصول ==================== */
.focus-ring:focus-visible {
  outline: 3px solid #B98A3E;
  outline-offset: 3px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  top: -100px;
  right: 16px;
  z-index: 100;
  background: #B98A3E;
  color: #0B2440;
  padding: 12px 24px;
  border-radius: 8px;
  font-weight: 700;
  transition: top 0.2s;
}
.skip-link:focus { top: 16px; }

/* تحديد النص */
::selection { background: #B98A3E; color: #fff; }

/* الأرقام المتساوية */
.num-tabular {
  font-variant-numeric: tabular-nums;
  font-feature-settings: 'tnum' 1;
}

/* شريط تمرير رقيق */
.thin-scroll::-webkit-scrollbar { width: 6px; }
.thin-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }
.dark .thin-scroll::-webkit-scrollbar-thumb { background: #334155; }

/* منع layout shift قبل تحميل Lucide */
i[data-lucide] {
  display: inline-block;
  min-width: 1em;
  min-height: 1em;
  vertical-align: middle;
}

/* ==================== 4. المكونات: بطاقات الخدمات ==================== */
.service-card {
  background-color: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 0.75rem;
  padding: 1.25rem;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
}
.service-card:hover {
  border-color: #164A84;
  box-shadow: 0 4px 6px -1px rgba(11,36,64,0.08), 0 12px 24px -4px rgba(11,36,64,0.12);
  transform: translateY(-2px);
}
.dark .service-card { background-color: #0E2E52; border-color: #164A84; }
.dark .service-card:hover { border-color: #B98A3E; }

/* ==================== 5. النماذج ==================== */
.form-input {
  width: 100%;
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.5rem;
  padding: 0.75rem 1rem;
  font-size: 0.875rem;
  outline: none;
  transition: all 0.15s ease;
  color: #0B2440;
  font-family: inherit;
  line-height: 1.5;
}
.form-input::placeholder { color: #9ca3af; }
.form-input:focus {
  border-color: #1C5D9F;
  box-shadow: 0 0 0 3px rgba(28, 93, 159, 0.15);
}
.dark .form-input {
  background-color: #0E2E52;
  border-color: #164A84;
  color: #ffffff;
}
.dark .form-input::placeholder { color: #94a3b8; }
.dark .form-input:focus {
  border-color: #2C74BD;
  box-shadow: 0 0 0 3px rgba(44, 116, 189, 0.25);
}

/* select — سهم مخصص */
select.form-input {
  appearance: none;
  -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: left 1rem center;
  padding-left: 2.5rem;
}
select.form-input option {
  background-color: #ffffff;
  color: #0B2440;
}
.dark select.form-input option {
  background-color: #0E2E52;
  color: #ffffff;
}
.dark select.form-input {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2394a3b8' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
}

/* ==================== 6. الشارات ==================== */
.badge-success {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: #059669;
  background-color: #ECFDF5;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  white-space: nowrap;
}
.dark .badge-success {
  background-color: rgba(5, 150, 105, 0.2);
  color: #34d399;
}

.badge-warning {
  display: inline-flex;
  align-items: center;
  font-size: 11px;
  font-weight: 600;
  color: #D97706;
  background-color: #FFFBEB;
  padding: 0.25rem 0.625rem;
  border-radius: 9999px;
  white-space: nowrap;
}
.dark .badge-warning {
  background-color: rgba(217, 119, 6, 0.2);
  color: #fbbf24;
}

/* ==================== 7. التنقل السفلي (الجوال) ==================== */
.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 0.625rem 0;
  color: #6b7280;
  transition: color 0.15s;
  position: relative;
  font-size: 10px;
}
.dark .bottom-nav-item { color: #94a3b8; }
.bottom-nav-item:hover,
.bottom-nav-item.active { color: #123B69; }
.dark .bottom-nav-item:hover,
.dark .bottom-nav-item.active { color: #D9AE6C; }

.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  right: 25%;
  left: 25%;
  height: 3px;
  background: #B98A3E;
  border-radius: 0 0 4px 4px;
}

/* ==================== 8. حركات الظهور ==================== */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}
.reveal.in-view {
  opacity: 1;
  transform: translateY(0);
}

/* ==================== 9. القائمة الجانبية (Drawer) ==================== */
.drawer-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  background: rgba(11, 36, 64, 0.55);
  z-index: 9998;
  display: none;
  border: none;
  padding: 0;
  cursor: pointer;
}
.drawer-overlay.open { display: block; }

.drawer-panel {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: 86%;
  max-width: 24rem;
  background: #ffffff;
  z-index: 9999;
  overflow-y: auto;
  overflow-x: hidden;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.25);
  -webkit-overflow-scrolling: touch;
  display: none;
}
.dark .drawer-panel { background: #0E2E52; }
.drawer-panel.open {
  display: block;
  animation: drawerSlideIn 0.25s ease-out;
}
@keyframes drawerSlideIn {
  from { transform: translateX(30px); opacity: 0; }
  to   { transform: translateX(0);    opacity: 1; }
}

@media (min-width: 1280px) {
  .drawer-overlay,
  .drawer-panel { display: none !important; }
}

/* ==================== 10. تقليل الحركة ==================== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation: none !important;
    transition: none !important;
  }
  html { scroll-behavior: auto; }

  /* إظهار عناصر .reveal فوراً — بدل تركها مخفية */
  .reveal {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* ==================== 11. معالج التقديم (Wizard) ==================== */
.wizard-step { display: none; }
.wizard-step.active {
  display: block;
  animation: fadeInUp 0.4s ease-out;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(15px); }
  to   { opacity: 1; transform: translateY(0); }
}

.step-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  flex-shrink: 0;
}
.step-circle {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 9999px;
  background: #e5e7eb;
  color: #6b7280;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  transition: all 0.3s;
}
.step-indicator.active .step-circle {
  background: #123B69;
  color: white;
  box-shadow: 0 0 0 4px rgba(18,59,105,0.15);
}
.step-indicator.completed .step-circle {
  background: #059669;
  color: white;
}
.step-label {
  font-size: 0.65rem;
  color: #6b7280;
  font-weight: 600;
  white-space: nowrap;
}
.step-indicator.active .step-label { color: #123B69; }
.step-indicator.completed .step-label { color: #059669; }

.step-line {
  flex: 1;
  height: 2px;
  background: #e5e7eb;
  margin: 0 0.25rem;
  margin-bottom: 1.25rem;
  transition: background 0.3s;
}
.step-line.completed { background: #059669; }

@media (max-width: 640px) {
  .step-label { display: none; }
  .step-circle { width: 2rem; height: 2rem; font-size: 0.75rem; }
}

.dark .step-circle { background: #164A84; color: #94a3b8; }
.dark .step-indicator.active .step-circle {
  background: #B98A3E;
  color: #0B2440;
  box-shadow: 0 0 0 4px rgba(185,138,62,0.2);
}
.dark .step-indicator.active .step-label { color: #D9AE6C; }
.dark .step-line { background: #164A84; }

/* تنقل المعالج */
.wizard-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.75rem;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e5e7eb;
}
.dark .wizard-nav { border-color: #164A84; }

.btn-next, .btn-prev {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
  font-size: 0.875rem;
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  transition: all 0.2s;
  cursor: pointer;
  border: none;
  font-family: inherit;
}
.btn-next { background: #123B69; color: white; }
.btn-next:hover { background: #0B2440; }
.btn-next:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-prev { background: transparent; color: #123B69; border: 1px solid rgba(18,59,105,0.25); }
.btn-prev:hover { background: #F4F8FC; }
.dark .btn-next { background: #B98A3E; color: #0B2440; }
.dark .btn-next:hover { background: #D9AE6C; }
.dark .btn-prev { color: #D9AE6C; border-color: rgba(217,174,108,0.3); }
.dark .btn-prev:hover { background: rgba(185,138,62,0.1); }

/* اختيار الخدمة */
.service-option {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1.25rem;
  border: 2px solid #e5e7eb;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
}
.service-option:hover { border-color: #B98A3E; background: #F4F8FC; }
.service-option.selected {
  border-color: #123B69;
  background: #F4F8FC;
  box-shadow: 0 4px 12px -2px rgba(18,59,105,0.15);
}
.dark .service-option { background: #0E2E52; border-color: #164A84; }
.dark .service-option:hover { border-color: #B98A3E; background: #123B69; }
.dark .service-option.selected { border-color: #B98A3E; background: #123B69; }

.service-option .check-icon {
  position: absolute;
  top: 0.75rem;
  left: 0.75rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  background: #123B69;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transform: scale(0.5);
  transition: all 0.2s;
}
.service-option.selected .check-icon {
  opacity: 1;
  transform: scale(1);
}
.dark .service-option.selected .check-icon {
  background: #B98A3E;
  color: #0B2440;
}

/* منطقة الرفع */
.upload-zone {
  border: 2px dashed #e5e7eb;
  border-radius: 0.75rem;
  padding: 1.25rem;
  cursor: pointer;
  transition: all 0.2s;
  background: white;
}
.upload-zone:hover,
.upload-zone.dragover { border-color: #B98A3E; background: #FFFBEB; }
.upload-zone.uploaded { border-style: solid; border-color: #059669; background: #ECFDF5; }
.dark .upload-zone { background: #0E2E52; border-color: #164A84; }
.dark .upload-zone:hover,
.dark .upload-zone.dragover { border-color: #B98A3E; background: #123B69; }
.dark .upload-zone.uploaded { border-color: #059669; background: rgba(5,150,105,0.1); }

/* ==================== 12. حالة التحميل للأزرار ==================== */
button.loading,
button[data-loading-text].loading {
  pointer-events: none;
  opacity: 0.75;
  position: relative;
  cursor: wait;
}

button.loading::after,
button[data-loading-text].loading::after {
  content: '';
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: btnSpin 0.6s linear infinite;
  margin-right: 8px;
  vertical-align: middle;
}

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

/* ==================== 13. أنماط الطباعة ==================== */
@media print {
  .no-print,
  header,
  footer,
  nav[aria-label="التنقل السريع"],
  #drawer,
  #drawerOverlay,
  #toastContainer,
  #backToTop,
  .drawer-overlay,
  .drawer-panel,
  .skip-link,
  .wizard-nav,
  .btn-next,
  .btn-prev {
    display: none !important;
  }

  body {
    background: white !important;
    color: #000 !important;
    font-size: 12pt;
    font-family: 'Cairo', sans-serif;
  }

  main { padding: 0 !important; }
  section[data-page] { page-break-inside: avoid; }

  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .reveal {
    opacity: 1 !important;
    transform: none !important;
  }

  .service-card,
  .bg-white,
  .shadow-gov,
  .shadow-gov-lg {
    box-shadow: none !important;
  }

  .bg-bunya-900,
  .bg-bunya-950 {
    background-color: #0E2E52 !important;
    color: white !important;
  }

  .brick-pattern {
    background-image: none !important;
    background-color: #0E2E52 !important;
  }

  a[href]::after {
    content: "";
  }

  #successTx {
    font-size: 18pt;
    font-weight: bold;
    border: 2px solid #000;
    padding: 8px 16px;
    display: inline-block;
  }

  table { page-break-inside: auto; }
  tr { page-break-inside: avoid; page-break-after: auto; }
  thead { display: table-header-group; }
}

/* ==================== 14. حماية من الامتداد الأفقي ==================== */
/* نستخدم clip بدل hidden — لا يقوّض position: sticky */
html {
  overflow-x: hidden;  /* fallback للمتصفحات القديمة */
  overflow-x: clip;    /* حديث — يحفظ sticky */
}

body {
  overflow-x: hidden;
  overflow-x: clip;
  max-width: 100vw;
}

main {
  overflow-x: clip;
}

/* ضمان أن الصور والجداول لا تتجاوز العرض */
img, svg, table {
  max-width: 100%;
}

/* منع النصوص الطويلة من كسر التصميم */
* {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* على الجوال — ضمان أن الشبكات تتحول لعمود واحد */
@media (max-width: 1023px) {
  .lg\:col-span-4,
  .lg\:col-span-8 {
    grid-column: span 12 / span 12;
  }
}