/* ============================================================
   Layout — Docker Desktop inspired (top bar + clean canvas)
   Horizontal top bar, full-width content area below.
   ============================================================ */

:root {
  --topbar-height: 72px;
  --content-pad-x: 28px;
  --content-pad-y: 24px;
  --content-max: 1200px;
}

body {
  padding-top: var(--topbar-height);
  background: var(--color-bg);
}

.container {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--content-pad-y) var(--content-pad-x);
  flex: 1;
}

.app-main {
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--content-pad-y) var(--content-pad-x);
  flex: 1;
}

@media (max-width: 768px) {
  .container,
  .app-main {
    padding: 16px;
  }
}

/* ============================================================
   Top bar — Docker Desktop style
   ============================================================ */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  z-index: 100;
  display: flex;
  align-items: center;
  /* Subtle inner shadow line for depth (Docker uses this trick) */
  box-shadow: 0 1px 0 0 rgba(15, 23, 42, 0.04);
}
/* Remove the previous orange gradient bar */
.topbar::after { content: none; }

.topbar__inner {
  width: 100%;
  height: 100%;
  margin: 0 auto;
  padding: 0 var(--content-pad-x);
  display: flex;
  align-items: center;
  gap: var(--space-5);
  position: relative;
}

.topbar__brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: var(--color-text);
  white-space: nowrap;
  height: 100%;
}
.topbar__brand:hover { text-decoration: none; }

.topbar__logo {
  height: 56px;
  width: auto;
  display: block;
  border-radius: 0;
}

.topbar__brand-text {
  font-family: var(--font-title);
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--color-text);
  line-height: 1;
}

/* Nav (horizontal pill links) */
.topbar__nav {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  height: 100%;
  position: absolute;
  left: 50%;
  top: 0;
  transform: translateX(-50%);
}
.topbar__nav::-webkit-scrollbar { display: none; }

.topbar__link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 9px 16px;
  border-radius: 8px;
  color: var(--color-gray-600);
  text-decoration: none;
  font-size: 15px;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: background-color 120ms ease, color 120ms ease;
  white-space: nowrap;
}
.topbar__link:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
  text-decoration: none;
}
.topbar__link.is-active {
  background: var(--color-surface-alt);
  color: var(--color-text);
  font-weight: 600;
}
.topbar__link.is-active::before {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -10px;
  height: 2px;
  background: var(--color-primary);
  border-radius: 2px 2px 0 0;
}

/* Inject icons via Font Awesome unicode based on href.
   Free Solid weights — keep in sync with renderHelpers nav(). */
.topbar__link::before {
  font-family: "Font Awesome 6 Free";
  font-weight: 900;
  font-size: 14px;
  width: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-gray-500);
  transition: color 120ms ease;
}
.topbar__link.is-active::before {
  color: var(--color-primary);
}
.topbar__link[href="/"]::before                  { content: "\f625"; } /* gauge-high */
.topbar__link[href="/sites"]::before             { content: "\f233"; } /* server */
.topbar__link[href="/datawatcherboxes"]::before  { content: "\f2db"; } /* microchip */
.topbar__link[href="/niagarawatchers"]::before   { content: "\f519"; } /* tower-broadcast */
.topbar__link[href="/admin/users"]::before       { content: "\f0c0"; } /* users */
.topbar__link[href="/admin/sites"]::before       { content: "\e3e2"; } /* sitemap */
.topbar__link[href="/admin/noboxes"]::before     { content: "\f1b2"; } /* cube */
.topbar__link[href="/admin/fleet"]::before       { content: "\f6ff"; } /* network-wired */

/* Reset the sliding underline on active links to position correctly under the link */
.topbar__link.is-active::before {
  position: static;
  background: transparent;
  height: auto;
  width: 16px;
}
/* And use a real bottom indicator via box-shadow so it sits over the topbar border */
.topbar__link.is-active {
  box-shadow: inset 0 -2px 0 0 var(--color-primary);
  border-radius: 8px 8px 0 0;
}

/* Right-side actions */
.topbar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-left: auto;
  height: 100%;
}

.topbar__user {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px 6px 6px;
  border-radius: 999px;
  background: var(--color-surface-alt);
  color: var(--color-text);
  font-size: 12.5px;
  font-weight: 500;
  white-space: nowrap;
  border: 1px solid var(--color-border);
}
.topbar__user::before {
  content: attr(data-initials);
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
  color: #fff;
  font-size: 10.5px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: 0.02em;
  flex: 0 0 auto;
}

.topbar__logout { margin: 0; }

/* Logout button shrinks to a clean icon-only chip */
.topbar__logout .btn,
.topbar__logout button[type="submit"] {
  height: 32px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  color: var(--color-text-muted);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.topbar__logout .btn:hover,
.topbar__logout button[type="submit"]:hover {
  background: var(--color-surface-alt);
  color: var(--color-text);
  border-color: var(--color-gray-300);
}

/* Burger (mobile) */
.topbar__burger {
  display: none;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  padding: 0;
  cursor: pointer;
  color: var(--color-text);
  font-size: 16px;
  align-items: center;
  justify-content: center;
}

@media (max-width: 768px) {
  .topbar__inner { padding: 0 16px; gap: 10px; }
  .topbar__brand { padding-right: 10px; }
  .topbar__brand-text { display: none; }
  .topbar__burger { display: inline-flex; }
  .topbar__nav,
  .topbar__user { display: none; }

  .topbar.is-open .topbar__nav {
    display: flex;
    position: absolute;
    top: var(--topbar-height);
    left: 0;
    right: 0;
    background: var(--color-surface);
    border-bottom: 1px solid var(--color-border);
    box-shadow: var(--shadow-md);
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 6px;
    height: auto;
  }
  .topbar.is-open .topbar__link {
    border-radius: 8px;
    padding: 10px 12px;
    box-shadow: none;
  }
  .topbar.is-open .topbar__link.is-active {
    background: var(--color-primary-bg);
    color: var(--color-primary-dark);
    box-shadow: none;
  }
}

/* ============================================================
   Page header — Docker style: clean, restrained
   ============================================================ */
.page-header {
  margin-bottom: 20px;
}

.page-header h1 {
  font-family: var(--font-title);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.018em;
  margin: 0 0 4px;
  color: var(--color-text);
}

.page-header__subtitle {
  color: var(--color-text-muted);
  margin: 0;
  font-size: 13.5px;
}

.page-header__back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  color: var(--color-text-muted);
  font-size: 12.5px;
  text-decoration: none;
}
.page-header__back:hover { color: var(--color-text); text-decoration: none; }

.page-header__row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.page-header__row h1 { margin: 0; }

.section-title {
  margin: 24px 0 12px;
  font-family: var(--font-title);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.005em;
  color: var(--color-text);
}
