/* ── Shared application shell ─────────────────────────────────── */

/* ── Header ── */
header {
  background: #060910;
  border-bottom: 1px solid #131d2c;
  padding: 0 2rem;
  height: 52px;
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
}

.header-inner {
  max-width: 1100px;
  margin: 0 auto;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* ── Logo ── */
.logo {
  font-size: 0.83rem;
  font-weight: 700;
  color: #c8d8ea;
  letter-spacing: -0.025em;
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  transition: color 0.15s;
}
.logo::before {
  content: '';
  display: block;
  width: 6px;
  height: 6px;
  background: #3b82f6;
  border-radius: 1px;
  transform: rotate(45deg);
  flex-shrink: 0;
}
.logo:hover { color: #e8f0f8; text-decoration: none; }

/* ── Primary nav ── */
.sh-nav {
  display: flex;
  align-items: center;
  gap: 0.125rem;
  margin-left: 1.5rem;
}

.sh-nav-link {
  font-size: 0.79rem;
  font-weight: 500;
  color: #3f566b;
  text-decoration: none;
  padding: 0.3rem 0.6rem;
  border-radius: 5px;
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
  letter-spacing: -0.005em;
}
.sh-nav-link:hover {
  color: #7a90a8;
  background: rgba(255, 255, 255, 0.045);
  text-decoration: none;
}
.sh-nav-link[aria-current="page"] {
  color: #a8c0d8;
  font-weight: 600;
}

/* ── Right slot ── */
.header-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

/* ── Environment workspace switcher ── */
.env-switcher {
  position: relative;
  flex-shrink: 0;
}

.env-switcher-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid #1a2d3f;
  border-radius: 6px;
  color: #7a90a8;
  font-size: 0.74rem;
  font-weight: 600;
  padding: 0.28rem 0.55rem 0.28rem 0.7rem;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
  max-width: 200px;
  line-height: 1;
}
.env-switcher-btn:hover {
  border-color: #2a4060;
  color: #a8c0d8;
  background: rgba(255, 255, 255, 0.06);
}
.env-switcher-btn[aria-expanded="true"] {
  border-color: #2a4060;
  color: #a8c0d8;
  background: rgba(255, 255, 255, 0.06);
}

.env-switcher-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.env-switcher-caret {
  font-size: 0.7rem;
  opacity: 0.55;
  flex-shrink: 0;
  display: inline-block;
  transition: transform 0.15s;
  line-height: 1;
}
.env-switcher-btn[aria-expanded="true"] .env-switcher-caret {
  transform: scaleY(-1);
}

.env-switcher-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 5px);
  min-width: 210px;
  max-width: 300px;
  background: #0b1520;
  border: 1px solid #1a2d3f;
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.55), 0 2px 8px rgba(0, 0, 0, 0.3);
  z-index: 200;
  padding: 4px;
  overflow: hidden;
}

.env-option {
  display: block;
  position: relative;
  width: 100%;
  padding: 0.42rem 0.75rem 0.42rem 2rem;
  background: transparent;
  border: none;
  color: #4a6a8a;
  font-size: 0.78rem;
  font-family: inherit;
  cursor: pointer;
  border-radius: 5px;
  text-align: left;
  transition: background 0.1s, color 0.1s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.env-option:hover {
  background: rgba(255, 255, 255, 0.055);
  color: #a8c0d8;
}
.env-option-active {
  color: #c8d8ea;
  font-weight: 600;
}
.env-option-active::before {
  content: '✓';
  position: absolute;
  left: 0.65rem;
  color: #3b82f6;
  font-size: 0.68rem;
  top: 50%;
  transform: translateY(-50%);
}

.env-switcher-sep {
  height: 1px;
  background: #141f2e;
  margin: 4px 0;
}

.env-option-add {
  color: #384e63;
  font-size: 0.74rem;
  font-weight: 500;
}
.env-option-add:hover {
  color: #3b82f6;
  background: rgba(59, 130, 246, 0.08);
}

@media (max-width: 640px) {
  .env-switcher-dropdown {
    right: auto;
    left: 0;
    min-width: 180px;
  }
}

/* ── Footer ── */
.sh-footer {
  border-top: 1px solid #0d1620;
  padding: 1.5rem 2rem;
}
.sh-footer-inner {
  max-width: 1100px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  font-size: 0.67rem;
  color: #1c2c3c;
  flex-wrap: wrap;
}
.sh-footer-brand {
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.61rem;
}
.sh-footer-sep { opacity: 0.35; }

/* ── User pill + logout (auth pages) ── */
#header-user {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}
.header-user-email {
  font-size: 0.72rem;
  color: var(--muted, #7a90a8);
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.header-logout-btn {
  padding: 0.2rem 0.55rem;
  background: transparent;
  border: 1px solid #1e2d3d;
  border-radius: 4px;
  color: #7a90a8;
  font-size: 0.72rem;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}
.header-logout-btn:hover { border-color: #ef4444; color: #ef4444; }

/* ── Responsive ── */
@media (max-width: 600px) {
  header { padding: 0 1rem; height: 48px; }
  .sh-nav { margin-left: 0.5rem; }
  .sh-nav-link { padding: 0.25rem 0.4rem; font-size: 0.74rem; }
  .sh-footer { padding: 1.25rem 1rem; }

  /* Hide verbose user email — keep only the sign-out button */
  .header-user-email { display: none; }

  /* Compact sign-out — icon-sized */
  .header-logout-btn {
    padding: 0.22rem 0.5rem;
    font-size: 0.68rem;
  }
}

/* On very small screens, deprioritise Admin link */
@media (max-width: 380px) {
  .sh-nav-link[href="admin.html"] { display: none; }
}
