.header-toggle {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  color: var(--arena-text-secondary);
  border-radius: var(--r-md);
  cursor: pointer;

  &:hover,
  &:focus-visible {
    background: var(--arena-surface-02);
    color: #fff;
    outline: none;
  }
}

.header-search {
  flex: 1;
  max-width: 420px;
  position: relative;

  .search-icon {
    position: absolute;
    inset-inline-start: 14px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--arena-text-muted);
    pointer-events: none;
  }

  input {
    width: 100%;
    height: 40px;
    padding-inline: 40px 72px;
    background: var(--arena-surface-02);
    border: 1px solid var(--arena-border);
    border-radius: var(--r-md);
    color: var(--arena-text-primary);
    font-size: 0.85rem;
    cursor: pointer;

    &::placeholder {
      color: var(--arena-text-muted);
    }

    &:focus {
      outline: none;
      border-color: rgba(124, 92, 252, 0.5);
      box-shadow: 0 0 0 3px var(--arena-violet-glow);
      background: var(--arena-surface-03);
    }
  }

  .search-kbd {
    position: absolute;
    inset-inline-end: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    gap: 4px;

    .kbd {
      font-size: 0.6rem;
      font-family: var(--font-display);
      padding: 2px 6px;
      background: var(--arena-surface-03);
      border: 1px solid var(--arena-border);
      border-radius: 4px;
      color: var(--arena-text-muted);
    }
  }
}

.header-actions {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-inline-start: auto;
}

.header-btn {
  position: relative;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border: none;
  background: transparent;
  color: var(--arena-text-secondary);
  border-radius: var(--r-md);
  text-decoration: none;
  cursor: pointer;

  &:hover,
  &:focus-visible {
    background: var(--arena-surface-02);
    color: #fff;
    outline: none;
  }

  .badge-count {
    position: absolute;
    top: 6px;
    inset-inline-end: 6px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: var(--arena-red);
    color: #fff;
    font-size: 0.55rem;
    font-weight: 800;
    border-radius: var(--r-full);
    display: grid;
    place-items: center;
    border: 2px solid var(--arena-bg);
  }
}

.header-profile {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: 4px 8px 4px 4px;
  border: none;
  background: transparent;
  border-radius: var(--r-md);
  color: inherit;
  cursor: pointer;

  &:hover,
  &:focus-visible {
    background: var(--arena-surface-02);
    outline: none;
  }

  .avatar {
    width: 34px;
    height: 34px;
    border-radius: var(--r-full);
    object-fit: cover;
    border: 2px solid rgba(124, 92, 252, 0.45);
  }

  .profile-name {
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    line-height: 1.15;
    text-align: start;
  }

  .profile-rank {
    font-size: 0.65rem;
    color: var(--arena-text-muted);
    text-align: start;
  }
}

.dropdown-arena {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  min-width: 240px;
  background: var(--arena-surface-01);
  border: 1px solid var(--arena-border);
  border-radius: var(--r-md);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
  z-index: var(--z-dropdown);
  overflow: hidden;

  &.open {
    display: block;
  }
}

.dropdown-item-arena {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px var(--sp-4);
  color: var(--arena-text-secondary);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 600;

  &:hover {
    background: var(--arena-surface-02);
    color: #fff;
  }

  &.danger {
    color: var(--arena-red);
  }
}

.dropdown-divider {
  height: 1px;
  background: var(--arena-border);
  margin: var(--sp-1) 0;
}

.lang-switcher {
  display: flex;
  gap: 2px;
  background: var(--arena-surface-02);
  border: 1px solid var(--arena-border);
  border-radius: var(--r-sm);
  padding: 2px;

  .lang-btn {
    border: none;
    background: transparent;
    color: var(--arena-text-muted);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 4px;
    cursor: pointer;

    &.active {
      background: var(--arena-violet);
      color: #fff;
    }
  }
}

.command-palette {
  display: none;
  position: fixed;
  top: 18vh;
  left: 50%;
  transform: translateX(-50%);
  width: min(560px, calc(100vw - 32px));
  background: var(--arena-surface-01);
  border: 1px solid var(--arena-border);
  border-radius: var(--r-lg);
  z-index: calc(var(--z-modal) + 1);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.65);
  overflow: hidden;

  &.open {
    display: block;
  }
}

.command-palette-input-wrap {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-4);
  border-bottom: 1px solid var(--arena-border);
}

.command-palette-input {
  flex: 1;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 0.95rem;
  outline: none;
}

.command-results {
  max-height: 360px;
  overflow-y: auto;
  padding: var(--sp-2) 0;
}

.command-group-label {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--arena-text-muted);
  padding: var(--sp-2) var(--sp-4);
}

.command-result-item {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 10px var(--sp-4);
  color: var(--arena-text-secondary);
  text-decoration: none;

  &:hover {
    background: var(--arena-surface-02);
    color: #fff;
  }
}

.arena-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: var(--z-modal);

  &.open {
    display: block;
  }
}
