@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans+Arabic:wght@400;500;600;700&family=Noto+Naskh+Arabic:wght@600;700&display=swap");
@import url("brand-tokens.css");
@import url("hubs-rail.css");

:root {
  --shell-bg: var(--h-nav);
  --shell-text: var(--h-text);
  --shell-muted: var(--h-muted);
  --shell-gold: var(--h-gold);
  --shell-gold-bright: var(--h-gold-bright);
  --shell-line: var(--h-line);
  --shell-font: "IBM Plex Sans Arabic", "Tajawal", sans-serif;
  --shell-display: "Noto Naskh Arabic", "Amiri", serif;
}

.alhajda-shell {
  position: relative;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 68px;
  padding: 0.8rem clamp(1rem, 4vw, 2.5rem);
  border-bottom: 1px solid var(--shell-line);
  background:
    linear-gradient(180deg, rgba(179, 147, 89, 0.12), transparent 72%),
    linear-gradient(90deg, rgba(56, 184, 181, 0.04), transparent 40%),
    var(--shell-bg);
  color: var(--shell-text);
  font-family: var(--shell-font);
  backdrop-filter: blur(20px) saturate(1.15);
  -webkit-backdrop-filter: blur(20px) saturate(1.15);
}

.alhajda-shell::after {
  content: "";
  position: absolute;
  right: clamp(1rem, 4vw, 2.5rem);
  left: clamp(1rem, 4vw, 2.5rem);
  bottom: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(179, 147, 89, 0.55), transparent);
  pointer-events: none;
}

.alhajda-shell__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  color: var(--shell-text);
  text-decoration: none;
  white-space: nowrap;
  min-width: 0;
}

.alhajda-shell__mark {
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  border-radius: 11px;
  background: #1c1914;
  box-shadow:
    0 0 0 1px rgba(179, 147, 89, 0.42),
    0 0 22px rgba(179, 147, 89, 0.16);
  transition: box-shadow 0.25s ease, transform 0.25s ease;
}

.alhajda-shell__brand:hover .alhajda-shell__mark {
  transform: translateY(-1px);
  box-shadow:
    0 0 0 1px rgba(212, 184, 122, 0.55),
    0 0 28px rgba(179, 147, 89, 0.28);
}

.alhajda-shell__brand-text {
  display: flex;
  flex-direction: column;
  gap: 0.05rem;
  min-width: 0;
}

.alhajda-shell__brand strong {
  font-family: var(--shell-display);
  color: var(--shell-gold-bright);
  font-size: 1.35rem;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.01em;
}

.alhajda-shell__brand em {
  font-style: normal;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--shell-gold);
  text-transform: uppercase;
}

.alhajda-shell__brand small {
  display: block;
  color: var(--shell-muted);
  font-size: 0.68rem;
  line-height: 1.25;
  max-width: 18rem;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alhajda-shell__nav {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.alhajda-shell__nav a {
  position: relative;
  color: var(--shell-muted);
  text-decoration: none;
  font-size: 0.84rem;
  font-weight: 650;
  transition: color 0.2s ease;
}

.alhajda-shell__nav a::after {
  content: "";
  position: absolute;
  right: 0;
  left: 0;
  bottom: -0.35rem;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--shell-gold-bright), transparent);
  transform: scaleX(0);
  transition: transform 0.22s ease;
}

.alhajda-shell__nav a:hover,
.alhajda-shell__nav a:focus-visible {
  color: var(--shell-gold-bright);
}

.alhajda-shell__nav a:hover::after,
.alhajda-shell__nav a:focus-visible::after {
  transform: scaleX(1);
}

/* حساب المستخدم — أعلى الشريط مثل المواقع العالمية */
.alhajda-account {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  flex: 0 0 auto;
  z-index: 1100;
  font-family: var(--shell-font);
}

.alhajda-shell .alhajda-account {
  margin-inline-start: 0.35rem;
}

.home-nav .alhajda-account {
  margin-inline-start: 0.25rem;
}

header .nav-group .alhajda-account {
  margin-inline-start: 0.15rem;
}

