/* ==========================================================================
   components.css — مكوّنات مشتركة بين كل الصفحات
   ========================================================================== */

@view-transition {
  navigation: auto;
}

/* تثبيت عرض الصفحة ومنع القفزة الأفقية عند الانتقال بين الصفحات الطويلة والقصيرة */
html {
  overflow-x: clip;
  overflow-y: scroll;
  scrollbar-gutter: stable;
}

body {
  overflow-x: clip;
}

.svg-symbols {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

[data-shell] { display: contents; }
[data-shell="header"]:empty {
  display: block;
  min-height: 66px;
  margin-block-end: clamp(24px, 4vw, 48px);
}
[data-shell="footer"]:empty {
  display: block;
  min-height: 180px;
  margin-block-start: clamp(56px, 8vw, 96px);
}

/* ---------- إطار التطبيق ---------- */
.app-frame {
  width: min(100% - clamp(16px, 4vw, 64px), var(--container));
  margin: clamp(12px, 2.5vw, 36px) auto;
  padding: clamp(16px, 2.5vw, 36px);
  background: var(--bg);
  border-radius: var(--r-xl);
  box-shadow: none;
}

/* ---------- انتقال المحتوى الرئيسي بين الصفحات ---------- */
#main {
  transition: opacity 140ms var(--ease-out), transform 140ms var(--ease-out);
}

#main.is-nav-leaving {
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
}

@keyframes tessera-page-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

#main.is-nav-entering {
  animation: tessera-page-in 380ms var(--spring-smooth) both;
}

/* ---------- الهيدر ---------- */
.topbar {
  position: relative;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  margin-block-end: clamp(24px, 4vw, 48px);
}

.brand { display: inline-flex; align-items: center; gap: 12px; }
.brand__mark {
  display: grid; place-items: center; flex: none;
  color: var(--ink);
}
.brand__mark .logo { width: 52px; height: 52px; }
.brand__logo { width: 44px; height: 44px; color: var(--ink); flex: none; }
.brand__name { font-family: var(--font-latin); font-weight: 800; font-size: 1.4rem; letter-spacing: -0.03em; }

.icon { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: none; }

.nav-pill,
.pill-group {
  display: flex; align-items: center; gap: 6px;
  padding: 6px;
  background: var(--dark);
  border-radius: var(--r-pill);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.07);
}

.nav-link {
  display: inline-flex; align-items: center; justify-content: center; gap: 0;
  height: 46px; min-width: 46px; padding-inline: 0;
  border-radius: var(--r-pill);
  font-size: 0.85rem; font-weight: 700; white-space: nowrap;
  color: var(--on-dark);
  background: rgba(255, 255, 255, 0.12);
  transition:
    background 320ms var(--ease-out),
    color 240ms var(--ease-out),
    padding-inline 520ms var(--spring-smooth),
    gap 520ms var(--spring-smooth),
    scale var(--dur-slow) var(--spring-bouncy);
}

.nav-link > span {
  display: inline-block;
  max-width: 0;
  opacity: 0;
  overflow: hidden;
  white-space: nowrap;
  transition:
    max-width 520ms var(--spring-smooth),
    opacity 200ms var(--ease-out);
}

.nav-link:hover { background: rgba(255, 255, 255, 0.22); }
.nav-link:active { scale: 0.94; }

.nav-link.is-active {
  background: var(--pink);
  color: var(--on-color);
  gap: 8px;
  padding-inline: 18px;
}

.nav-link.is-active > span {
  max-width: var(--nav-w, 96px);
  opacity: 1;
  transition:
    max-width 520ms var(--spring-smooth),
    opacity 320ms var(--ease-out) 60ms;
}

.topbar__actions { position: relative; display: flex; align-items: center; gap: 12px; }

.icon-pill {
  width: 46px; height: 46px; border-radius: 50%;
  display: grid; place-items: center;
  background: rgba(255, 255, 255, 0.12); color: var(--on-dark);
  transition: scale var(--dur-slow) var(--spring-bouncy), background var(--t-fast);
}
.icon-pill:hover { background: rgba(255, 255, 255, 0.22); scale: 1.06; }
.icon-pill:active { scale: 0.92; }
.theme-toggle .icon--sun { display: none; }
[data-theme="dark"] .theme-toggle .icon--sun { display: block; }
[data-theme="dark"] .theme-toggle .icon--moon { display: none; }

.avatar-btn {
  width: 54px; height: 54px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: var(--pink); color: var(--on-color);
  transition: scale var(--dur-slow) var(--spring-bouncy), box-shadow 300ms var(--ease-out);
}
.avatar-btn:hover { scale: 1.06; }
.avatar-btn:active { scale: 0.92; }
.avatar-btn .icon { fill: currentColor; stroke: none; }
.avatar-btn.is-current { box-shadow: 0 0 0 3px var(--dark), 0 0 0 5px var(--pink); }

