/*
  Kernex AppForge Top Navbar
  Purpose:
  - Replace inconvenient floating right-side action buttons.
  - Keep exactly 8 screens.
  - Improve desktop and mobile navigation.
*/

:root {
  --af-nav-bg: rgba(5, 12, 28, 0.96);
  --af-nav-line: rgba(120, 190, 255, 0.28);
  --af-nav-text: #eaf4ff;
  --af-nav-muted: #91a9c7;
  --af-nav-blue: #5cc8ff;
  --af-nav-green: #58f0a7;
  --af-nav-violet: #a78bfa;
  --af-nav-yellow: #ffd166;
  --af-nav-red: #ff6b6b;
}

/* Main top navigation */
.appforge-top-navbar {
  position: sticky;
  top: 0;
  z-index: 99990;
  width: 100%;
  min-height: 54px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  background:
    radial-gradient(circle at 2% 0%, rgba(92, 200, 255, .18), transparent 28%),
    linear-gradient(135deg, rgba(5,12,28,.98), rgba(9,20,42,.96));
  color: var(--af-nav-text);
  border-bottom: 1px solid var(--af-nav-line);
  box-shadow: 0 18px 60px rgba(0,0,0,.35);
  backdrop-filter: blur(16px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.appforge-top-navbar * {
  box-sizing: border-box;
}

.appforge-top-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 205px;
}

.appforge-top-logo {
  width: 34px;
  height: 34px;
  border-radius: 13px;
  background: linear-gradient(135deg, var(--af-nav-blue), var(--af-nav-violet));
  box-shadow: 0 0 28px rgba(92,200,255,.38);
  flex: 0 0 auto;
}

.appforge-top-brand-text {
  display: grid;
  gap: 1px;
}

.appforge-top-brand-title {
  font-size: 0.86rem;
  line-height: 1.05;
  font-weight: 900;
  letter-spacing: .01em;
  color: var(--af-nav-text);
  white-space: nowrap;
}

.appforge-top-brand-subtitle {
  font-size: 0.68rem;
  line-height: 1.1;
  color: var(--af-nav-muted);
  white-space: nowrap;
}

.appforge-top-menu {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 3px 2px;
  scrollbar-width: thin;
  scrollbar-color: rgba(120,190,255,.45) transparent;
}

.appforge-top-menu::-webkit-scrollbar {
  height: 5px;
}

.appforge-top-menu::-webkit-scrollbar-thumb {
  background: rgba(120,190,255,.38);
  border-radius: 999px;
}

.appforge-top-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 7px 10px;
  border: 1px solid rgba(120,190,255,.24);
  border-radius: 999px;
  color: var(--af-nav-text);
  text-decoration: none;
  font-size: 0.72rem;
  line-height: 1;
  font-weight: 850;
  white-space: nowrap;
  background: rgba(255,255,255,.045);
  transition: transform .15s ease, border-color .15s ease, background .15s ease;
}

.appforge-top-link:hover {
  transform: translateY(-1px);
  border-color: rgba(120,190,255,.55);
  background: rgba(92,200,255,.11);
}

.appforge-top-link.active {
  color: #04101f;
  border-color: transparent;
  box-shadow: 0 0 24px rgba(92,200,255,.28);
}