.alhajda-account__loading {
  color: var(--shell-muted, #9b9ba3);
  font-size: 0.85rem;
  min-width: 2rem;
  text-align: center;
}

.alhajda-account__login,
.alhajda-account__signup {
  appearance: none;
  border: 1px solid rgba(28, 25, 20, 0.12);
  background: rgba(255, 250, 241, 0.7);
  color: var(--shell-text, #1c1914);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.42rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, color 0.2s, transform 0.15s;
  white-space: nowrap;
}

.alhajda-account__login:hover,
.alhajda-account__signup:hover {
  border-color: rgba(179, 147, 89, 0.5);
  color: var(--shell-gold-bright, #d4b87a);
  transform: translateY(-1px);
}

.alhajda-account__signup {
  background: linear-gradient(135deg, #d4b87a, #b39359);
  color: #1a140c;
  border-color: transparent;
  box-shadow: 0 4px 16px rgba(179, 147, 89, 0.25);
}

.alhajda-account__signup:hover {
  color: #1a140c;
  filter: brightness(1.05);
}

.alhajda-account__avatar-btn {
  appearance: none;
  border: 0;
  padding: 0;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  cursor: pointer;
  background: linear-gradient(145deg, #f4efe4, #e8dfcf);
  box-shadow:
    0 0 0 2px rgba(179, 147, 89, 0.55),
    0 0 18px rgba(179, 147, 89, 0.2);
  transition: transform 0.18s ease, box-shadow 0.2s;
}

.alhajda-account__avatar-btn:hover,
.alhajda-account__avatar-btn[aria-expanded="true"] {
  transform: translateY(-1px) scale(1.03);
  box-shadow:
    0 0 0 2px rgba(212, 184, 122, 0.7),
    0 0 24px rgba(179, 147, 89, 0.32);
}

.alhajda-account__avatar-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.alhajda-account__initials {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: 0.72rem;
  font-weight: 800;
  color: #8f7344;
  letter-spacing: 0.02em;
}

.alhajda-account__menu {
  position: absolute;
  top: calc(100% + 0.55rem);
  inset-inline-end: 0;
  min-width: 220px;
  padding: 0.55rem;
  border-radius: 14px;
  border: 1px solid rgba(28, 25, 20, 0.10);
  background:
    linear-gradient(165deg, rgba(179, 147, 89, 0.08), transparent 40%),
    rgba(255, 250, 241, 0.98);
  backdrop-filter: blur(16px);
  box-shadow: 0 18px 48px rgba(28, 25, 20, 0.12);
  display: none;
  flex-direction: column;
  gap: 0.2rem;
  z-index: 1200;
}

.alhajda-account__menu.is-open {
  display: flex;
}

.alhajda-account__meta {
  display: grid;
  gap: 0.15rem;
  padding: 0.45rem 0.55rem 0.65rem;
  border-bottom: 1px solid rgba(28, 25, 20, 0.08);
  margin-bottom: 0.25rem;
}

.alhajda-account__meta strong {
  color: var(--shell-text, #1c1914);
  font-size: 0.92rem;
}

.alhajda-account__meta span {
  color: var(--shell-muted, #9b9ba3);
  font-size: 0.72rem;
  word-break: break-all;
}

.alhajda-account__item {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--shell-muted, #9b9ba3);
  text-decoration: none;
  text-align: inherit;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 650;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.alhajda-account__item:hover {
  background: rgba(179, 147, 89, 0.1);
  color: var(--shell-gold-bright, #d4b87a);
}

.alhajda-account__item--danger:hover {
  background: rgba(196, 92, 92, 0.12);
  color: #e07a7a;
}

.alhajda-auth-overlay {
  position: fixed;
  inset: 0;
  z-index: 10050;
  display: grid;
  place-items: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(6px);
}

.alhajda-auth-modal {
  width: min(100%, 380px);
  padding: 1.35rem 1.25rem 1.1rem;
  border-radius: 18px;
  border: 1px solid rgba(179, 147, 89, 0.35);
  background:
    linear-gradient(165deg, rgba(179, 147, 89, 0.12), transparent 45%),
    #fffaf1;
  color: #1c1914;
  font-family: var(--shell-font);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
}

.alhajda-auth-modal h2 {
  margin: 0 0 0.35rem;
  font-family: var(--shell-display);
  font-size: 1.35rem;
  color: #8f7344;
}

.alhajda-auth-modal__lead {
  margin: 0 0 1rem;
  color: #9b9ba3;
  font-size: 0.88rem;
  line-height: 1.6;
}

.alhajda-auth-modal label {
  display: grid;
  gap: 0.3rem;
  margin-bottom: 0.7rem;
  font-size: 0.78rem;
  color: #9b9ba3;
}

.alhajda-auth-modal input {
  width: 100%;
  border: 1px solid rgba(28, 25, 20, 0.12);
  border-radius: 10px;
  background: #fff;
  color: #1c1914;
  font: inherit;
  font-size: 0.95rem;
  padding: 0.7rem 0.8rem;
}

.alhajda-auth-modal input:focus {
  outline: 2px solid rgba(179, 147, 89, 0.55);
  outline-offset: 1px;
}

.alhajda-auth-modal__row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  margin-top: 0.25rem;
}

.alhajda-auth-btn {
  appearance: none;
  border: 1px solid rgba(28, 25, 20, 0.12);
  background: #fff;
  color: #1c1914;
  font: inherit;
  font-size: 0.88rem;
  font-weight: 700;
  padding: 0.7rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
}

.alhajda-auth-btn--primary {
  background: linear-gradient(135deg, #d4b87a, #b39359);
  color: #1a140c;
  border-color: transparent;
}

.alhajda-auth-btn--google {
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  background: #fff;
  color: #1a1a1a;
  border-color: transparent;
}

.alhajda-auth-modal__or {
  text-align: center;
  margin: 0.85rem 0 0.65rem;
  color: #8a8a92;
  font-size: 0.75rem;
}

.alhajda-auth-modal__toast {
  min-height: 1.2rem;
  margin: 0.65rem 0 0;
  color: #e07a7a;
  font-size: 0.78rem;
  line-height: 1.5;
}

.alhajda-auth-modal__close {
  appearance: none;
  border: 0;
  background: transparent;
  color: #8a8a92;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  margin-top: 0.35rem;
  cursor: pointer;
  width: 100%;
  padding: 0.45rem;
}

.alhajda-auth-modal__close:hover {
  color: #d4b87a;
}

html[data-theme="dark"] .alhajda-shell__mark { background: #181e2a; }
html[data-theme="dark"] .alhajda-account__menu {
  border-color: rgba(243, 238, 228, 0.10);
  background:
    linear-gradient(165deg, rgba(196, 164, 106, 0.07), transparent 40%),
    #181e2a;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
}
html[data-theme="dark"] .alhajda-auth-modal {
  background:
    linear-gradient(165deg, rgba(196, 164, 106, 0.08), transparent 45%),
    #181e2a;
  color: #f3eee4;
}
html[data-theme="dark"] .alhajda-auth-modal input {
  background: #10141c;
  color: #f3eee4;
  border-color: rgba(243, 238, 228, 0.12);
}
html[data-theme="dark"] .alhajda-trust-footer {
  background:
    linear-gradient(0deg, rgba(196, 164, 106, 0.04), transparent 55%),
    #10141c;
}

.alhajda-trust-footer {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 1.35rem clamp(1rem, 4vw, 2.5rem);
  border-top: 1px solid var(--shell-line);
  background:
    linear-gradient(0deg, rgba(179, 147, 89, 0.05), transparent 55%),
    #f4efe4;
  color: var(--shell-muted);
  font: 0.8rem/1.7 var(--shell-font);
}

.alhajda-trust-footer strong {
  color: var(--shell-gold);
  font-family: var(--shell-display);
  font-weight: 700;
}

.alhajda-trust-footer nav {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.alhajda-trust-footer a {
  color: var(--shell-muted);
  text-decoration: none;
}

.alhajda-trust-footer a:hover {
  color: var(--shell-gold);
}

/* الصفحات التي لديها شريط shell لا تحتاج تنقّل مكرر داخل المحتوى */
body:has(.alhajda-shell) .wrap > nav.nav {
  display: none;
}

.alhajda-shell .theme-toggle,
.alhajda-account + .theme-toggle {
  appearance: none;
  border: 1px solid var(--shell-line);
  background: transparent;
  color: var(--shell-gold-bright);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  padding: 0.38rem 0.8rem;
  border-radius: 999px;
  cursor: pointer;
}
.alhajda-shell .theme-toggle:hover {
  border-color: var(--shell-gold);
  color: var(--shell-text);
}

@media (max-width: 760px) {
  .alhajda-shell {
    flex-wrap: wrap;
    align-items: center;
    min-height: 0;
    gap: 0.55rem;
    padding: 0.7rem clamp(0.85rem, 3vw, 1.25rem) 0.65rem;
    padding-top: max(0.7rem, env(safe-area-inset-top, 0px));
  }

  .alhajda-shell__mark {
    width: 34px;
    height: 34px;
    flex-basis: 34px;
  }

  .alhajda-shell__brand {
    flex: 1 1 auto;
    min-width: 0;
  }

  .alhajda-shell__brand strong {
    font-size: 1.2rem;
  }

  .alhajda-shell__brand small,
  .alhajda-shell__brand em {
    display: none;
  }

  .alhajda-shell .alhajda-account {
    order: 2;
    margin-inline-start: 0;
  }

  /* شريط واحد على الجوال: hubs-rail يكفي — أخفِ تنقّل الـ shell */
  body:has(.hubs-rail) .alhajda-shell__nav {
    display: none;
  }

  .alhajda-shell__nav {
    order: 3;
    flex: 1 1 100%;
    justify-content: flex-start;
    flex-wrap: nowrap;
    gap: 0.45rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    padding-bottom: 0.15rem;
  }

  .alhajda-account__login,
  .alhajda-account__signup {
    min-height: 44px;
    padding: 0.45rem 0.9rem;
    font-size: 0.8rem;
  }

  .home-nav .alhajda-account__signup {
    display: none;
  }

  .alhajda-shell__nav::-webkit-scrollbar {
    display: none;
  }

  .alhajda-shell__nav a {
    flex: 0 0 auto;
    white-space: nowrap;
    font-size: 0.8rem;
    border: 1px solid rgba(179, 147, 89, 0.35);
    border-radius: 999px;
    padding: 0.45rem 0.85rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
    color: var(--shell-gold);
    background: rgba(179, 147, 89, 0.08);
  }

  .alhajda-auth-modal__row {
    flex-direction: column;
  }

  .alhajda-auth-btn {
    min-height: 44px;
    width: 100%;
  }

  /* شريطا الحالة يبدوان كوحدة واحدة على الجوال */
  #server-strip {
    margin-bottom: 0;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  #live-strip {
    margin-top: 0;
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-top-color: transparent;
  }

  .alhajda-trust-footer {
    grid-template-columns: 1fr;
  }
}
