/* app-header.css — Shared inner-page header (Home V2, Profile V2, …)
 *
 * Two systems live here:
 *   1. CSS variables — all inner pages consume these for visual consistency.
 *   2. .sc-header + .sc-* — the shared header structure used by Home V2 and
 *      Profile V2. Profile V2 keeps a duplicate of these rules in profile-v2.css
 *      (no build step to deduplicate — by design, see ARCHITECTURE.md).
 */

/* ── Variables ── */
:root {
  --ah-h:    44px;
  --ah-bg:   var(--color-surface-glass);
  --ah-blur: blur(14px);
  --ah-brd:  var(--color-border-default);
  --ah-muted: rgba(var(--color-ink-rgb), .5);
  --ah-g: var(--color-brand-primary);
  --ah-b: var(--color-brand-secondary);
  --ah-bnav-h: 60px;   /* unified bottom nav (HEADER-NAV.md HNAV-06) */

  /* Home button — pages can override these three vars for per-page theming */
  --hdr-home-accent: var(--color-brand-primary);
  --hdr-home-glow:   rgba(var(--color-brand-primary-rgb), .28);
  --hdr-home-bg:     rgba(var(--color-brand-primary-rgb), .07);
}

/* ── Shared header bar ── */
.sc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: var(--ah-h);
  min-height: 0;
  box-sizing: border-box;
  /* position/top intentionally omitted — each page sets its own:
     Profile V2 → position:sticky in profile-v2.css
     Home V2    → position:fixed  in home-v2.css            */
  z-index: 100;
  background: var(--ah-bg);
  backdrop-filter: var(--ah-blur);
  -webkit-backdrop-filter: var(--ah-blur);
  border-bottom: 0 !important;
  box-shadow: none !important;
}

/* Logo — absolute center so left/right groups stay balanced */
.sc-header .sc-logo {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  pointer-events: none;
}
.sc-logo img { height: 32px; width: auto; max-width: 120px; object-fit: contain; display: block; }
.sc-logo-fallback {
  font-weight: 800; font-size: 1rem; letter-spacing: -.3px;
  background: linear-gradient(135deg, var(--ah-g), var(--ah-b));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}

/* Generic icon button (square with rounded corners) */
.sc-hicon {
  width: 32px; height: 32px; border-radius: 10px; border: none; cursor: pointer;
  background: rgba(var(--color-ink-rgb), .06); color: var(--color-text-primary); font-size: 1rem;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; font-family: inherit;
}
/* Ghost/bare variant — no background, auto-sized by icon */
.sc-hicon-bare {
  width: auto; height: auto; padding: 4px;
  background: none !important; border: none !important;
  text-decoration: none; color: var(--color-text-secondary);
  transition: color .15s;
}
.sc-hicon-bare:hover { color: var(--color-text-body); }
.sc-hicon-bare .ico { width: 20px; height: 20px; }

/* Glow-square home button — size, shape, and glow driven by CSS vars */
.sc-home-btn {
  width: 40px; height: 40px;
  border-radius: 11px;
  flex-shrink: 0;
  background: var(--hdr-home-bg);
  border: 1.5px solid var(--hdr-home-glow);
  box-shadow: 0 0 10px var(--hdr-home-glow),
              inset 0 0 6px var(--hdr-home-glow);
  color: var(--hdr-home-accent);
  transition: box-shadow .2s, border-color .2s;
}
.sc-home-btn .ico {
  width: 19px; height: 19px;
  filter: drop-shadow(0 0 3px var(--hdr-home-glow));
}
.sc-home-btn:hover,
.sc-home-btn:focus-visible {
  box-shadow: 0 0 18px var(--hdr-home-glow),
              inset 0 0 10px var(--hdr-home-glow);
  border-color: var(--hdr-home-accent);
}
.sc-home-btn:active { transform: scale(.93); }

/* Right group (RTL-start: visually right) — wraps home button + any owner-only icon.
   Keeps logo absolute-centered by ensuring sc-header has only 2 flex children. */
.sc-head-right { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }

/* Icon group on the left side (RTL end: visually left) */
.sc-head-icons { display: flex; align-items: center; gap: 8px; }

/* ── Dropdown menu ── */
.sc-menu-wrap { position: relative; }
.sc-menu-dropdown {
  display: none; position: absolute; top: calc(100% + 8px); left: 0; min-width: 180px;
  background: var(--color-surface-glass); border: 1px solid var(--color-border-medium);
  border-radius: 13px; padding: 5px; z-index: 200;
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  box-shadow: 0 10px 30px rgba(var(--color-overlay-rgb), .45);
}
.sc-menu-dropdown.open { display: block; }
.sc-menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  padding: 9px 12px; border: none; background: none;
  color: var(--color-text-primary); font-family: inherit; font-size: 12px; font-weight: 600;
  border-radius: 8px; cursor: pointer; text-align: right; text-decoration: none;
  transition: background .15s;
}
.sc-menu-item:hover { background: var(--color-surface-hover); }
.sc-menu-sep { height: 1px; background: var(--color-border-default); margin: 3px 8px; }
.sc-menu-item.danger { color: var(--color-status-danger); }
.sc-menu-item.danger:hover { background: rgba(var(--color-status-danger-rgb), .1); }

