/* =========================
   SHARED TOPBAR
========================= */

.topbar {
  position: relative;
  z-index: 50;
  width: 100%;
  background: #243d78;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.12);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
}

.topbar-inner {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  min-height: 84px;
  padding: 0 28px;
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  align-items: center;
  column-gap: 28px;
  box-sizing: border-box;
}

.brand {
  display: flex;
  align-items: center;
  justify-self: start;
  min-width: 0;
}

.brand-link {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
}

.logo {
  width: 54px;
  height: 54px;
  object-fit: contain;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  padding: 3px;
  flex-shrink: 0;
}

.brand-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.brand-text h1 {
  margin: 0;
  color: #ffffff;
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.12;
  white-space: nowrap;
}

.subtitle {
  margin: 3px 0 0;
  color: rgba(255, 255, 255, 0.86);
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.main-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  gap: 6px;
  flex-wrap: wrap;
}

.nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 42px;
  padding: 0 18px;
  border-radius: 12px;
  color: rgba(255, 255, 255, 0.92);
  text-decoration: none;
  font-size: 0.96rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.nav-link:hover,
.nav-link.active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  justify-self: end;
  gap: 12px;
  flex-wrap: wrap;
}

.topbar-login-link {
  color: #ffffff;
  text-decoration: none;
  font-size: 0.93rem;
  font-weight: 600;
  white-space: nowrap;
  padding: 8px 0;
  transition: opacity 0.2s ease;
}

.topbar-login-link:hover {
  opacity: 0.85;
}

.topbar-create-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #f2bc2b;
  color: #111827;
  text-decoration: none;
  font-size: 0.92rem;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 12px;
  white-space: nowrap;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.topbar-create-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.topbar-user-role {
  color: rgba(255, 255, 255, 0.88);
  font-size: 0.92rem;
  font-weight: 600;
  white-space: nowrap;
}

@media (max-width: 1180px) {
  .topbar-inner {
    grid-template-columns: 1fr;
    min-height: auto;
    gap: 14px;
    padding: 14px 18px;
  }

  .brand {
    justify-content: center;
  }

  .main-nav {
    justify-content: center;
  }

  .topbar-actions {
    justify-content: center;
    justify-self: center;
  }
}

@media (max-width: 768px) {
  .topbar-inner {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px 14px;
  }

  .brand {
    justify-content: center;
    width: 100%;
  }

  .brand-text h1,
  .subtitle {
    white-space: normal;
    text-align: center;
  }

  .brand-link {
    flex-direction: column;
    gap: 8px;
    width: 100%;
    align-items: center;
    justify-content: center;
  }

  .logo {
    width: 46px;
    height: 46px;
  }

  .brand-text {
    width: 100%;
    max-width: 260px;
    align-items: center;
  }

  .brand-text h1 {
    font-size: clamp(0.95rem, 4vw, 1.15rem);
    line-height: 1.15;
  }

  .subtitle {
    font-size: clamp(0.76rem, 3vw, 0.9rem);
    line-height: 1.3;
  }

  .main-nav {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    width: 100%;
  }

  .nav-link {
    min-height: 42px;
    height: 100%;
    padding: 10px 12px;
    font-size: 0.88rem;
    text-align: center;
  }

  .topbar-actions {
    justify-content: center;
    gap: 10px;
    width: 100%;
  }

  .topbar-login-link,
  .topbar-create-btn,
  .topbar-user-role {
    font-size: 0.88rem;
  }

  .topbar-login-link,
  .topbar-create-btn,
  .topbar-user-role {
    text-align: center;
  }

  .topbar-create-btn {
    min-height: 46px;
  }

  .topbar-user-role {
    max-width: none;
  }
}

@media (max-width: 480px) {
  .topbar-inner {
    padding: 10px 12px;
    gap: 10px;
  }

  .brand-link {
    gap: 6px;
  }

  .logo {
    width: 42px;
    height: 42px;
    border-radius: 12px;
  }

  .brand-text h1 {
    max-width: 12ch;
    font-size: clamp(0.88rem, 5.6vw, 1rem);
  }

  .subtitle {
    max-width: 24ch;
    font-size: clamp(0.68rem, 3.8vw, 0.8rem);
  }

  .main-nav {
    grid-template-columns: 1fr;
  }

  .topbar-actions {
    flex-direction: column;
    align-items: center;
  }

  .topbar-login-link,
  .topbar-create-btn,
  .topbar-user-role {
    width: 100%;
    max-width: 280px;
  }
}

@media (max-width: 360px) {
  .logo {
    width: 38px;
    height: 38px;
  }

  .brand-text {
    max-width: 220px;
  }

  .brand-text h1 {
    font-size: 0.82rem;
  }

  .subtitle {
    font-size: 0.64rem;
  }
}

/* =========================
   SAFE ENHANCEMENTS (NON-BREAKING)
========================= */

/* Prevent overflow issues */
.topbar-inner {
  overflow: hidden;
}

/* Ensure nav wraps nicely on smaller widths */
.main-nav {
  flex-wrap: wrap;
}

/* Prevent long names from breaking layout */
.topbar-user-role {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
}