/* ---------- لوحة الإشعارات ---------- */
.notif-panel {
  position: absolute;
  inset-block-start: calc(100% + 12px);
  inset-inline-end: 0;
  z-index: 60;
  width: min(340px, calc(100vw - 32px));
  padding: 18px;
  background: var(--card-2);
  border: 1px solid var(--line);
  box-shadow: var(--shadow-card);
  display: grid;
  gap: 12px;
}
.notif-panel[hidden] { display: none; }
.notif-panel__head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.notif-panel__title { font-size: 0.98rem; }
.notif-panel__action { font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.notif-panel__action[hidden] { display: none; }
.notif-panel__action:hover { color: var(--ink); text-decoration: underline; }
.notif-panel__body { display: grid; gap: 8px; max-height: 300px; overflow-y: auto; }
.notif-panel__empty { display: grid; gap: 10px; padding: 14px 8px; text-align: center; font-size: 0.86rem; color: var(--muted); }
.notif-panel__link {
  justify-self: center; padding: 8px 18px; border-radius: var(--r-pill);
  background: var(--pink); color: var(--on-color); font-size: 0.82rem; font-weight: 700;
}
.notif-item {
  display: grid; gap: 3px; padding: 10px 12px;
  border-radius: var(--r-sm); background: var(--card);
}
.notif-item.is-unread { box-shadow: inset 3px 0 0 var(--pink); }
[dir="rtl"] .notif-item.is-unread { box-shadow: inset -3px 0 0 var(--pink); }
.notif-item__title { font-size: 0.85rem; }
.notif-item__body { font-size: 0.78rem; color: var(--muted); }

/* ---------- الأزرار ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px 24px;
  border-radius: var(--r-pill);
  font-weight: 700; font-size: 0.95rem;
  transition: transform var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
}
.btn:hover { transform: translateY(-2px); }
.btn--pink { background: var(--pink); color: var(--on-color); }
.btn--pink:hover { box-shadow: 0 10px 24px rgba(228, 184, 230, 0.55); }
.btn--dark { background: var(--dark); color: var(--on-dark); }
.btn--ghost { border: 2px solid var(--line); color: var(--ink); }
.btn--ghost:hover { border-color: var(--ink); }
.btn--lg { padding: 18px 32px; font-size: 1.05rem; }

.btn__spinner {
  display: none;
  width: 18px; height: 18px; border-radius: 50%;
  border: 2.5px solid currentColor;
  border-inline-end-color: transparent;
  animation: tessera-spin 0.7s linear infinite;
}
.btn.is-loading { opacity: 0.82; pointer-events: none; }
.btn.is-loading .btn__spinner { display: inline-block; }
.btn.is-loading .arrow { display: none; }
@keyframes tessera-spin { to { transform: rotate(360deg); } }

.arrow { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
[dir="rtl"] .arrow { transform: scaleX(-1); }

/* ---------- البطاقات والتنبيهات ---------- */
.card {
  background: var(--card);
  border-radius: var(--r-lg);
  padding: clamp(20px, 2.2vw, 28px);
  min-width: 0;
}
.card--pink { background: var(--pink); color: var(--on-color); }
.card--blue { background: var(--blue); color: var(--on-color); }
.card--lav  { background: var(--lav);  color: var(--on-color); }
.card--dark { background: var(--dark); color: var(--on-dark); }
.card--dark .muted { color: var(--on-dark-muted); }

.muted { color: var(--muted); }
.card--pink .muted, .card--blue .muted, .card--lav .muted { color: rgba(17, 17, 17, 0.62); }

.card__title { font-size: 1.15rem; margin-block-end: 8px; }
.card__text { font-size: 0.95rem; color: var(--muted); }
.card--pink .card__text, .card--blue .card__text, .card--lav .card__text { color: rgba(17, 17, 17, 0.7); }
.card--dark .card__text { color: var(--on-dark-muted); }

.divider { height: 1px; background: var(--line); border: 0; margin-block: 14px; }
.card--pink .divider, .card--blue .divider, .card--lav .divider { background: rgba(0, 0, 0, 0.14); }
.card--dark .divider { background: rgba(255, 255, 255, 0.12); }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: var(--r-pill);
  font-size: 0.78rem; font-weight: 600;
  background: var(--track);
}
.card--dark .chip { background: rgba(255, 255, 255, 0.12); }

.icon-badge {
  width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--blue); color: var(--on-color);
}

.form-alert {
  padding: 14px 16px;
  border-radius: var(--r-md);
  font-size: 0.9rem; font-weight: 600;
  border: 1.5px solid transparent;
}
.form-alert[hidden] { display: none; }
.form-alert--error {
  background: color-mix(in srgb, var(--err) 12%, var(--card-2));
  border-color: color-mix(in srgb, var(--err) 35%, transparent);
  color: var(--err);
}
.form-alert--success {
  background: color-mix(in srgb, var(--green) 22%, var(--card-2));
  border-color: color-mix(in srgb, var(--ok) 35%, transparent);
  color: var(--ok);
}

/* ---------- عناوين الأقسام ---------- */
.section { margin-block-start: clamp(56px, 8vw, 104px); }
.section__head { margin-block-end: clamp(20px, 3vw, 32px); max-width: 640px; }
.section__eyebrow { font-size: 0.85rem; font-weight: 700; color: var(--muted); margin-block-end: 6px; }
.section__title { font-size: clamp(1.6rem, 3.2vw, 2.4rem); }
.section__lead { margin-block-start: 10px; color: var(--muted); }

/* ---------- الفوتر ---------- */
.footer {
  margin-block-start: clamp(56px, 8vw, 96px);
  padding-block-start: 28px;
  border-block-start: 1px solid var(--line);
  display: grid; gap: 24px;
}
.footer__row { display: flex; flex-wrap: wrap; gap: 20px 40px; justify-content: space-between; align-items: center; }
.footer__links { display: flex; flex-wrap: wrap; gap: 8px 22px; font-size: 0.9rem; font-weight: 600; }
.footer__links a:hover { text-decoration: underline; text-underline-offset: 4px; }
.footer__note { font-size: 0.82rem; color: var(--muted); max-width: 760px; }

.label { display: block; font-size: 1rem; font-weight: 700; padding-inline: 4px; }

@media (max-width: 760px) {
  .topbar { flex-wrap: wrap; }
  .nav-pill { order: 3; width: 100%; justify-content: space-between; overflow-x: auto; scrollbar-width: none; }
  .nav-pill::-webkit-scrollbar { display: none; }
}