/* Site-wide login / profile widget */

.auth-widget {
  position: relative;
  z-index: 40;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.auth-widget--fixed {
  position: fixed;
  top: calc(0.75rem + env(safe-area-inset-top, 0px));
  right: calc(0.85rem + env(safe-area-inset-right, 0px));
  z-index: 90; /* above enter-gate (50) */
}

.topbar-auth-slot {
  position: fixed;
  top: 0;
  right: 0;
  z-index: 90;
  pointer-events: none;
}

.topbar-auth-slot .auth-widget {
  pointer-events: auto;
}

.tools-top--auth {
  grid-template-columns: 1fr auto;
  align-items: start;
}

.tools-top--auth .tools-back {
  grid-column: 1;
}

.tools-top--auth .auth-widget {
  grid-column: 2;
  grid-row: 1;
}

.tools-top--auth .tools-title,
.tools-top--auth .tools-subtitle {
  grid-column: 1 / -1;
}

.auth-login-btn,
.auth-profile-btn {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.16);
  background: rgba(17, 18, 20, 0.92);
  color: var(--text, #f4f4f5);
  border-radius: 0.75rem;
  padding: 0.45rem 0.75rem;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.auth-login-btn:hover,
.auth-profile-btn:hover {
  border-color: rgba(255, 255, 255, 0.35);
}

/* Site Google OAuth (Admin login) — not yt-dlp YouTube session */
.tools-btn--google {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.55rem;
  width: 100%;
  margin: 0.35rem 0 0.15rem;
  background: linear-gradient(180deg, #f8fafc 0%, #e8eaed 100%);
  color: #1f2937;
  border-color: rgba(0, 0, 0, 0.12);
  font-weight: 600;
}

.tools-btn--google:hover,
.tools-btn--google:focus-visible {
  border-color: rgba(66, 133, 244, 0.55);
  filter: brightness(1.02);
  color: #111827;
}

.tools-btn--google::before {
  content: "";
  width: 1.15rem;
  height: 1.15rem;
  flex-shrink: 0;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 48 48'%3E%3Cpath fill='%23EA4335' d='M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z'/%3E%3Cpath fill='%234285F4' d='M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z'/%3E%3Cpath fill='%23FBBC05' d='M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z'/%3E%3Cpath fill='%2334A853' d='M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z'/%3E%3C/svg%3E")
    center / contain no-repeat;
}

.login-divider {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin: 0.85rem 0 0.65rem;
  color: var(--muted, #a1a1aa);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.login-divider::before,
.login-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
}

#login-google-error {
  margin-bottom: 0.65rem;
}

.auth-avatar {
  width: 1.7rem;
  height: 1.7rem;
  border-radius: 50%;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
}

.auth-avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.auth-avatar-fallback {
  font-size: 0.75rem;
  font-weight: 700;
}

.auth-name {
  max-width: 8rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.auth-role-pill {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 0.3rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1.2;
}

.role-admin .auth-role-pill,
.role-admin .auth-name,
.profile-panel.role-admin .profile-username {
  color: #ff6b6b;
}

.role-admin .auth-role-pill {
  background: rgba(220, 60, 60, 0.14);
  border: 1px solid rgba(220, 60, 60, 0.45);
}

.role-beta .auth-role-pill,
.role-beta .auth-name,
.profile-panel.role-beta .profile-username {
  color: #4ea1ff;
}

.role-beta .auth-role-pill {
  background: rgba(78, 161, 255, 0.12);
  border: 1px solid rgba(78, 161, 255, 0.4);
}

.role-user .auth-role-pill,
.role-user .auth-name,
.profile-panel.role-user .profile-username {
  color: #3dd68c;
}

.role-user .auth-role-pill {
  background: rgba(61, 214, 140, 0.12);
  border: 1px solid rgba(61, 214, 140, 0.4);
}

.role-vpn .auth-role-pill,
.role-vpn .auth-name,
.profile-panel.role-vpn .profile-username {
  color: #c084fc;
}

.role-vpn .auth-role-pill {
  background: rgba(192, 132, 252, 0.12);
  border: 1px solid rgba(192, 132, 252, 0.45);
}

/* Per-pill colors when multiple groups are shown */
.auth-role-pill.role-admin {
  color: #ff6b6b;
  background: rgba(220, 60, 60, 0.14);
  border: 1px solid rgba(220, 60, 60, 0.45);
}
.auth-role-pill.role-beta {
  color: #4ea1ff;
  background: rgba(78, 161, 255, 0.12);
  border: 1px solid rgba(78, 161, 255, 0.4);
}
.auth-role-pill.role-vpn {
  color: #c084fc;
  background: rgba(192, 132, 252, 0.12);
  border: 1px solid rgba(192, 132, 252, 0.45);
}
.auth-role-pill.role-user {
  color: #3dd68c;
  background: rgba(61, 214, 140, 0.12);
  border: 1px solid rgba(61, 214, 140, 0.4);
}

.auth-menu {
  position: absolute;
  top: calc(100% + 0.35rem);
  right: 0;
  min-width: 11rem;
  display: grid;
  gap: 0.15rem;
  padding: 0.4rem;
  border-radius: 0.75rem;
  background: rgba(17, 18, 20, 0.98);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.45);
}

/* Author display:grid must not override the HTML hidden attribute */
.auth-menu[hidden] {
  display: none !important;
}

.auth-menu-item,
.auth-menu-item--btn {
  display: block;
  width: 100%;
  text-align: left;
  padding: 0.55rem 0.7rem;
  border-radius: 0.5rem;
  color: var(--text, #f4f4f5);
  text-decoration: none;
  font-size: 0.9rem;
  border: 0;
  background: transparent;
  cursor: pointer;
  font: inherit;
}

.auth-menu-item:hover,
.auth-menu-item--btn:hover {
  background: rgba(255, 255, 255, 0.06);
}

.auth-logout-form {
  margin: 0;
}

.profile-head {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.profile-avatar-lg {
  width: 4.5rem;
  height: 4.5rem;
  border-radius: 50%;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 1.4rem;
  font-weight: 700;
}

.profile-avatar-lg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-username {
  margin: 0 0 0.35rem;
  font-size: 1.35rem;
}

.control-heading {
  margin: 0;
  font-size: 1.1rem;
}

.control-hint-static {
  margin: 0 0 0.75rem;
}

.control-check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1rem;
  margin: 0.35rem 0 0.75rem;
}

.control-check {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.88rem;
  color: var(--muted, #a1a1aa);
  cursor: pointer;
  user-select: none;
}

.control-check input {
  margin: 0;
}

.control-links {
  display: grid;
  gap: 0.75rem;
}

.control-link {
  display: grid;
  gap: 0.55rem;
  padding: 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}

.control-link--hidden {
  opacity: 0.72;
  border-style: dashed;
}

.control-link-main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.control-link-url {
  display: block;
  width: 100%;
  font-size: 0.78rem;
  color: var(--muted, #a1a1aa);
  word-break: break-all;
}

.control-hidden-pill {
  display: inline-block;
  padding: 0.1rem 0.4rem;
  border-radius: 0.3rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.12);
  border: 1px solid rgba(251, 191, 36, 0.4);
}

.control-link-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.control-users {
  display: grid;
  gap: 0.75rem;
}

.control-user {
  display: grid;
  gap: 0.55rem;
  padding: 0.75rem;
  border-radius: 0.75rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
}

.control-user-main {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.control-user-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.45rem;
}

@media (min-width: 560px) {
  .control-user-actions {
    grid-template-columns: 1fr auto auto;
    align-items: center;
  }

  .auth-name {
    max-width: 12rem;
  }
}

.control-inline-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.5rem;
}

.control-inline-row .tools-input {
  flex: 1 1 12rem;
  min-width: 0;
}

.control-failed-logins,
.control-blocked-ips {
  display: grid;
  gap: 0.45rem;
}

.control-failed-row,
.control-blocked-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.45rem 0.75rem;
  padding: 0.55rem 0.65rem;
  border-radius: 0.55rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.18);
  font-size: 0.85rem;
}

.control-pass-mask {
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  color: var(--muted, #a1a1aa);
  letter-spacing: 0.04em;
}

.control-ip {
  font-size: 0.78rem;
}

