/* Import Arabic font for RTL */
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@300;400;500;700;800&display=swap');

/* ================ THEME TOKENS ================ */
:root {
  --primary: #00A4FF;
  --primary-dark: #00389B;
  --bg: #f7f7f7;
  --text: #1f2937;
  --muted: #6b7280;
  --white: #ffffff;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* ================ RESET/UTILS ================ */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

/* Arabic font when document is RTL */
[dir="rtl"] body,
[dir="rtl"] * {
  font-family: 'Tajawal', Tahoma, Arial, sans-serif;
}

/* Ensure FontAwesome icons display properly in RTL */
[dir="rtl"] .fas,
[dir="rtl"] .far,
[dir="rtl"] .fab,
[dir="rtl"] .fa {
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900 !important;
  display: inline-block !important;
  font-style: normal !important;
  font-variant: normal !important;
  text-rendering: auto !important;
  line-height: 1 !important;
}

/* Global FontAwesome icon fix for all pages */
.fas,
.far,
.fab,
.fa {
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900 !important;
  display: inline-block !important;
  font-style: normal !important;
  font-variant: normal !important;
  text-rendering: auto !important;
  line-height: 1 !important;
}

/* Specific fixes for common icons */
.fa-bars,
.fa-chevron-down,
.fa-arrow-up,
.fa-envelope,
.fa-phone,
.fa-copy,
.fa-check,
.fa-times,
.fa-user,
.fa-comment {
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900 !important;
  display: inline-block !important;
  font-style: normal !important;
  font-variant: normal !important;
  text-rendering: auto !important;
  line-height: 1 !important;
}

.container {
  width: min(1200px, 92%);
  margin: 0 auto;
}

/* ================ NAVBAR ================ */
.navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: var(--white);
  box-shadow: var(--shadow-sm);
}

.navbar-container {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0 4px;
}

.logo {
  height: 40px;
  width: auto;
  cursor: pointer;
}

.nav-links {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 20px;
}

.nav-links a {
  text-decoration: none;
  color: var(--text);
  font-weight: 600;
  padding: 8px 10px;
  border-radius: 8px;
  transition: color .2s ease, background .2s ease;
  position: relative;
}

.nav-links a:hover {
  color: var(--primary-dark);
  background: rgba(0, 164, 255, 0.08);
}

/* Active indicator & hover underline */
.nav-links a::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 4px;
  height: 2px;
  background: linear-gradient(90deg, var(--primary), var(--primary-dark));
  border-radius: 2px;
  transform: scaleX(0);
  transform-origin: left;
  transition: transform .2s ease;
}

.nav-links a:hover::after,
.nav-links a.active::after {
  transform: scaleX(1);
}