.appforge-top-link.home.active,
.appforge-top-link.home:hover {
  background: linear-gradient(135deg, #5cc8ff, #a78bfa);
}

.appforge-top-link.builder.active,
.appforge-top-link.builder:hover {
  background: linear-gradient(135deg, #a78bfa, #5cc8ff);
}

.appforge-top-link.preview.active,
.appforge-top-link.preview:hover {
  background: linear-gradient(135deg, #5cc8ff, #58f0a7);
}

.appforge-top-link.correction.active,
.appforge-top-link.correction:hover {
  background: linear-gradient(135deg, #ffd166, #5cc8ff);
}

.appforge-top-link.write.active,
.appforge-top-link.write:hover {
  background: linear-gradient(135deg, #58f0a7, #a78bfa);
}

.appforge-top-link.commit.active,
.appforge-top-link.commit:hover {
  background: linear-gradient(135deg, #a78bfa, #5cc8ff);
}

.appforge-top-link.materialize.active,
.appforge-top-link.materialize:hover {
  background: linear-gradient(135deg, #58f0a7, #a78bfa);
}

.appforge-top-link.relationships.active,
.appforge-top-link.relationships:hover {
  background: linear-gradient(135deg, #5cc8ff, #58f0a7);
}

.appforge-top-right {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 126px;
}

.appforge-top-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 6px 9px;
  border: 1px solid rgba(88,240,167,.35);
  border-radius: 999px;
  color: var(--af-nav-green);
  background: rgba(88,240,167,.08);
  font-size: 0.68rem;
  font-weight: 900;
  white-space: nowrap;
}

.appforge-top-toggle {
  display: none;
  border: 1px solid rgba(120,190,255,.35);
  background: rgba(255,255,255,.06);
  color: var(--af-nav-text);
  border-radius: 999px;
  min-height: 30px;
  padding: 6px 9px;
  font-size: 0.72rem;
  font-weight: 900;
  cursor: pointer;
}

/* Hide old floating colored buttons generated by previous patches */
body > a[href="./builder.html"][style*="position:fixed"],
body > a[href="./preview.html"][style*="position:fixed"],
body > a[href="./correction.html"][style*="position:fixed"],
body > a[href="./write.html"][style*="position:fixed"],
body > a[href="./commit.html"][style*="position:fixed"],
body > a[href="./materialize.html"][style*="position:fixed"],
body > a[href="./relationships.html"][style*="position:fixed"],
body > a[href="./index.html"][style*="position:fixed"] {
  display: none !important;
}

/* Hide previous 8-screen freeze badge because it is now inside top navbar */
.stable8-freeze {
  display: none !important;
}

/* Reduce top crowding after navbar insertion */
body.appforge-top-navbar-enabled .shell {
  min-height: calc(100vh - 54px) !important;
}

body.appforge-top-navbar-enabled aside {
  top: 54px !important;
  height: calc(100vh - 54px) !important;
}

/* Tablet */
@media (max-width: 1180px) {
  .appforge-top-navbar {
    grid-template-columns: auto 1fr auto;
    padding: 7px 10px;
    gap: 8px;
  }

  .appforge-top-brand {
    min-width: 180px;
  }

  .appforge-top-brand-title {
    font-size: 0.78rem;
  }

  .appforge-top-brand-subtitle {
    font-size: 0.62rem;
  }

  .appforge-top-link {
    font-size: 0.68rem;
    padding: 6px 8px;
  }

  body.appforge-top-navbar-enabled aside {
    top: auto !important;
    height: auto !important;
  }
}

/* Mobile: navbar becomes compact dropdown */
@media (max-width: 760px) {
  .appforge-top-navbar {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "brand toggle"
      "menu menu";
    align-items: center;
    min-height: 48px;
    padding: 7px 9px;
  }

  .appforge-top-brand {
    grid-area: brand;
    min-width: 0;
  }

  .appforge-top-logo {
    width: 30px;
    height: 30px;
    border-radius: 11px;
  }

  .appforge-top-brand-title {
    font-size: 0.74rem;
  }

  .appforge-top-brand-subtitle {
    font-size: 0.58rem;
  }

  .appforge-top-right {
    grid-area: toggle;
    min-width: 0;
  }

  .appforge-top-badge {
    display: none;
  }

  .appforge-top-toggle {
    display: inline-flex;
  }

  .appforge-top-menu {
    grid-area: menu;
    display: none;
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    padding-top: 7px;
  }

  .appforge-top-navbar.open .appforge-top-menu {
    display: flex;
  }

  .appforge-top-link {
    font-size: 0.64rem;
    min-height: 29px;
    padding: 6px 8px;
  }

  body.appforge-top-navbar-enabled .shell {
    min-height: auto !important;
  }
}

/* Very small mobile */
@media (max-width: 430px) {
  .appforge-top-brand-title {
    font-size: 0.68rem;
  }

  .appforge-top-brand-subtitle {
    display: none;
  }

  .appforge-top-toggle {
    font-size: 0.66rem;
    padding: 5px 8px;
  }
}

/* APPFORGE_TOP_NAVBAR_BIGGER_FONT_OVERRIDE_START */
/* Increase only top navbar menu item fonts. Keeps 8-screen freeze unchanged. */

.appforge-top-link {
  font-size: 0.88rem !important;
  font-weight: 950 !important;
  padding: 9px 13px !important;
  min-height: 38px !important;
  letter-spacing: 0.01em !important;
}

.appforge-top-brand-title {
  font-size: 0.98rem !important;
}

.appforge-top-brand-subtitle {
  font-size: 0.74rem !important;
}

.appforge-top-badge {
  font-size: 0.78rem !important;
  padding: 7px 11px !important;
}

.appforge-top-toggle {
  font-size: 0.82rem !important;
  padding: 7px 11px !important;
}

/* Tablet */
@media (max-width: 1180px) {
  .appforge-top-link {
    font-size: 0.82rem !important;
    padding: 8px 11px !important;
    min-height: 36px !important;
  }

  .appforge-top-brand-title {
    font-size: 0.9rem !important;
  }

  .appforge-top-brand-subtitle {
    font-size: 0.68rem !important;
  }
}

/* Mobile */
@media (max-width: 760px) {
  .appforge-top-link {
    font-size: 0.78rem !important;
    padding: 8px 10px !important;
    min-height: 34px !important;
  }

  .appforge-top-brand-title {
    font-size: 0.86rem !important;
  }

  .appforge-top-toggle {
    font-size: 0.78rem !important;
  }
}

/* Very small mobile */
@media (max-width: 430px) {
  .appforge-top-link {
    font-size: 0.74rem !important;
    padding: 7px 9px !important;
  }

  .appforge-top-brand-title {
    font-size: 0.78rem !important;
  }
}
/* APPFORGE_TOP_NAVBAR_BIGGER_FONT_OVERRIDE_END */
