/* ============================================================
   Unified TOP navigation — Nusoos 2026
   One horizontal nav shared by every app/public page.
   Fixed to the top, full-width, RTL-correct, clear text labels,
   collapses to a hamburger drawer on mobile.
   Does NOT consume horizontal content width (unlike a sidebar).
   ============================================================ */
:root { --topnav-h: 62px; }
@media (max-width: 768px) { :root { --topnav-h: 56px; } }

/* content offset for the fixed bar */
body.has-topnav { padding-top: var(--topnav-h); }

/* ---- shell ---- */
.topnav {
  position: fixed; top: 0; inset-inline: 0;
  height: var(--topnav-h); z-index: 60;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  /* subtle elevation so content scrolls cleanly beneath */
  box-shadow: 0 1px 0 rgba(0,0,0,.02);
}
html[data-theme="dark"] .topnav { background: var(--surface); }

.topnav-inner {
  height: 100%;
  max-width: 1320px; margin: 0 auto;
  padding: 0 20px;
  display: flex; align-items: center; gap: 8px;
}

/* ---- brand (start side = right in RTL) ---- */
.tn-brand {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none; flex-shrink: 0;
  margin-inline-end: 8px;
}
.tn-logo { width: 34px; height: 34px; border-radius: 9px; flex-shrink: 0; }
.tn-brand-name {
  font-size: 1.32rem; font-weight: 800; color: var(--brand-600);
  letter-spacing: -.01em; white-space: nowrap;
}

/* ---- primary links ---- */
.tn-links {
  display: flex; align-items: center; gap: 2px;
  margin-inline-start: 6px; min-width: 0;
}
.tn-link {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 11px; border-radius: 10px;
  color: var(--text-secondary);
  text-decoration: none; white-space: nowrap;
  font-size: .875rem; font-weight: 600;
  transition: background .15s ease, color .15s ease;
}
@media (max-width: 1320px) { .tn-link { padding: 8px 9px; font-size: .85rem; } .tn-links { gap: 0; } }
.tn-link:hover { background: var(--surface-hover); color: var(--text-primary); }
.tn-link.is-active { background: var(--brand-50); color: var(--brand-700); }
.tn-ic { width: 19px; height: 19px; flex-shrink: 0; }
.tn-ic svg { width: 19px; height: 19px; display: block; }

/* ---- actions (end side = left in RTL) ---- */
.tn-actions {
  display: flex; align-items: center; gap: 8px;
  margin-inline-start: auto; flex-shrink: 0;
}

/* icon button base (theme toggle, bell) */
.tn-icon-btn {
  position: relative;
  width: 40px; height: 40px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; cursor: pointer;
  color: var(--text-secondary); background: transparent;
  border: 1px solid var(--border);
  transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.tn-icon-btn:hover { background: var(--surface-hover); color: var(--text-primary); }
.tn-icon-btn svg { width: 20px; height: 20px; }
.tn-theme-toggle .icon-sun { display: none; }

/* balance pill */
.tn-balance {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 8px 14px; border-radius: 999px; text-decoration: none;
  font-size: .86rem; font-weight: 700;
  background: var(--brand-50); color: var(--brand-700);
  border: 1px solid transparent;
  transition: background .15s ease;
}
.tn-balance:hover { background: var(--brand-100); }
.tn-balance svg { width: 17px; height: 17px; }

/* login CTA (guest) */
.tn-cta {
  display: inline-flex; align-items: center; gap: 7px;
  padding: 9px 18px; border-radius: 999px; text-decoration: none;
  font-size: .88rem; font-weight: 700;
  background: var(--brand-600); color: #fff;
  transition: background .15s ease;
}
.tn-cta:hover { background: var(--brand-700); }
.tn-cta-ghost {
  background: transparent; color: var(--text-secondary);
  border: 1px solid var(--border); padding: 8px 16px;
}
.tn-cta-ghost:hover { background: var(--surface-hover); color: var(--text-primary); }

/* ---- user menu ---- */
.tn-user { position: relative; flex-shrink: 0; }
.tn-user-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 5px 10px 5px 6px; border-radius: 999px; cursor: pointer;
  background: transparent; border: 1px solid var(--border);
  color: var(--text-primary); transition: background .15s ease;
}
.tn-user-btn:hover { background: var(--surface-hover); }
.tn-user-avatar {
  width: 30px; height: 30px; flex-shrink: 0; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--brand-600); color: #fff; font-weight: 800; font-size: .9rem;
}
/* Inline username is avatar-only by default (name lives in the dropdown head);
   revealed beside the avatar only when there is plenty of room. */