/* Contact CTA (desktop) */
.nav-links a[data-section="contact"] {
  background: linear-gradient(180deg, var(--primary), #0b96ea);
  color: var(--white);
  box-shadow: 0 6px 16px rgba(0, 164, 255, 0.25);
}

.nav-links a[data-section="contact"]:hover {
  background: linear-gradient(180deg, #0b96ea, var(--primary-dark));
}

.hamburger {
  display: none;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: 22px;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  align-items: center;
  justify-content: center;
  transition: background .2s ease, color .2s ease;
}

.hamburger i {
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900 !important;
  display: inline-block !important;
  font-style: normal !important;
  font-variant: normal !important;
  text-rendering: auto !important;
  line-height: 1 !important;
}

.hamburger:focus {
  outline: 2px solid rgba(0, 164, 255, 0.35);
  outline-offset: 2px;
}

.hamburger:hover {
  background: #f1f5f9;
  color: var(--primary-dark);
}

/* ================ LANGUAGE DROPDOWN ================ */
.lang-toggle-container {
  position: relative;
}

.lang-btn {
  border: 1px solid #e5e7eb;
  background: var(--white);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.lang-btn:hover {
  border-color: var(--primary);
  background: rgba(0, 164, 255, 0.05);
}

.lang-btn i {
  font-size: 12px;
  transition: transform 0.2s ease;
  opacity: 0.7;
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900 !important;
  display: inline-block !important;
  font-style: normal !important;
  font-variant: normal !important;
  text-rendering: auto !important;
  line-height: 1 !important;
}

.lang-toggle-container.open .lang-btn i {
  transform: rotate(180deg);
  opacity: 1;
}

.lang-options {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 160px;
  background: var(--white);
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: var(--shadow-sm);
  padding: 6px;
  display: none;
}

.lang-option {
  padding: 10px 10px;
  border-radius: 8px;
  cursor: pointer;
}

.lang-option:hover {
  background: #f1f5f9;
}

/* toggle via JS by adding .open on container */
.lang-toggle-container.open .lang-options {
  display: block;
}

/* ================ RESPONSIVE ================ */
@media (max-width: 900px) {
  .hamburger {
    display: inline-flex;
  }

  .nav-links {
    position: fixed;
    top: 64px;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(180deg, var(--primary-dark), var(--primary));
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 24px 16px;
    transform: translateY(8px);
    opacity: 0;
    pointer-events: none;
    transition: transform .22s ease, opacity .22s ease;
    z-index: 1001;
  }

  /* when JS adds .active or .open to #nav-links */
  .nav-links.active,
  .nav-links.open {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  /* Large centered links */
  .nav-links li {
    list-style: none;
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .nav-links li a,
  .nav-links li .lang-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: min(520px, 92%);
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 20px;
    color: #ffffff;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
  }

  /* Remove desktop underline effect inside mobile */
  .nav-links a::after {
    content: none;
  }

  /* Emphasize primary actions on hover */
  .nav-links li a:hover,
  .nav-links li .lang-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.3);
  }

  /* Backdrop not needed: overlay is full-screen */

  /* Contact primary action (brighter) */
  .nav-links a[data-section="contact"] {
    background: #ffffff;
    color: var(--primary-dark);
    border: 0;
    font-weight: 800;
  }

  /* Language button styled like link; dropdown stays absolute/hidden */
  .lang-toggle-container {
    width: 100%;
    display: flex;
    justify-content: center;
  }

  .lang-btn {
    width: min(520px, 92%);
    justify-content: center;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    border-color: rgba(255, 255, 255, 0.14);
  }

  /* RTL friendly layout */
  [dir="rtl"] .nav-links li a,
  [dir="rtl"] .nav-links li .lang-btn {
    flex-direction: row;
  }
}

/* ================ RTL LANGUAGE DROPDOWN FIXES ================ */
[dir="rtl"] .lang-btn {
  flex-direction: row-reverse;
}

[dir="rtl"] .lang-btn i {
  transform: scaleX(-1);
}

[dir="rtl"] .lang-toggle-container.open .lang-btn i {
  transform: scaleX(-1) rotate(180deg);
}

[dir="rtl"] .lang-options {
  right: auto;
  left: 0;
}

/* ================ LOADER (shared) ================ */
.loader {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1100;
}

.loader-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #e5e7eb;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ================ CUSTOM SCROLLBAR ================ */
::-webkit-scrollbar {
  width: 8px;
}

::-webkit-scrollbar-track {
  background: #f1f5f9;
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, var(--primary), var(--primary-dark));
  border-radius: 4px;
  transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--primary-dark), #002a7a);
}

/* Firefox scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--primary) #f1f5f9;
}

/* ================ CUSTOM SELECTION COLORS ================ */
::selection {
  background: rgba(0, 164, 255, 0.2);
  color: var(--primary-dark);
}

::-moz-selection {
  background: rgba(0, 164, 255, 0.2);
  color: var(--primary-dark);
}

/* ================ ENHANCED BACK TO TOP BUTTON ================ */
.back-to-top {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 0;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: var(--white);
  display: grid;
  place-items: center;
  box-shadow: 0 8px 24px rgba(0, 164, 255, 0.4);
  cursor: pointer;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px) scale(0.8);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 1000;
  font-size: 18px;
}

.back-to-top i {
  font-family: "Font Awesome 6 Free" !important;
  font-weight: 900 !important;
  display: inline-block !important;
  font-style: normal !important;
  font-variant: normal !important;
  text-rendering: auto !important;
  line-height: 1 !important;
}

.back-to-top:hover {
  background: linear-gradient(135deg, var(--primary-dark), #002a7a);
  box-shadow: 0 12px 32px rgba(0, 164, 255, 0.5);
  transform: translateY(-2px) scale(1.05);
}

.back-to-top:active {
  transform: translateY(0) scale(0.95);
}

.back-to-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

/* Pulse animation for attention */
.back-to-top.pulse {
  animation: pulseGlow 2s ease-in-out infinite;
}

@keyframes pulseGlow {

  0%,
  100% {
    box-shadow: 0 8px 24px rgba(0, 164, 255, 0.4);
  }

  50% {
    box-shadow: 0 8px 24px rgba(0, 164, 255, 0.6), 0 0 20px rgba(0, 164, 255, 0.3);
  }
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .back-to-top {
    right: 16px;
    bottom: 16px;
    width: 44px;
    height: 44px;
    font-size: 16px;
  }
}

@media (max-width: 480px) {
  .back-to-top {
    right: 12px;
    bottom: 12px;
    width: 40px;
    height: 40px;
    font-size: 14px;
  }
}