/* SVG icons inside dynamically-rendered menu items (tw_shared.js _twHeaderMenuItemHtml) */
.sc-svg-icon-sm { width: 14px; height: 14px; flex-shrink: 0; }
.sc-menu-item .sc-svg-icon-sm          { color: var(--ac); }
.sc-menu-item.danger .sc-svg-icon-sm   { color: var(--color-status-danger); }

/* Disabled ("قريباً") menu item — visual only, not interactive */
.sc-menu-item.disabled {
  color: var(--color-text-placeholder);
  cursor: default;
  pointer-events: none;
  justify-content: space-between;
}
.sc-menu-item.disabled .sc-svg-icon-sm { color: var(--color-text-placeholder); }
.sc-menu-item.disabled:hover           { background: none; }

/* "قريباً" pill badge */
.sc-menu-soon {
  font-size: .6rem; font-weight: 700;
  background: var(--color-surface-hover); color: var(--color-text-placeholder);
  border-radius: 999px; padding: 1px 6px;
  margin-right: auto;
}

/* Notification unread badge — positioned relative to bell icon wrapper */
.sc-notif-wrap { position: relative; display: inline-flex; overflow: visible; }
[data-ah-notif-badge] {
  display: none; /* JS sets inline-flex to show */
  position: absolute;
  top: -4px; right: -4px; /* physical — no RTL flip */
  min-width: 16px; height: 16px;
  background: var(--color-status-danger-strong); color: var(--color-text-on-fill);
  font-size: 10px; font-weight: 700;
  border-radius: 8px; padding: 0 3px;
  line-height: 1; text-align: center;
  align-items: center; justify-content: center;
  pointer-events: none; z-index: 20;
}


/* ══ Unified App Header + Bottom Nav (docs/design-system/HEADER-NAV.md) ══════
 * Rendered by twMountAppChrome() (tw_shared.js) into <header data-tw-header>
 * and <nav data-tw-bottom-nav>. Sizes = DS-SIZE tokens · colours = DS-COLOR tokens.
 * Pages never restyle these — one header for the whole site. */
[data-tw-header] { display: flex; height: var(--ah-h); }   /* reserves the height before mount */
.sc-header.tw-hdr {
  position: sticky; top: 0; inset-inline: 0;
  padding: 0 var(--space-8);
  font-family: 'Cairo', sans-serif;
}
.tw-hdr .sc-home-btn {
  width: var(--size-control-icon-lg); height: var(--size-control-icon-lg);
  border-radius: var(--radius-md);
  text-decoration: none;
}
.tw-hdr .sc-hicon-bare { color: var(--color-text-secondary); position: relative; }
.tw-hdr .sc-hicon-bare:hover { color: var(--color-text-primary); }
.tw-hdr .tw-hdr-ico.is-current { color: var(--color-brand-primary); }
.tw-hdr .sc-head-icons { gap: var(--space-4); }
.tw-hdr .sc-head-right { gap: var(--space-3); }
.tw-hdr .sc-logo img { height: 32px; width: auto; max-width: 120px; }

/* Header badges — bell + messages, one style, one cap (twNotifBadgeLabel → 99+) */
.tw-hdr-badge {
  display: none;   /* loadGlobalBadges / Badge WS set inline-block when count > 0 */
  position: absolute; top: -2px; right: -4px;   /* physical — no RTL flip */
  min-width: 16px; height: 16px; padding: 0 var(--space-1);
  border-radius: var(--radius-pill);
  background: var(--color-status-danger); color: var(--color-text-primary);
  font-size: var(--size-font-3xs); font-weight: 700;
  line-height: 16px; text-align: center;
  pointer-events: none;
}

/* Guest actions — login / register */
.tw-hdr-auth {
  display: inline-flex; align-items: center;
  height: var(--size-control-sm); padding: 0 var(--space-5);
  border-radius: var(--radius-control);
  border: 1px solid var(--color-border-strong);
  color: var(--color-text-primary); text-decoration: none;
  font-size: var(--size-font-xs); font-weight: 700; white-space: nowrap;
}
.tw-hdr-auth--primary { background: var(--color-brand-primary); border-color: var(--color-brand-primary); color: var(--color-surface-page); }

/* Bottom nav — mobile / tablet only, authenticated only */
.tw-bnav {
  position: fixed; bottom: 0; inset-inline: 0; z-index: 100;
  height: calc(var(--ah-bnav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex; align-items: stretch;
  background: var(--ah-bg);
  backdrop-filter: var(--ah-blur); -webkit-backdrop-filter: var(--ah-blur);
  border-top: 1px solid var(--color-border-default);
  font-family: 'Cairo', sans-serif;
}
.tw-bnav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: var(--space-1); min-width: 0;
  color: var(--color-text-muted); text-decoration: none;
  font-size: var(--size-font-2xs); font-weight: 600;
  transition: color .15s;
}
.tw-bnav-item:hover, .tw-bnav-item.is-current { color: var(--color-brand-primary); }
body.tw-has-bnav { padding-bottom: calc(var(--ah-bnav-h) + env(safe-area-inset-bottom, 0px)); }
@media (min-width: 1020px) {
  .tw-bnav { display: none; }
  body.tw-has-bnav { padding-bottom: 0; }
}
