/* ==========================================================================
   Layout - Header, Nav, Background, Responsive
   ========================================================================== */

/* ---------- Background Layer ---------- */
.bg-layer { position: fixed; inset: 0; z-index: 0; overflow: hidden; }
.bg-gradient { position: absolute; inset: 0; background: linear-gradient(140deg, #0D1B3E, #1B3869, #0A2344, #111827); background-size: 300% 300%; animation: gradientShift 18s ease infinite; }
html.dark .bg-gradient { background: linear-gradient(140deg, #050a18, #0a1530, #060f22, #080c15); background-size: 300% 300%; }
.bg-orbs { position: absolute; inset: 0; pointer-events: none; }
.bg-orbs img { position: absolute; filter: hue-rotate(195deg) saturate(1.4) brightness(1.1); object-fit: contain; pointer-events: none; }

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* 6 keyframe sets — orbs never move in sync */
@keyframes floatSlow {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(20px, -25px) rotate(3deg); }
  50% { transform: translate(-15px, 20px) rotate(-4deg); }
  75% { transform: translate(25px, 15px) rotate(5deg); }
}

@keyframes floatSlow2 {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-18px, 30px) rotate(-3deg); }
  50% { transform: translate(22px, -18px) rotate(5deg); }
  75% { transform: translate(-12px, -20px) rotate(-6deg); }
}

@keyframes floatMedium {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(-25px, 20px) rotate(5deg); }
  66% { transform: translate(20px, -30px) rotate(-6deg); }
}

@keyframes floatMedium2 {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(30px, -15px) rotate(-5deg); }
  66% { transform: translate(-20px, 28px) rotate(7deg); }
}

@keyframes floatFast {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(18px, -15px) rotate(6deg); }
  50% { transform: translate(-22px, 25px) rotate(-10deg); }
  75% { transform: translate(28px, -18px) rotate(12deg); }
}

@keyframes floatFast2 {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(-20px, 18px) rotate(-8deg); }
  50% { transform: translate(25px, -22px) rotate(10deg); }
  75% { transform: translate(-15px, 12px) rotate(-6deg); }
}

/* ---------- App Container ---------- */
#app {
  position: relative;
  z-index: 2;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  /* min-height instead of height: the header is anchored to --header-height
     for all downstream calc() consumers, but min-height lets it expand
     gracefully if content (e.g. a notification bar) ever needs more room.
     A hard height would force overflow onto the page behind the sticky surface. */
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--sp-xl);
  background: var(--glass-bg);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border-bottom: 1px solid var(--glass-border-secondary);
  box-shadow: var(--shadow-header);
}

.header__brand {
  display: flex;
  align-items: center;
  gap: var(--sp-md);
  text-decoration: none;
  color: var(--base-text);
  cursor: pointer;
}

.header__logo {
  height: 36px;
  width: auto;
  transition: transform 0.3s var(--ease-spring), filter 0.3s ease;
}

.header__logo:hover {
  transform: scale(1.08);
  filter: drop-shadow(0 4px 16px rgba(232, 184, 75, 0.5));
}

.header__title {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, var(--primary), var(--primary-glow));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header__subtitle {
  font-size: 15px;
  font-weight: 600;
  color: var(--base-text);
  opacity: 0.7;
}

/* Nav */
.header__nav {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
}

.nav-link {
  display: flex;
  align-items: center;
  gap: var(--sp-xs);
  padding: var(--sp-xs) var(--sp-md);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  color: var(--muted-text);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.2s;
  border: none;
  background: none;
}

.nav-link:hover {
  color: var(--base-text);
  background: var(--glass-bg-secondary);
}

.nav-link--active {
  color: var(--primary);
  background: var(--glass-bg-secondary);
}

.nav-link__icon {
  width: 16px;
  height: 16px;
}

.nav-separator {
  width: 1px;
  height: 24px;
  background: var(--glass-border-secondary);
  margin: 0 var(--sp-xs);
}

