/* Shared training header / primary navigation — TryHackMe-style horizontal bar (RTL) */

.app-nav {
  position: sticky;
  top: 0;
  z-index: 200;
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 1px 0 rgba(115, 20, 175, 0.06);
  backdrop-filter: blur(18px);
}

.app-nav-inner {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0.6rem clamp(0.85rem, 3vw, 1.75rem);
}

/* Brand (right side in RTL) */
.app-nav-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  flex: 0 0 auto;
  color: var(--text);
  text-decoration: none;
}

.app-nav-logo {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  padding: 7px;
  background: var(--logo-bg);
  border-radius: var(--radius-md);
}

.app-nav-logo svg {
  width: 100%;
  height: 100%;
  stroke: var(--logo-stroke) !important;
}

.app-nav-logo:has(img) {
  padding: 0;
  overflow: hidden;
  background: transparent;
}

.app-nav-logo img,
.app-nav-logo-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: var(--radius-md);
}

.app-nav-brandtext { display: flex; flex-direction: column; line-height: 1.2; }
.app-nav-brandtext strong { font-size: 1.02rem; font-weight: 900; }
.app-nav-brandtext span { color: var(--muted); font-size: 0.72rem; font-weight: 600; }

/* Primary menu (center) */
.app-nav-menu {
  display: flex;
  align-items: center;
  gap: 0.2rem;
  flex: 1 1 auto;
  justify-content: center;
}

.app-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.5rem 0.85rem;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.9rem;
  font-weight: 800;
  text-decoration: none;
  white-space: nowrap;
  transition: background var(--transition-ui), color var(--transition-ui), border-color var(--transition-ui);
}

.app-nav-link svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.app-nav-link:hover {
  background: var(--surface-hover);
  color: var(--text);
}

.app-nav-link.is-active {
  background: var(--accent-soft);
  border-color: var(--accent-ring);
  color: var(--brand-blue);
}

:root[data-theme="dark"] .app-nav-link.is-active { color: var(--brand-blue); }

/* Utility cluster (left side in RTL) */
.app-nav-utils {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 0 auto;
}

/* Hamburger */
.app-nav-burger {
  display: none;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  margin-inline-start: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  color: var(--text);
  cursor: pointer;
}

.app-nav-burger svg { width: 22px; height: 22px; stroke: currentColor; }
.app-nav-burger .icon-close { display: none; }
.app-nav.is-open .app-nav-burger .icon-open { display: none; }
.app-nav.is-open .app-nav-burger .icon-close { display: inline; }

@media (max-width: 61.25em) {
  .app-nav-inner { flex-wrap: wrap; gap: 0.6rem; }
  .app-nav-brand { flex: 1 1 auto; }
  .app-nav-burger { display: inline-flex; }

  .app-nav-menu,
  .app-nav-utils {
    display: none;
    flex-basis: 100%;
    flex-direction: column;
    align-items: stretch;
    gap: 0.35rem;
    width: 100%;
  }

  .app-nav.is-open .app-nav-menu,
  .app-nav.is-open .app-nav-utils {
    display: flex;
  }

  .app-nav.is-open .app-nav-utils {
    margin-top: 0.35rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--border);
    flex-direction: row;
    flex-wrap: wrap;
  }

  .app-nav-link {
    justify-content: flex-start;
    padding: 0.7rem 0.85rem;
    font-size: 0.98rem;
  }
}

@media (max-width: 35em) {
  .app-nav-brandtext span { display: none; }
}

/* Admin-only chrome (shared with reports pages) */
.admin-only { display: none !important; }
body.is-admin .admin-only { display: inline-flex !important; }

.app-nav-logout {
  text-decoration: none !important;
  text-transform: lowercase;
  font-family: var(--font-en);
  font-weight: 700;
  letter-spacing: 0.02em;
}

.app-nav-lang {
  min-width: 3.4rem;
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* Document direction comes from <html dir> (set by js/i18n.js: rtl for fa, ltr for en).
   Do not force direction:ltr here — that blocked Persian RTL. */

.theme-toggle-btn {
  padding: 0.45rem;
  min-width: 2.35rem;
}

.theme-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
}

/* Tools dropdown */
.app-nav-dropdown {
  position: relative;
}

.app-nav-dropdown-trigger {
  cursor: pointer;
  background: transparent;
  font: inherit;
}

.app-nav-dropdown-trigger svg:last-child {
  width: 14px;
  height: 14px;
  opacity: 0.65;
  margin-inline-start: 0.1rem;
}

.app-nav-dropdown.is-active > .app-nav-dropdown-trigger,
.app-nav-dropdown.is-open > .app-nav-dropdown-trigger {
  background: var(--accent-soft);
  border-color: var(--accent-ring);
  color: var(--brand-blue);
}

.app-nav-dropdown-panel {
  position: absolute;
  top: calc(100% + 0.35rem);
  inset-inline-end: 0;
  min-width: 15.5rem;
  padding: 0.35rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card);
  box-shadow: var(--shadow-md);
  z-index: 220;
}

.app-nav-dropdown-panel[hidden] {
  display: none !important;
}

.app-nav-dropdown-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: 0.86rem;
  font-weight: 700;
  text-decoration: none;
  transition: background var(--transition-ui), color var(--transition-ui);
}

.app-nav-dropdown-item svg {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
}

.app-nav-dropdown-item:hover,
.app-nav-dropdown-item:focus-visible {
  background: var(--accent-soft);
  color: var(--brand-blue);
  outline: none;
}

.app-nav-dropdown-item.is-active {
  background: var(--accent-soft);
  color: var(--brand-blue);
}

.app-nav-dropdown-all {
  margin-top: 0.25rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--border);
}

@media (max-width: 61.25em) {
  .app-nav-dropdown {
    width: 100%;
  }

  .app-nav-dropdown-trigger {
    width: 100%;
    justify-content: flex-start;
  }

  .app-nav-dropdown-panel {
    position: static;
    width: 100%;
    margin-top: 0.25rem;
    box-shadow: none;
    border: 1px dashed var(--border);
  }
}

.theme-icon svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
}