.tn-user-name { display: none; font-size: .86rem; font-weight: 600; max-width: 130px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 1400px) { .tn-user-name { display: inline; } }
.tn-user-caret { width: 15px; height: 15px; flex-shrink: 0; color: var(--text-tertiary); }
.tn-user-menu {
  position: absolute; top: calc(100% + 8px); inset-inline-start: 0;
  min-width: 200px;
  background: var(--surface-elevated); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden; z-index: 70;
  padding: 6px;
}
.tn-user-menu.hidden { display: none; }
.tn-user-head {
  padding: 10px 12px 12px; border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.tn-user-head .nm { font-weight: 700; font-size: .92rem; color: var(--text-primary); }
.tn-user-head .bal { font-size: .8rem; color: var(--text-tertiary); margin-top: 2px; }
.tn-user-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: start;
  padding: 10px 12px; border-radius: 9px;
  font-size: .88rem; color: var(--text-secondary);
  background: transparent; border: none; cursor: pointer; text-decoration: none;
  transition: background .12s ease;
}
.tn-user-item:hover { background: var(--surface-hover); color: var(--text-primary); }
.tn-user-item svg { width: 17px; height: 17px; flex-shrink: 0; }
.tn-user-logout { color: var(--danger); }
.tn-user-logout:hover { color: var(--danger); background: var(--surface-hover); }

/* ---- hamburger (mobile only) ---- */
.tn-burger { display: none; }

/* ============================================================
   Mobile drawer panel (slides down under the bar)
   ============================================================ */
.tn-mobile {
  position: fixed; top: var(--topnav-h); inset-inline: 0;
  z-index: 59;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 10px 14px 16px;
  display: flex; flex-direction: column; gap: 2px;
  max-height: calc(100vh - var(--topnav-h)); overflow-y: auto;
}
.tn-mobile[hidden] { display: none; }
.tn-mobile .tn-link {
  width: 100%; padding: 12px 14px; font-size: .95rem; border-radius: 11px;
}
.tn-mobile-sep { height: 1px; background: var(--border); margin: 8px 4px; }
.tn-mobile-cta { display: flex; flex-direction: column; gap: 8px; margin-top: 6px; }
.tn-mobile-cta .tn-cta, .tn-mobile-cta .tn-cta-ghost { justify-content: center; }

/* overlay behind the drawer */
.tn-overlay { display: none; }

/* ============================================================
   Responsive — collapse links into the hamburger.
   Below 1200px the full text-link row would crowd the actions on
   small laptops, so we switch to the hamburger drawer (which holds
   every link cleanly). Text links show only when there is real room.
   ============================================================ */
@media (max-width: 1023px) {
  .tn-links { display: none; }
  .tn-burger {
    display: inline-flex; align-items: center; justify-content: center;
    width: 42px; height: 42px; flex-shrink: 0;
    border-radius: 10px; cursor: pointer;
    color: var(--text-primary); background: transparent;
    border: 1px solid var(--border);
  }
  .tn-burger svg { width: 22px; height: 22px; }
  .topnav-inner { padding: 0 14px; }
  .tn-overlay {
    display: block; position: fixed; inset: 0; z-index: 58;
    background: rgba(15,23,42,.45); opacity: 0; pointer-events: none;
    transition: opacity .2s ease;
  }
  .tn-open .tn-overlay { opacity: 1; pointer-events: auto; }
}
@media (max-width: 460px) {
  .tn-balance { display: none; }   /* balance lives in the drawer on tiny screens */
  .tn-cta-ghost { display: none; }
}

/* print: never show app chrome */
@media print {
  .topnav, .tn-mobile, .tn-overlay { display: none !important; }
  body.has-topnav { padding-top: 0 !important; }
}