/* Theme toggle */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--base-text);
  cursor: pointer;
  font-size: 18px;
  transition: all 0.3s ease;
}

.theme-toggle:hover {
  background: var(--glass-bg-secondary);
  transform: scale(1.1) rotate(5deg);
}

/* User section wrapper */
#user-section {
  position: relative;
}

/* User menu */
.user-menu {
  display: flex;
  align-items: center;
  gap: var(--sp-sm);
  padding: var(--sp-xs) var(--sp-md);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all 0.2s;
}

.user-menu:hover {
  background: var(--glass-bg-secondary);
}

.user-menu__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}

.user-menu__name {
  font-size: 13px;
  font-weight: 600;
  color: var(--base-text);
}

.user-menu__dropdown {
  position: absolute;
  top: calc(var(--header-height) - 4px);
  right: var(--sp-xl);
  min-width: 180px;
  background: var(--glass-bg);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
  border: 1px solid var(--glass-border-secondary);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-glass);
  padding: var(--sp-xs);
  display: none;
  z-index: 200;
}

.user-menu__dropdown.open {
  display: block;
}

.user-menu__item {
  display: block;
  width: 100%;
  padding: var(--sp-sm) var(--sp-md);
  border: none;
  background: none;
  color: var(--base-text);
  font-size: 13px;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}

.user-menu__item:hover {
  background: var(--glass-bg-secondary);
}

.user-menu__item--danger {
  color: var(--error);
}

/* ---------- Main Content ---------- */
.main-content {
  flex: 1;
  padding: var(--sp-xl);
  max-width: 1400px;
  margin: 0 auto;
  width: 100%;
}

/* ---------- Footer ---------- */
.footer {
  min-height: var(--footer-height);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-sm);
  padding: var(--sp-md) var(--sp-xl);
  font-size: 12px;
  color: var(--muted-text);
  background: var(--glass-bg-secondary);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--glass-border-secondary);
}

/* ---------- View transition ---------- */
#view-container {
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------- Page header ---------- */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-xl);
  flex-wrap: wrap;
  gap: var(--sp-md);
}

.page-header__title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.page-header__actions {
  display: flex;
  gap: var(--sp-sm);
  align-items: center;
}

/* ---------- Constrained Card Widths ---------- */
.glass-card--sm {
  max-width: 500px;
  margin-left: auto;
  margin-right: auto;
}

.glass-card--md {
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
}

/* ---------- Profile Hero ---------- */
.profile-hero {
  text-align: center;
  margin-bottom: var(--sp-xl);
}

.profile-hero__avatar {
  width: 80px;
  height: 80px;
  margin: 0 auto var(--sp-md);
  display: block;
}

.profile-hero__name {
  font-size: 16px;
  font-weight: 600;
}

.profile-hero__email {
  font-size: 13px;
  color: var(--muted-text);
}

.profile-hero__role {
  margin-top: var(--sp-sm);
}

/* ---------- Responsive ---------- */
@media (max-width: 768px) {
  /* On mobile the brand text is hidden, so the header height is driven
     entirely by the logo. Logo is 32px on mobile (fits 56px header with
     vertical clearance). 44px min touch target still met via padding. */
  .header {
    padding: 0 var(--sp-base);
  }

  .header__logo {
    height: 32px;
  }

  .header__title {
    display: none;
  }

  .header__subtitle {
    display: none;
  }

  .nav-link__label {
    display: none;
  }

  .user-menu__name {
    display: none;
  }

  .main-content {
    padding: var(--sp-base);
  }

  .glass-card {
    border-radius: var(--radius-2xl);
    backdrop-filter: blur(40px);
    -webkit-backdrop-filter: blur(40px);
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 480px) {
  .main-content {
    padding: var(--sp-md);
  }

  .glass-card {
    border-radius: var(--radius-2xl);
    padding: var(--sp-md) var(--sp-base);
  }
}
